Selecting Object in Specific Layer with in a Boundary

Selecting Object in Specific Layer with in a Boundary

jhunelb
Explorer Explorer
759 Views
2 Replies
Message 1 of 3

Selecting Object in Specific Layer with in a Boundary

jhunelb
Explorer
Explorer

Hi Experts,

 

I found this code here and I want to add a filter so that it will only select objects in specific layer.

 

(defun c:SWC (/ _pac add ss i temp i2)
;; Select Within Curve
;; Alan J. Thompson, 03.31.11

(vl-load-com)

(defun _pac (e / l v d lst)
(setq d (- (setq v (/ (setq l (vlax-curve-getDistAtParam e (vlax-curve-getEndParam e))) 100.))))
(while (< (setq d (+ d v)) l)
(setq lst (cons (vlax-curve-getPointAtDist e d) lst))
)
)

(princ "\nSelect closed curves to select object(s) within: ")
(if (setq add (ssadd)
ss (ssget '((-4 . "<OR")
(0 . "CIRCLE,ELLIPSE")
(-4 . "<AND")
(0 . "*POLYLINE")
(-4 . "&=")
(70 . 1)
(-4 . "AND>")
(-4 . "OR>")
)
)
)
(progn (repeat (setq i (sslength ss))
(if (setq temp (ssget "_CP" (_pac (ssname ss (setq i (1- i))))))
(repeat (setq i2 (sslength temp)) (ssadd (ssname temp (setq i2 (1- i2))) add))
)
)
(sssetfirst nil add)
(ssget "_I")
)
)
(princ)
)

 

Can you help me identify where to put this line:

 

'((-4 . "<or")(8 . "Layer01")(-4 . "or>"))

 

so I can only select object in this layer.

 

Thank you! 

0 Likes
Accepted solutions (1)
760 Views
2 Replies
Replies (2)
Message 2 of 3

ВeekeeCZ
Consultant
Consultant
Accepted solution
      (progn (repeat (setq i (sslength ss))
	     (if (setq temp (ssget "_CP" (_pac (ssname ss (setq i (1- i)))) '((8 . "Layer01"))))
	       (repeat (setq i2 (sslength temp)) (ssadd (ssname temp (setq i2 (1- i2))) add))
	       )
	     )

 

And as matter of fact, you rather need the AND than OR. But since it works as implied, you don't need to spell it out. See not about <and ... and> HERE ... 

 

Edit: Sorry, this makes much more sense.

0 Likes
Message 3 of 3

jhunelb
Explorer
Explorer

Works like a charm!

Thanks man! 

0 Likes