@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