求一个cad关于图层的lisp文件,具体就是关闭未选图层的代码,不是图层隔离,不用天正什么的插件
3个回答
展开全部
是不是通过选取图元,其所在图层是打开的,未选到的图元其所在图层就闭关。如果是这样,请试用下面两程序。
;;选取图元,关闭其所在图层之外的所有图层
(defun c:gbtc()
(vl-load-com)
(setq cm (getvar "cmdecho"))
(setvar "cmdecho" 0)
(command "_undo" "be")
(setq tcmb nil)
(vlax-for layer (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object)))
(setq tcmb (cons (list (vla-get-name layer) layer) tcmb))
)
(if (setq ssa (ssget ))
(progn
(setq tymb (vl-remove-if 'listp (mapcar 'cadr (ssnamex ssa))))
(foreach ent tymb
(setq name (cdr (assoc 8 (entget ent)))
tcmb (vl-remove (assoc name tcmb) tcmb)
)
)
(foreach tcm tcmb
(vla-put-LayerOn (cadr tcm) :vlax-false)
)
)
)
(command "_undo" "e")
(setvar "cmdecho" cm)
(princ)
)
;;打开闭关的所有图层
(defun c:dktc()
(vl-load-com)
(setq cm (getvar "cmdecho"))
(setvar "cmdecho" 0)
(command "_undo" "be")
(setq tcmb nil)
(vlax-for layer (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object)))
(if (= (vla-get-LayerOn layer) ':vlax-false)
(vla-put-LayerOn layer :vlax-true)
)
)
(command "_undo" "e")
(setvar "cmdecho" cm)
(princ)
)
;;选取图元,关闭其所在图层之外的所有图层
(defun c:gbtc()
(vl-load-com)
(setq cm (getvar "cmdecho"))
(setvar "cmdecho" 0)
(command "_undo" "be")
(setq tcmb nil)
(vlax-for layer (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object)))
(setq tcmb (cons (list (vla-get-name layer) layer) tcmb))
)
(if (setq ssa (ssget ))
(progn
(setq tymb (vl-remove-if 'listp (mapcar 'cadr (ssnamex ssa))))
(foreach ent tymb
(setq name (cdr (assoc 8 (entget ent)))
tcmb (vl-remove (assoc name tcmb) tcmb)
)
)
(foreach tcm tcmb
(vla-put-LayerOn (cadr tcm) :vlax-false)
)
)
)
(command "_undo" "e")
(setvar "cmdecho" cm)
(princ)
)
;;打开闭关的所有图层
(defun c:dktc()
(vl-load-com)
(setq cm (getvar "cmdecho"))
(setvar "cmdecho" 0)
(command "_undo" "be")
(setq tcmb nil)
(vlax-for layer (vla-get-Layers (vla-get-ActiveDocument (vlax-get-acad-object)))
(if (= (vla-get-LayerOn layer) ':vlax-false)
(vla-put-LayerOn layer :vlax-true)
)
)
(command "_undo" "e")
(setvar "cmdecho" cm)
(princ)
)
追问
这个程序怎么用,复制到记事本再改成lisp格式?
2015-01-11 · 知道合伙人软件行家
关注
展开全部
(command "LAYER" "Off" "图层" "");关闭这个【图层】
(command "LAYER" "ON" "图层" "");打开这个【图层】
不知道是不是你需要的。
如果要关闭除了选择对象的图层;(setvar "clayer" "图层");设置这个图层为当前,然后逐个关闭其它的图层。
(command "LAYER" "ON" "图层" "");打开这个【图层】
不知道是不是你需要的。
如果要关闭除了选择对象的图层;(setvar "clayer" "图层");设置这个图层为当前,然后逐个关闭其它的图层。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询