由于ssget不允许选择属性等子实体,因此您需要使用nentsel选择(单个对象),或允许选择属性块(插入),然后迭代块持有的属性,例如:
- (defun c:strow ( / i o s x )
- (if (and (/= "" (setq x (getstring t "\nEnter text to overwrite: ")))
- (setq s (ssget "_:L" '((-4 . "<OR") (0 . "TEXT,MTEXT") (-4 . "<AND") (0 . "INSERT") (66 . 1) (-4 . "AND>") (-4 . "OR>"))))
- )
- (repeat (setq i (sslength s))
- (setq o (vlax-ename->vla-object (ssname s (setq i (1- i)))))
- (if (= "AcDbBlockReference" (vla-get-objectname o))
- (foreach a (vlax-invoke o 'getattributes) (vla-put-textstring a x))
- (vla-put-textstring o x)
- )
- )
- )
- (princ)
- )
- (vl-load-com) (princ)
|