作为一个小规模的例子,我附上了我的图层属性管理器的图片。
我试图实现的是一个按钮宏,它将删除所有冻结的层以及层上的对象。
目前,我使用以下步骤缓慢完成这一切:
1、锁定所有层的按钮:
^C^C_layer LO * ^C^C
2.然后解冻并解锁冻结的层(在图层属性管理器GUI中),然后选择模型中的所有对象,然后删除。
3、点击按钮解锁所有层:
^C^C_layer U * ^C^C
我希望简化第二步。但这通常是macro功能结束的地方,需要开始使用LISP,所以我不抱太大希望。 你试过分层行走吗?
只是为了好玩,这是我能做的最好的这么快-我可能需要修改再生步骤-但试一试:
(defun c:LAYSWAP(/ *error* _swapVal _layswap)
(vl-load-com)
(princ "\rLAYSWAP ")
(defun *error*(msg)
(if acDoc
(vla-endundomark acDoc))
(cond ((not msg)) ; Normal exit
((member msg '("Function cancelled" "quit / exit abort"))) ; <esc> or (quit)
((princ (strcat "\n** Error: " msg " ** ")))) ; Fatal error, display it
(princ))
(defun _swapVal(val)
(if (= :vlax-true val)
:vlax-false
:vlax-true))
(defun _layswap(oLayer lst)
(foreach itemlst
(eval item)))
((lambda (acDoc cLayer / mode)
(initget "ALL FREEZE ON LOCK PLOT")
(if (or (setq mode
(getkword
"\nSpecify mode <Freeze>: "))
(not mode))
(progn
(vla-startundomark acDoc)
(vlax-for oLayer(vla-get-layers acDoc)
(if (/= (vla-get-name oLayer) cLayer)
(cond
((or (= nil mode) (= "FREEZE" mode))
(_layswap
oLayer
(list '(vla-put-freeze
oLayer
(_swapVal (vla-get-freeze oLayer))))))
((= "ALL" mode)
(_layswap
oLayer
(list '(vla-put-freeze
oLayer
(_swapVal (vla-get-freeze oLayer)))
'(vla-put-layeron
oLayer
(_swapVal (vla-get-layeron oLayer)))
'(vla-put-lock
oLayer
(_swapVal (vla-get-lock oLayer)))
'(vla-put-plottable
oLayer
(_swapVal (vla-get-plottable oLayer))))))
((= "ON" mode)
(_layswap
oLayer
(list '(vla-put-layeron
oLayer
(_swapVal (vla-get-layeron oLayer))))))
((= "LOCK" mode)
(_layswap
oLayer
(list '(vla-put-lock
oLayer
(_swapVal (vla-get-lock oLayer))))))
((= "PLOT" mode)
(_layswap
oLayer
(list '(vla-put-plottable
oLayer
(_swapVal (vla-get-plottable oLayer)))))))))
;;(vla-regen acDoc acAllViewports)
(vl-cmdf "._regenall")
))
(*error* nil))
(vla-get-activedocument (vlax-get-acad-object))
(getvar 'clayer)))
再次执行同一选项的LAYSWAP将“撤消”初始选项。
无“全部”(首选项):
(defun c:LayTog (/ *error* lst option)
(defun *error* (msg)
(and *AcadDoc* (vla-endundomark *AcadDoc*))
(if (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*,")))
(princ (strcat "\nError: " msg))
)
)
(vla-startundomark
(cond (*AcadDoc*)
((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object))))
)
)
(initget "Freeze Lock On Plot")
(if (setq option
(cdr
(assoc
(getkword "\nSpecify toggle option: : ")
(setq lst '(("Freeze" . freeze) ("Lock" . lock) ("On" . layeron) ("Plot" . plottable)))
)
)
)
(progn (vlax-for layer (vla-get-layers *AcadDoc*)
(vl-catch-all-apply 'vlax-put (list layer option (~ (vlax-get layer option))))
)
(vla-regen *AcadDoc* acActiveViewport)
)
)
(*error* nil)
(princ)
)
“全部”:
(defun c:LayTog2 (/ *error* lst option)
(defun *error* (msg)
(and *AcadDoc* (vla-endundomark *AcadDoc*))
(if (and msg (not (wcmatch (strcase msg) "*BREAK*,*CANCEL*,*QUIT*,")))
(princ (strcat "\nError: " msg))
)
)
(vla-startundomark
(cond (*AcadDoc*)
((setq *AcadDoc* (vla-get-activedocument (vlax-get-acad-object))))
)
)
(initget "All Freeze Lock On Plot")
(if (setq option
(cdr
(assoc
(getkword "\nSpecify toggle option: : ")
(setq lst '(("All" . "All")
("Freeze" . freeze)
("Lock" . lock)
("On" . layeron)
("Plot" . plottable)
)
)
)
)
)
(progn (cond ((eq option "All")
(setq lst (mapcar 'cdr (cdr lst)))
(vlax-for layer (vla-get-layers *AcadDoc*)
(foreach opt lst
(vl-catch-all-apply 'vlax-put (list layer opt (~ (vlax-get layer opt))))
)
)
)
((vlax-for layer (vla-get-layers *AcadDoc*)
(vl-catch-all-apply 'vlax-put (list layer option (~ (vlax-get layer option))))
)
)
)
(vla-regen *AcadDoc* acActiveViewport)
)
)
(*error* nil)
(princ)
) 谢谢
我在其他方面使用LAYWALK,但在这种情况下它不会切换冻结层。
还有RenderMan和alanjt,非常感谢您的投入。在我工作的地方,我们仍然只有LT,所以我无法实施这些。非常抱歉。
你怎么这么快就把它们组合起来了?你有使用的代码生成器吗? 好吧,我想我可能简化了逻辑:
我想自动(宏、脚本或DIESEL)锁定所有冻结层的过程。我不知道该怎么做。
页:
1
[2]