Quantcast
Channel: Autodesk AutoCAD forums
Viewing all articles
Browse latest Browse all 14319

How to loop based on number of selected & filtered objects

$
0
0

Hello again guys.

 

I am looking for a way to extract (filter) all polylines, and loop a lisp based on the number that are found within a "W" selection window.

 

I am frustrated getting "malformed list" or errors, even after defining "n" for repeat.
The code I have so far looks like this:

 

(defun c:PWW (/ p1 p2 sspw myObj ss)
(setq p1 (getpoint "\nPick first corner: "))
  (setq p2 (getcorner p1 "\nSpecify opposite corner: "))
  (if
   (setq sspw (ssget "W" p1 p2 '((0 . "*POLYLINE")))
  )

(repeat n
 (command "_.explode" sspw)
 (command "_.pedit" "m" sspw "" "Y" "J" "" "")
; (command "_.pedit" "m" sspw "" "w" 0.01 "" )
; (command "_.pedit" "m" sspw "" "w" 0 "" )
)

);end defun
 (princ "\nConverted all 2D Polylines.")
(princ)
)

 

==

Without the (repeat () portion, it was working ok with selection window, however it only would run the commands for a single polyline.  What needs to be done without overhauling the code?  The lisp has worked on a drawing-wide basis, however needs to run on only on user-windowed polylines since there are other polylines within the drawing which are attached to layouts via viewports.  As with my previous post, this has to be done on a multitude of objects, with exception this time of localized areas.


Viewing all articles
Browse latest Browse all 14319

Trending Articles