creating multiple layers for concentric circles or enclosed/nested polylines

creating multiple layers for concentric circles or enclosed/nested polylines

jabellB8SPL
Explorer Explorer
718 Views
11 Replies
Message 1 of 12

creating multiple layers for concentric circles or enclosed/nested polylines

jabellB8SPL
Explorer
Explorer

I would like to select a a large group of nested objects, such as a concentric circles , and automatically assign each object to layers based on their 'inner' or 'outer' level, e.g. for X number of circles, the circle in the center would be 'Layer 1' and the outer most circle would be the 'Layer X'  (or vice versa).

0 Likes
719 Views
11 Replies
Replies (11)
Message 2 of 12

ara_neresesian
Collaborator
Collaborator

hi

i think you need a lisp file to do like this

if  radius 1 < radius 2  then change circle 1 to 'Layer 1'  and circles 2  to 'Layer X'  (or vice versa)

remember every time you must select 2 circles, 

please upload an image ( before and after ) or cad file for more help

thanks

 

0 Likes
Message 3 of 12

Kent1Cooper
Consultant
Consultant

That would not be difficult for any selection of Circles, sorting them by radius.  And for other shapes such as closed Polylines, sorting by area.  But should checking for "nestedness" or "concentricity" be part of the operation?  Or would you control for that in selection?

Kent Cooper, AIA
0 Likes
Message 4 of 12

jabellB8SPL
Explorer
Explorer

Thank you for the replies.  I've included a picture that is more realistic example of what would be encountered, with each number being the layer that I would like to assign each object to.  As you can see, the area or size of each circle/polyline  is not necessarily indicative of the layer that it will be assigned to.

 

jabellB8SPL_0-1631125000561.png

 

0 Likes
Message 5 of 12

ara_neresesian
Collaborator
Collaborator

let us know

1- the  objects final layer ( just show it as same color  for same layer on picture) or a cad file before and after change

2- how many object you want to select and compare every time ?

 

0 Likes
Message 6 of 12

jabellB8SPL
Explorer
Explorer

1) the picture here shows the layers as different colors (DWG attached too) after converting all from same layer (e.g. layer 0)
2) the number of objects and degree of nesting in the drawing will be very large (e.g. 100-1000's objects, assume at least 5-10 layers), hence the need to do this is in an automated manner.

 

jabellB8SPL_0-1631126807744.png

 

0 Likes
Message 7 of 12

Kent1Cooper
Consultant
Consultant

So that answers my question -- "nestedness" is critical.  Things can't just be sorted by size/area/radius/etc., but it needs to be determined somehow which objects are inside which other objects, and when it's found that A is inside B, whether B is also inside something else [other than just the outermost perimeter object], and, if A is your green shape and B is your blue Circle, whether there might also be C [your red rectangle] in between, that A is inside but that is itself also inside B, and whether....  That looks like a really serious challenge, if it's even possible, but I wouldn't assume it can't be done [yet].

Kent Cooper, AIA
0 Likes
Message 8 of 12

ara_neresesian
Collaborator
Collaborator

HI

its possible but long story ,

this is very raw idea , i need to see the real file and check all possibilities 

  

if there is no  intersection between the shapes ,   ( i hope)

see picture , the lisp starts here

 

 

1=> layer 0 --the object  (white shape) which have all shapes  inside (the white shape will be hide for next step)

2=> layer 1  --the object/s(blue shapes) which have, has, has not  shape/s inside ( the blue shapes will be hide for next) 

3=> layer 2  --the object/s (red shapes) which have, has, has not  shape/s inside ( the red shapes  will be hide for next)

4=> layer 3  --the object/s (green shapes) which have, has, has not  shape/s inside ( the green shapes  will be hide for next)

.

.

.

n=> layer n--the object/s which have, has, has not  shape/s inside ( the object/s will be hide for next)

ends  if no object remain

 

its like surface countering (topography in civil 3d ,for each elevation you can assign different color )  

 

Capture.PNG

0 Likes
Message 9 of 12

Sea-Haven
Mentor
Mentor

I think work backwards no idea past this point but objects with 0 are most inner object. Maybe reset their layer then remove from ss and do again but with layer+1. Till get wp =0

 

Ps circles version 2 as need defun co-ords for circle.

 

 

 

(command "-layer" "m" "1" "c" 1 "" "M" "2" "c" 2 "" "M" "3" "c" 3 "" "m" "4" "c" 4 "" "m" "5" "c" 5 "" "s" "0" "")

(setq ss (ssget "x" (list (cons 0 "LWPOLYLINE")(cons 410 (getvar 'ctab)))))
(setq lst2 '())
(repeat (setq x (sslength ss))
(setq ent (ssname ss (setq x (- x 1))))
(setq ename (cdr (assoc -1 (entget ent))))
(setq lst (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget  ent))))
(setq lst (cons (last lst) lst))
(setq ss2 (ssget "WP" lst '((0 . "LWPOLYLINE"))))
(if (= ss2 nil)
(setq lst2 (cons (list ename 0) lst2))
(setq lst2 (cons (list ename (sslength ss2)) lst2))
)
)
(princ lst2)

 

 

 

0 Likes
Message 10 of 12

ara_neresesian
Collaborator
Collaborator
Basically it can start wherever you want and its look very simple, in this simple shapes
It is very easy to make ss and a counter till end, lets see what is the main course, there is a lot of if , i prefer to see the cad file and then decide what to do
Good luck
0 Likes
Message 11 of 12

Sea-Haven
Mentor
Mentor

Maybe this, only plines at this stage. Needs more but a long way there. Only tested on a few plines up to x deep. Very rough sure can be done better. 

 

 

 

 

(setq y 1 z 0)
(setq ss (ssget "x" (list (cons 0 "LWPOLYLINE")(cons 410 (getvar 'ctab) ))))
(princ (strcat "\nlen " (rtos (sslength ss) 2 0)))
(while (> (sslength ss) 0)
(setq lst2 '())
(repeat (setq x (sslength ss))
(setq ent (ssname ss (setq x (- x 1))))
(setq ename (cdr (assoc -1 (entget ent))))
(setq lst (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget  ent))))
(setq lst (cons (last lst) lst))
(setq ss2 (ssget "WP" lst '((0 . "LWPOLYLINE"))))
(if (= ss2 nil)
(setq lst2 (cons (list ename 0) lst2))
(setq lst2 (cons (list ename (sslength ss2)) lst2))
)
)
(foreach val lst2
(if (= (nth 1 val) (- y 1))
(progn
(entmod (subst (cons 8 (rtos Y 2 0)) (assoc 8 (entget (nth 0 val))) (entget (nth 0 val))))
(entmod (subst (cons 62 (rtos Y 2 0)) (assoc 62 (entget (nth 0 val))) (entget (nth 0 val))))
(setq ss (ssdel (cdr (assoc -1 (entget (nth 0 val)))) ss))
(princ (strcat "\nlen " (rtos (sslength ss) 2 0)))
)
)
)
(setq y (1+ y))
)

 

 

 

 

SeaHaven_0-1631180245075.png

SeaHaven_1-1631181052337.png

 

 

Need real dwg.

0 Likes
Message 12 of 12

Sea-Haven
Mentor
Mentor

Surprised no one else jumped in realised just sort the lst so get (e 0)(e 0)(e 1)(e 2) etc so its easy to put object on layer 1,2,3,4 etc 

 

Need real dwg to look at.

0 Likes