本帖最后由 llsheng_73 于 2025-1-23 10:40 编辑
先要知道所关心的属性的TAG,然后才能在众多属性中找到它,才可能进行后边的处理
- (defun getatts(blk);|获取块参照图元(对象)的属性参照,返回值((属性标记 属性值 属性对象)...)以便进一步修改指定标记的属性值|;
- (if(equal(VL-CATCH-ALL-APPLY(function vlax-get-property)(list(setq blk(if(=(type blk)'ename)(vlax-ename->vla-object blk)blk))'HasAttributes)):vlax-true)
- (mapcar(function(lambda(x)(list(strcase(vlax-get-property x'TagString))(vlax-get-property x'TextString)x)))
- (vlax-safearray->list(vlax-variant-value(vlax-invoke-method blk'GetAttributes))))))
$ (setq e(CAR(ENTSEL)))
<图元名: 7e498b08>
_$ (GETATTS e)
(("HEIGHT" "220.25" #<VLA-OBJECT IAcadAttributeReference2 2915b2c4>))
_$ (setq a(assoc "HEIGHT"(GETATTS e)))
("HEIGHT" "220.25" #<VLA-OBJECT IAcadAttributeReference2 2915b2c4>)
_$ (vlax-put-property(caddr a)'textstring(strcat(cadr a)"A"))
nil
_$ (GETATTS e)
(("HEIGHT" "220.25A" #<VLA-OBJECT IAcadAttributeReference2 2915b2c4>))
_$
自己想法进行批量处理就行了
|