ibach 发表于 2022-7-6 07:03:03

将图层状态替代应用于

如何编写Lsp,使用某种过滤器将保存的图层状态分配给图形中的视口。(例如布局中名称以字符串开头/包含字符串的所有视口,或特定层中的所有视口…)
 
链接到其他线程:层状态保存更新问题
这种lisp可能是问题覆盖。

ibach 发表于 2022-7-6 07:47:34

由于我不能用lisp编写代码,我将尝试起草代码的概念,欢迎对lsp的每个部分提供任何帮助。我会试着把它组合起来。。。
多斯利卜
 
(defun C:CHLSTATEB (/ LAYOUTS PATTERN LAYERLIST ALLVIEWPORTLIST LISTALLST LAYERSTORE)
(setq LAYOUTS(mapcar 'strcase(cons "MODEL" (layoutlist))))
(if(and(setq PATTERN(strcase(getstring "Layoutname (with wildcards):")))
(/= PATTERN "")
)
(progn
;;;Create LAYOUTS list using wildcards
(setq LAYOUTS(vl-remove-if-not '(lambda(X)(wcmatch X PATTERN))LAYOUTS))
(princ (strcat "\n" (itoa(length LAYOUTS))" layouts found."))
(terpri)
(princ LAYOUTS)
(princ)
(terpri)
;;;Create LAYERLIST list using onscreen list box
(setq LAYERLIST (dos_layerlistbox
   "Select layers to use:"
   "(Off and frozen layers available)"
   256) ;;enable multiple selection
   )
(terpri)
(princ LAYERLIST)
(princ)
(terpri)
;;;Create ALLVIEWPORTLIST all viewports
(setq ALLVIEWPORTLIST (vports))
(terpri)
(princ ALLVIEWPORTLIST)
(princ)
;;;Select Layerstate to restore
(setq LISTALLST (layerstate-getnames includehidden includexref))
(terpri)
(princ LISTALLST)
(princ)
(terpri)
(setq LAYERSTORE (dos_listbox "Layerstates" "Select Layerstate to Restore" LISTALLST))
)
)
);;;那么,我做了选择,现在怎么办?
 
(foreach item (layoutlist)
(if (wcmatch item LAYOUTS)
(progn
(setvar "CTAB" item)
;;;Do the layerstate_restore if viewports are on the selected layers
;;;using: layerstate-restore layerstatename viewport )
;;;problem: viewport must not be nil to use flag 4 which is what i need here...
;;;is there a way to specify all or any?
)
)
)

ibach 发表于 2022-7-6 08:28:57

或者,我做了选择。。。不,我做了用户输入,现在我必须过滤掉它并进行实际的图层状态恢复
 
我需要在ALLVIEWPORTLIST上使用ssdel,消除不在选定层和选定布局上的vievports
 
并创建VIEVPORTSTOCHANGE集
 
而不是在新集合上执行layerstaterestore。
 
不!ALLVIEWPORTLIST不好。。。我需要。。。
(setq ALLVIEWPORTLIST (ssget "_X" (list '(0 . "VIEWPORT") (cons 410 (getvar 'ctab)))))。。。。
页: [1]
查看完整版本: 将图层状态替代应用于