(vl-load-com)

;; Select window poly
(defun c:sip (/)
(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)
ss (ssadd (ssname pSS 0) ss ))
)
(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 (> (sslength ss) 1)
(sssetfirst nil ss)
)
)
(c:sip)

Advertisements