Layer Table

Troy

Usenet Archive
Joined
Jan 25, 2003
Messages
5
Reaction score
0
How can I get the entity names of all of the layers in a drawing?
 
(setq la (tblnext "layer" t"))
(while (setq la (tbnext "layer"))
(setq la-list (append la-list (list (cdr (assoc 2 la)))))
)
 
(while (setq la (tblnext "layer")); replace sorry, quick on the send

Rudy Tovar said:
(setq la (tblnext "layer" t"))
(while (setq la (tbnext "layer"))
(setq la-list (append la-list (list (cdr (assoc 2 la)))))
)
 
But does this return the entname of the layer?
Rudy Tovar said:
(while (setq la (tblnext "layer")); replace sorry, quick on the send
 
(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
___
 
Sorry about that I saw only layer name and not entname.

Do as Paul has outlined.
 
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. 8-)

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.
 

Latest threads

Back
Top