属性值更新全局
大家好,你能给我一个在不改变现有值的情况下在多个布局中更新块属性值的解决方案吗。
如:
标签
DT3
价值
“第01部分”
我需要将该值编辑为“MEP Part-01”
多重布局有不同的编号。
所以我需要在所有布局中添加“MEP”。
感谢阅读 欢迎来到CadTutor
-属性块的名称是什么?
-是否要根据第01部分或根据标记名更改值?
塔瓦特 下面的宏应该可以工作,它将更改DT3的所有值以添加MEP-,宏不会接受字符串中的空格,因此在结尾处为-
^C^C-attedit;n;n;;DT3;;;MEP-;
但是请先在文件的副本上使用这个来检查结果 快捷键。。。
....removed... @塔瓦特
块名为“Title-A1-Text”,我需要根据标签“DT3”进行更改
多个布局具有不同的值,例如:布局1具有第01部分,布局2具有第2部分等。。。
我需要在第01部分、第02部分等之前添加“MEP”。。。在不更改每个布局中的零件号的情况下
谢谢你的回复。
pBe发布的代码对你有帮助吗?
否则,如果你可以上传一个样例绘图,在上面测试我的代码就太好了 无论如何,试试这个未经测试的程序,让我知道。
(defun c:Test (/ tag ss lock)
;; Tharwat 22. Oct. 2013 ;;
(or acdoc
(setq acdoc (vla-get-activedocument (vlax-get-acad-object)))
)
(vlax-for x (vla-get-layers acdoc)
(if (eq :vlax-true (vla-get-lock x))
(vla-put-lock (car (setq lock (cons x lock))) :vlax-false)
)
)
(if (setq tag "DT3"
ss(ssget "_X"
'((0 . "INSERT") (66 . 1) (2 . "Title-A1-Text"))
)
)
(progn
(vla-StartUndoMark acdoc)
((lambda (x / sn e)
(while (setq sn (ssname ss (setq x (1+ x))))
(while
(and (setq sn (entnext sn))
(/= (cdr (assoc 0 (setq e (entget sn)))) "SEQEND")
)
(if (and (eq (cdr (assoc 0 e)) "ATTRIB")
(eq (strcase (cdr (assoc 2 e))) tag)
)
(entmod (subst (cons 1 (strcat "MEP " (cdr (assoc 1 e))))
(assoc 1 e)
e
)
)
)
)
)
)
-1
)
(vla-EndUndoMark acdoc)
)
)
(foreach layer lock (vla-put-lock layer :vlax-true))
(vla-regen acdoc AcAllViewports)
(princ)
)
(vl-load-com)
以适应您发布的条件:
(defun c:c2 (/ ss i e tag str_ str)
(setq tag"DT3"
str_ "*PART*"
)
(if (setq ss (ssget "_X" '((0 . "INSERT") (66 . 1)(2 . "`*U*,Title_A1_Text")(410 . "~Model"))))
(repeat (setq i (sslength ss))
(setq e (vlax-ename->vla-object (ssname ss (Setq i (1- i)))))
(if (and (Eq (Strcase (vla-get-effectivename e)) "TITLE_A1_TEXT")
(vlax-write-enabled-p e))
(vl-some
'(lambda (x)
(if
(and
(eq (vla-get-tagstring x) tag)
(wcmatch (strcase (setq str (vla-get-textstring x))) str_)
(not (wcmatch str "*"))
)
;;; in case layer "0" is also locked considering ;;;
;;; most blocks are created at layer "0" ;;;
(vl-catch-all-error-p
(vl-catch-all-apply
'vla-put-textstring
(list x (strcat "MEP " str))
)
)
;;; ;;;
)
)
(vlax-invoke e 'Getattributes)
)
)
)
)
(princ)
)
大家好,
我在这里附上图纸,希望它容易。。。
Attri测试。图纸 更新了邮政编码#8以满足您的条件
HTH公司
页:
[1]
2