
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Im sure this has been covered ad infinitum but ive been hunting the forums and internet sources and cant get it to work.
Im converting a companies standard details to something resembling an actual standard. One of the issues is theres a mix of color by layer, by object and "just plop that on whatever layer has that color" throughout the master file.
The new standard detail... standard... is everything on a single detail layer with color set by entity. (this is done as these details will never change so a single layer to toggle on/off keeps things tidy elsewhere)
I wrote a working function that gets the layer color from an entity and appends it to the dxf description of that object. where ive run aground is finding a way to run that same function on each item in a selection set. Note, Im ok with lisp to a degree but never had to write something that processes like this so its a good learning opportunity.
Current Code:
(defun c:zza (/ obj curlay curlaycol )
(setq obj (entget (car (entsel "\nSelect an object"))));set "obj" to the database definition of selected object
(setq curlay (cdr (assoc 8 obj)));Get object layer name
(setq curlaycol (cons 62 (cdr (assoc 62 (tblsearch "LAYER" curlay)))));get object layer color
(setq obj (append obj (list curlaycol)));add color to object definition
(setq obj (subst (cons 8 "DNL-DETAILS")(assoc 8 obj) obj));set object layer do "DNL-DETAILS"
(entmod obj);Update object database definition
(princ))
I tried using a couple of the options from Lee Mac's tutorials, basically replacing "obj" entsel with "e" and replacing the the line "x (cdr (assoc 0 (entget currentent)))" with my program but i keep breaking the otherwise working sample code
(defun c:test1 ( / e i n s x )
(if (setq s (ssget))
(progn
(setq i 0
n (sslength s)
)
(while (< i n)
(setq e (ssname s i)
x (cdr (assoc 0 (entget e)))
i (1+ i)
)
(print x)
)
)
)
(princ)
)
TLDR: Im after pointers to convert my single object function to run on each entity in a selection set.
thanks in advance
Solved! Go to Solution.