PDA

View Full Version : Need HELP: how to retrieve list of layers


bradipos
2005-01-26, 01:25 PM
Hi all, I need to assign the list of the layers of a drawing to a symbol... I´ve red something about the "Layer collection" in the VBA section of the guide but I don´t know how to assign it to a symbol in an AutoLISP routine.

Can anybody help?

Thanks a lot

Alberto

stig.madsen
2005-01-26, 02:23 PM
You could use the Layer collection, or you could check out the TBLNEXT function in the help files. For example, this will return a list of layer names:
(defun getLayers (/ lyr llst)
(while (setq lyr (tblnext "LAYER" (not lyr)))
(setq llst (cons (cdr (assoc 2 lyr)) llst)))
(reverse llst))

msretenovic
2005-01-26, 02:29 PM
Here is a way using VLISP, HTH

(defun MKSxGetLayers(/ lyrCol lyrObj lyrLst)
(setq lyrCol (vla-get-layers (vla-get-activeDocument (vlax-get-acad-object))) ;;get layer collection
lyrLst ()
)
(vlax-for lyrObj lyrCol ;;for each layer in the collection
(setq lyrLst (append lyrLst (list (vla-get-name lyrObj)))) ;;get the name of the layer and append it to the list
)
lyrLst
)