(setq la (tblnext "layer" t")) (while (setq la (tbnext "layer")) (setq la-list (append la-list (list (cdr (assoc 2 la))))) )
(setq lyr nil LayNameList nil) (while (setq lyr (tblnext "layer" (not lyr))) (setq name (cdr (assoc 2 lyr)) ename (tblobjname "layer" name) LayNameList (append LayNameList (list ename)) );;setq )::while ___
Or you can upgrade to vlisp: (setq layers (vla-get-layers (vla-get-activedocument (vlax-get-acad-object))) ) (vlax-for n layers (setq lst (cons (handent (vla-get-handle n)) lst)) ) (setq lst (reverse lst)) |B^) Bill
Code: (defun GetLayerEnames ( / result ) (vlax-for layer (vlax-get-property (vlax-get-property (vlax-get-acad-object) 'ActiveDocument ) 'Layers ) (setq result (cons (vlax-vla-object->ename layer) result ) ) ) enames ) Observations: About 25% faster than calls to vla-get-handle / handent, and about 200% faster than equivalent dxf methods (based on limited testing).
Thanks Michael! I'm just starting with the vl stuff. And don't know how to do the speed tests. And of coarse, if you don't put out the bait, you don't get these nice snippets to add to the ol' tool box. Bill
Actually, the code I posted is wrong, it should have read Code: (defun GetLayerEnames ( / result ) (vlax-for layer (vlax-get-property (vlax-get-property (vlax-get-acad-object) 'ActiveDocument ) 'Layers ) (setq result (cons (vlax-vla-object->ename layer) result ) ) ) result ) Sorry for any confusion it may have caused.