求代码,如何读取当前图纸的所有图层?
请教如何读取当前图纸的所有图层,并达到下面效果?"S-text\nS-colun\nS-hatch"这种字符串!!! (defun all_layers (/ ly l d) ;返回全部图层列表
(setq d (TBLNEXT "LAYER" 't) l nil)
(while d
(setq ly (cdr(assoc 2 d)))
(setq l (append l(list ly)))
(setq d (TBLNEXT "layer"))
)
l
)
谢谢您的解答,请问该如何用啊 我加载了 是不是查询!L呢??? vla-get-layers (Defun c:tt ()
(Vl-Load-Com)
(Setq Mylayers (Vlax-Get (Vlax-Get (Vlax-Get-Acad-Object) 'Activedocument) 'Layers))
(Setq i 0 lyname_lst '())
(Repeat (Vla-Get-Count Mylayers)
(setq lyname (Vla-Get-Name (Vla-Item Mylayers i)))
(setq lyname_lst (Append lyname_lst (List lyname)))
(setq i (1+ i))
)
(vl-sort lyname_lst '<)
) (defun c:tt ()
(setq lay (vlax-get (vlax-get (vlax-get-acad-object) 'activedocument)
'layers
)
lst '()
)
(vlax-for la lay
(setq lst (cons (vlax-get la 'name) lst))
)
lst
) xyp1964 发表于 2014-11-22 12:06 static/image/common/back.gif
;Lisp方法
(defun zg-GetAllLayerList (/ dxf LayerNameList)
(while (setq dxf (tblnext "layer" (not dxf)))
(setq LayerNameList (cons (cdr (assoc 2 dxf)) LayerNameList))
)
;(reverse LayerNameList)
)
;VLisp方法
(defun zg-GetAllLayerList (/ LayerNameList)
(vlax-for x (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object)))
(setq LayerNameList (cons (vla-get-Name x) LayerNameList))
)
;(reverse LayerNameList)
)
页:
[1]