Jump to content

Selection Set for Elements Inside Polyline (including Polyline)


bigd632

Recommended Posts

I found a LISP someone created that allows you to select a polyline and the program creates a selection set of all the elements inside the polyline. How can I get the program to include the polyline in the SS as well?

 

I tried to create an "en2" variable that is equal to the entity name of "pSS", then do (ssadd en2 ss) to add it onto the current selection set, but haven't gotten it to work. Any suggestions?

 

(vl-load-com)

;; Select window poly
(defun c:SelWP (/)
 (SelPoly "_WP")
 (princ)
)

;; Select objects inside a polyline
(defun SelPoly (WC / pSS ss ss1 n m en)
 (if (and
       (progn
         (prompt "\nSelect polylines to form WPoly borders: ")
         (setq pSS (ssget '((0 . "LWPOLYLINE"))))
       )

       (setq n (sslength pSS)) ;number of polylines selected
(setq ss (ssadd))
     )
   (while (> (setq n (1- n)) -1)
     (if (and
           (setq ss1 (ssget WC (mapcar 'cdr (vl-remove-if-not '(lambda (item) (= (car item) 10)) (entget (ssname pSS n))))))
           (setq m (sslength ss1))	;number of objects inside of polyline
         )
       (while (> (setq m (1- m)) -1)
         (setq en (ssname ss1 m)) ;en = list of entity names inside of polyline
  (ssadd en ss)

       )
     )

     (setq ss1 nil)
     (gc)
   )
 )
 (if (and ss (> (sslength ss) 0))
   (sssetfirst nil ss)
 )
)

Link to comment
Share on other sites

Thanks for your help. I replaced (sssetfirst nil (ssadd ss (ssname pSS 0))) for (sssetfirst nil ss) but I am getting "error: bad argument type: lentitype ". Was I supposed to replace somewhere else?

Link to comment
Share on other sites

Sorry I posted the reply without testing it :oops:

 

Replace / add the following .

 

(and
       (progn
         (prompt "\nSelect polylines to form WPoly borders: ")
         (setq pSS (ssget '((0 . "LWPOLYLINE"))))
       )
   
       (setq n (sslength pSS)) ;number of polylines selected
   (setq ss (ssadd)
             [color=red]ss (ssadd (ssname pSS 0) ss ))[/color]
     )

 

Replace this ...

 

(if (and ss (> (sslength ss) 0))
   (sssetfirst nil ss)
 )

 

With this ...

 

(if (> (sslength ss) 1)
   (sssetfirst nil ss)
 )

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...