打开文档间的图层同步,附源码
本帖最后由 vectra 于 2015-5-10 21:28 编辑有没有在图层管理器里导入导出las文件来同步图层设置,想要重置宿主文件中的图层设置为外部参照中的设置?请使用rl命令节省时间。
(setq *layer-properties*
'(color linetype lineweight plottable
plotstylenameviewportdefault layeron
lock freeze description
)
)
(defun getlayerproperties (/ dat lst)
(vlax-for lay(vla-get-layers
(vla-get-activedocument (vlax-get-acad-object))
)
(foreach prp *layer-properties*
(if (vlax-property-available-p lay prp)
(setq lst (cons (vlax-get-property lay prp) lst))
)
)
(setq dat (cons (cons (vla-get-name lay) (reverse lst)) dat)
lst nil
)
)
dat
)
(defun setlayerproperties (dat prefix / layer value)
(foreach e dat
(if(not (vl-catch-all-error-p
(setq layer
(vl-catch-all-apply
'vla-item
(list (vla-get-layers
(vla-get-activedocument (vlax-get-acad-object))
)
(strcat prefix (car e))
)
)
)
)
)
(progn
(setq value (cdr e))
(foreach prp *layer-properties*
(if (vlax-property-available-p layer prp t)
(vl-catch-all-apply
'vlax-put-property
(list layer prp (car value))
)
)
(setq value (cdr value))
)
)
)
)
(vla-regen (vla-get-activedocument (vlax-get-acad-object))
acallviewports
)
)
;; reset layer settings
(defun c:rl (/ ret sel)
(initget "S A X")
(setqret (getkword
"打开文档间的图层同步 [提取图层设置(S)/应用到当前文档(A)/应用到外部参照(X)]:"
)
)
(cond
((= ret "S")
(vl-bb-set 'layer-settings (getlayerproperties))
)
((= ret "A")
(setlayerproperties (vl-bb-ref 'layer-settings) "")
)
((= ret "X")
(setq sel (entsel "\n选择外部参照:"))
(if (and
(vl-consp sel)
(= "INSERT"
(cdr (assoc 0 (setq sel (entget (car sel)))))
)
(= 4
(logand
4
(cdr
(assoc 70
(tblsearch "block" (cdr (assoc 2 sel)))
)
)
)
)
)
(progn
(setlayerproperties
(vl-bb-ref 'layer-settings)
(strcat (cdr (assoc 2 sel)) "|")
)
)
)
)
)
(princ)
)
留个脚印,没看太懂和协调图层有什么关系 感觉不错试一下 (defun c:xttc ()
;协调图层
(command "-layer" "e" "*" "")
(princ)
)
页:
[1]