LISP problem for polylines

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?
--
Bill DeShawn
snipped-for-privacy@nospamsterling.net
  Click to see the full signature.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
snipped-for-privacy@sterling.net (Bill DeShawn) wrote in

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.
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
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.

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
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
">

Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

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(< i bndry_cnt) (setq bndry_ed(entget(ssname bndry_ss i)) cnt 0 ) ; ; Get the points that make up the boundary closed pline and put them into a list. (while(setq pnt(nth cnt bndry_ed)) (cond ((equal (car pnt) 10) (setq bndry_ptlst(append bndry_ptlst(list (cdr(nth cnt ry_ed)) ))) ) );-end cond (setq cnt(1+ cnt)) );-end while
; ; Now that we have a list defining the closed boundary pline, lets find the objects we want to change ; that reside within it. ; ; Find all plines within the closed pline (setq obj_ss nil) (setq obj_ss(ssget "_WP" bndry_ptlst (list (cons 0 "LWPOLYLINE"))))
; ; Change the found pline color to BLUE (setq obj_cnt 0 obj_cnt(sslength obj_ss) ii 0 ) (if(> 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
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload
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(< i bndry_cnt) (setq bndry_ed(entget(ssname bndry_ss i)) cnt 0 bndry_ptlst nil ) ; ; Get the points that make up the boundary closed pline and put them into a list. (while(setq pnt(nth cnt bndry_ed)) (cond ((equal (car pnt) 10) (setq bndry_ptlst(append bndry_ptlst(list (cdr(nth cnt ry_ed)) ))) ) );-end cond (setq cnt(1+ cnt)) );-end while
; ; Now that we have a list defining the closed boundary pline, lets find the objects we want to change ; that reside within it. ; ; Find all plines within the closed pline (setq obj_ss nil) (setq obj_ss(ssget "_WP" bndry_ptlst (list (cons 0 "LWPOLYLINE"))))
; ; Change the found pline color to BLUE (setq obj_cnt 0 obj_cnt(sslength obj_ss) ii 0 ) (if(> 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
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
<%-name%>
Add image file
Upload

Polytechforum.com is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here. All logos and trade names are the property of their respective owners.