Applying the current Layer Color to a new Layer using LISP

by Fenton Webb

To apply the current Layer’s colour to a newly created Layer using LISP can be done very simply like this:

; get the current layer name
(setq currentLayer (getvar "CLAYER"))
; get the ename of the current layer from the Layer table
(setq currentLayerEname (tblobjname "LAYER" currentLayer))
; extract the group code 62 (colour) from the ename using entget
(setq currentLayerColour (cdr (assoc 62 (entget currentLayerEname))))
; finally create the new layer using (command "LAYER")
(command "_.-LAYER" "_N" "TEST2" "_C" currentLayerColour "TEST2" "")


Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading