How do I use LISP to search for closed polylines that totally encompass other polylines and create duplicates of those and place them on a new layer?
LISP problem for polylines
Aug 03, 2004
5 Replies
snipped-for-privacy@sterling.net (Bill DeShawn) wrote in news: snipped-for-privacy@posting.google.com:
everything except the "totally encompass other" is pretty easy. is there perhaps another way to pose the question?
all vertices within a set of vertices would be very much programming.
for example, if you are only dealing with rectangles it would get far simpler, if the polygon could be horse shoe shaped, finding what is enclosed by it becomes MUCH harder.
Bill, it's rather simple using the ssget and sslength functions. After you aquire the closed pline(s) (using the ssget) pull the point list or vertices if not using LWPlines. Place these into a list and use the ssget function with the "WP" (polygon) option and filters for closed plines.
Now simply copy the found plines and change their color using the subst and entmod functions.
Actually it might be better if I gave you an example piece of code. Send me an email and I'll put something together for you that should make it clear... 'cause the way I described it earlier sucked!
Take care, TimB
">
Here is some code that will get you started, Bill. Nothing special but it will search out all closed lwplines and change the layer name of any plines that reside within them (rigth now it changes them to FRED as an example. Please note, this is just something to get you started and in the right direction.
Take care and I hope it helps you. TimB
(defun C:TESTCPL(/ bndry_ss bndry_cnt bndry_ptlst bndry_ed i ii cnt pnt obj_ss obj_cnt obj_ed) ; ; Aquire the closed plines to define the search boundaries (setq bndry_ss(ssget "X" (list (cons 70 1) (cons 0 "LWPOLYLINE"))))
; ; Preset some variables (setq bndry_cnt 0 bndry_cnt(sslength bndry_ss) i 0 )
; ; Spin through the found pline boundaries (if(> bndry_cnt 0)(progn (while( obj_cnt 0)(progn (while(< ii obj_cnt) (setq obj_ed(entget(ssname obj_ss ii))) ; ; change the layer name to "FRED" and modify the object (setq obj_ed (subst (cons 8 "FRED") (assoc 8 obj_ed) obj_ed)) (entmod obj_ed) (setq ii(1+ ii)) );- end while ));-end progn and if
(setq i(1+ i)) );-end while ));-end progn and if
(princ) );-end defun
For cripes sakes! my mind is in a fogg these days. I forgot to nil out the bndry_ptlst... here is the up dated code.
(defun C:TESTCPL(/ bndry_ss bndry_cnt bndry_ptlst bndry_ed i ii cnt pnt obj_ss obj_cnt obj_ed) ; ; Aquire the closed plines to define the search boundaries (setq bndry_ss(ssget "X" (list (cons 70 1) (cons 0 "LWPOLYLINE"))))
; ; Preset some variables (setq bndry_cnt 0 bndry_cnt(sslength bndry_ss) i 0 )
; ; Spin through the found pline boundaries (if(> bndry_cnt 0)(progn (while( obj_cnt 0)(progn (while(< ii obj_cnt) (setq obj_ed(entget(ssname obj_ss ii))) ; ; change the layer name to "FRED" and modify the object (setq obj_ed (subst (cons 8 "FRED") (assoc 8 obj_ed) obj_ed)) (entmod obj_ed) (setq ii(1+ ii)) );- end while ));-end progn and if
(setq i(1+ i)) );-end while ));-end progn and if
(princ) );-end defun
Join the Discussion
Have something to add? Share your thoughts — no account required.
Didn't find your answer?
Ask the community — no account required