辩论和子程序
现在我有了这个代码,但它不起作用。(defun _Modification (/ obj atts x lt Nombloc)
(initget 1 "P T D V")
(setq Mod (getkword "\n Quel élément voulez vous modifier? : "))
(if (= Mod "P")
(progn
(setq TProjet (strcase (getstring T "\n Quel est le nouveau nom du projet? ")))
(setq TagPro "PROJET")
(_getall->Layout (if (= Tag (vla-get-tagstring x))
(vla-put-textstring x Text)
)
)
)
)
(defun _getall->Layout (Tag Text / adoc nombloc)
(setq Nombloc '("LU CARTOUCHE" "Cartouche Aliance"
"LC CARTOUCHE CHUM" "LC CARTOUCHE CHUM 2"
"LC CARTOUCHE" "LU CARTOUCHE PANNEAU"
"CARTOUCHE LU" "LC CARTOUCHE 2"
)
)
(setq adoc (vla-get-activedocument (vlax-get-acad-object)))
(vlax-for lt (vla-get-layouts adoc)
(vlax-for obj (vla-get-block lt)
(if (and (= "AcDbBlockReference" (vla-get-objectname obj))
(member (vla-get-effectivename obj) Nombloc)
(= :vlax-true (vla-get-hasattributes obj))
)
(progn
(setq atts (vlax-invoke obj 'getattributes))
(foreach x atts
(if (= Tag (vla-get-tagstring x))
(vla-put-textstring x Text)
)
)
)
)
)
)
)
是我出错了
; error: bad argument type: VLA-OBJECT nil
我不明白为什么。。因为obj是vla对象。 VLA-OBJECT-布局不将VLA-OBJECT-块作为子对象。。。
尝试将最后一段改为:
(vlax-for obj (vla-get-blocks adoc)
(if (and (= "AcDbBlockReference" (vla-get-objectname obj))
(member (vla-get-effectivename obj) Nombloc)
(= :vlax-true (vla-get-hasattributes obj))
)
(progn
(setq atts (vlax-invoke obj 'getattributes))
(foreach x atts
(if (= Tag (vla-get-tagstring x))
(vla-put-textstring x Text)
)
)
)
)
)
HTH
[编辑]:刚刚选中-你可能想到了VLA-OBJECT-ActiveLayout,所以…:
(vlax-for lt (vla-get-activelayout adoc)
(vlax-for obj (vla-get-block lt)
(if (and (= "AcDbBlockReference" (vla-get-objectname obj))
(member (vla-get-effectivename obj) Nombloc)
(= :vlax-true (vla-get-hasattributes obj))
)
(progn
(setq atts (vlax-invoke obj 'getattributes))
(foreach x atts
(if (= Tag (vla-get-tagstring x))
(vla-put-textstring x Text)
)
)
)
)
)
)
页:
[1]