Build list with the directions of the polylines

Build list with the directions of the polylines

adaptacad
Advocate Advocate
2,486 Views
27 Replies
Message 1 of 28

Build list with the directions of the polylines

adaptacad
Advocate
Advocate

There is a way to steal the direction a polyline is in accordance with the block, whether it is on the right, left, front or back and how many are in that direction.
and return a list like this ' ((2 "front") (0 "back") (2 "right") (1 "left"))
if someone helps me i will be very happy,
Thank you very much in advance!

 

adaptacad_0-1599768985241.png

 

 

0 Likes
Accepted solutions (1)
2,487 Views
27 Replies
Replies (27)
Message 21 of 28

adaptacad
Advocate
Advocate

how to get the color to add to my list (the first item will be the color number of the entity)
((4 0 "NE") (4 2 "N") (nil 0 "NO") (4 2 "O") (nil 0 "SO") (4 2 "S") (nil 1 "SE") (4 1 "E"))

0 Likes
Message 22 of 28

adaptacad
Advocate
Advocate

excluded!

0 Likes
Message 23 of 28

Kent1Cooper
Consultant
Consultant

@adaptacad wrote:

....
(if ss (setq n (sslength ss)) (setq n 0))
(setq ent (ssname ss i))
(setq clr (cdr (assoc 62 (entget ent))))
(setq ret (list clr n dir))
;(setq ret (cons (list n dir) ret))
(setq i (+ i 1))
....

Why not add color ??


Careful -- if an object's color is ByLayer, there will be no (assoc 62) entry in its entity data.  [The nil in your example list that came in while I was writing this, I assume.]

 

Also, you need to wrap multiple operations into one 'then' argument for what to do if the Fence finds anything, including the setting of n to the number and all your blue stuff, which would mean stepping through ss.  This would involve a (progn) function wrapping those things together, and the setting of n to 0 would go outside that afterwards, as the 'else' argument for when nothing was found.  But before suggesting something, I have a question:

 

What if the Fence finds more than one thing, and they're not all of the same color?  You can put a single number of things found aiming in a given general direction, but what do you do about their colors?  If they're not all the same color, how would you indicate that and still have one number for the quantity?  Or if you don't put a single number for the quantity, but a series of numbers of quantities of whatever different colors are included, what would the resulting list look like?  [Now I see your example list -- my pieces are in a different order, but you get the idea.]  Maybe....

("N" 1 "red" 3 "blue")

But what about color numbers instead of names, because of the possibility of number-only colors?  Sublists?  Maybe....

("N" (1 1) (3 5))

Kent Cooper, AIA
0 Likes
Message 24 of 28

Kent1Cooper
Consultant
Consultant

@adaptacad wrote:

@Kent1Cooper  The chance of this influencing is very small !! I believe it will be in very, very rare cases.


As long as the "very, very rare," but still possible, incorrect result  is acceptable to you....

Kent Cooper, AIA
0 Likes
Message 25 of 28

adaptacad
Advocate
Advocate

("N" (1 1) (3 5)) <- That result would be Perfect !!
but I have many limitations and I don't know how to do it

0 Likes
Message 26 of 28

hak_vz
Advisor
Advisor

Will try to figure out something better to avoid what @Kent1Cooper  has elaborated.

Miljenko Hatlak

EESignature

Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
Message 27 of 28

adaptacad
Advocate
Advocate

Don't bother @hak_vz you already helped a lot !!! and it's working well.

0 Likes
Message 28 of 28

adaptacad
Advocate
Advocate

This is almost there.
How do I loop to get the two polylines?

 

(defun c:indira ( / deg_to_rad pt p1 p2 anglist dirlist ss i ret)
(defun deg_to_rad (deg)(* pi (/ deg 180.0)))
(setq pt (getpoint "\nSelect centerpoint >"))
(setq anglist (mapcar 'deg_to_rad '(22.5 67.5 112.5 157.5 202.5 247.5 292.5 337.5 22.5)))
(setq dirlist '("NE" "N" "NO" "O" "SO" "S" "SE" "E"))
(setq i 0)
(foreach dir dirlist
(setq p1 (polar pt (nth i anglist) 5))
(setq p2 (polar pt (nth (+ i 1) anglist) 5))
(setq ss (ssget "F" (list p1 p2)))
  
  
(if ss 
(setq n (sslength ss))
(setq n 0)
)
  
(if (/= n 0)
(and 
(setq ent (ssname ss 0))
(if (/= (cdr (assoc 62 (entget ent))) nil)
(setq clr (cdr (assoc 62 (entget ent))))
)
)
(setq clr 0)
)
 
(setq ret (cons (list dir (list clr n )) ret))
(setq i (+ i 1))
)
(reverse ret)
)

 

get out of it

>(("NE" (0 0)) ("N" (0 0)) ("NO" (2 2)) ("O" (0 0)) ("SO" (0 0)) ("S" (0 0)) ("SE" (4 1)) ("E" (2 1)))

 

for this

>(("NE" (0 0)) ("N" (0 0)) ("NO" (2 1)(4 1)) ("O" (0 0)) ("SO" (0 0)) ("S" (0 0)) ("SE" (4 1)) ("E" (2 1)))

 

adaptacad_0-1600269038560.png

 

 

 

0 Likes