| 啊,我现在明白了,没有仔细阅读任务是什么=误解了编码。
 
 FWIW,这里是另一种方法(从您那里复制了用户提示):
 
 
 (defun C:test ( / bnm tag n SS fnd new i o L )  (setq   bnm "VIFCD_001"   tag "DESC" )  (and   (setq n (_AttdefPosition bnm tag))   (setq SS (ssget "_X" (list '(0 . "INSERT") '(66 . 1) (cons 2 (strcat "`**," bnm)))))   (setq fnd (strcase (getstring t "\nSpecify attribute value to find: ")))   (setq new (getstring t (strcat "\nSpecify new value for "" tag "" attribute: ")))   (repeat (setq i (sslength SS))     (and        (eq bnm (vla-get-EffectiveName (setq o (vlax-ename->vla-object (ssname SS (setq i (1- i)))))))       (setq L (vlax-invoke o 'GetAttributes))       (vl-some (function (lambda (x) (wcmatch (strcase (vla-get-TextString x)) fnd))) L)       (vla-put-TextString (nth n L) new)     )   ) ) (princ)); defun C:test(defun _AttdefPosition ( bnm tgnm / e i enx f ) (and   (setq e (tblobjname "BLOCK" bnm))   (setq e (cdr (assoc -2 (entget e))))   (setq i -1)   (while (and e (not f))     (setq enx (entget e)) (setq e (entnext e))     (and (member '(0 . "ATTDEF") enx) (setq i (1+ i)))     (setq f (member (cons 2 tgnm) enx))     (and (member '(0 . "SEQEND") enx) (setq e nil))   ) ) (if f i)); defun _AttdefPosition
 
我看到你在处理属性时试图限制最多一次迭代,很明显你喜欢想出这么聪明的方法。 |