i ran into a couple of snags with will's routine and was wondering if anyone could help me improve it. first i would like it to prompt the user for the attribute name so it would work universally instead of on a single block. secondly i would like to modify it so the user selects the attributes in the order they want and it numbers them all at once not with each pick. this last one is a request from my boss. any takers???
(defun c:attnumb (/ ref tobj tstr ttag sel)
;
(defun *get_atts* (obj)
(vlax-safearray->list
(vlax-variant-value
(vla-getattributes
(if (eq (type obj) 'ENAME)
(vlax-ename->vla-object obj)
obj
)
)
)
)
)
;
(defun *find* (attlist nlst)
(vl-remove-if-not
'(lambda (x)
(vl-remove-if-not
'(lambda (y)
(eq (vla-get-tagstring x) y)
)
nlst
)
)
attlist
)
)
;
(defun *put* (obj str lst)
(mapcar '(lambda (x)
(vl-catch-all-apply
'vla-put-textstring
(list (rt:remove obj x) str)
)
)
lst
)
)
;
(defun rt:remove (obj str)
(car
(vl-remove-if-not
'(lambda (x)
(eq (vla-get-tagstring x) str)
)
(*get_atts* obj)
)
)
)
;
(if (and (setq ref (car (entsel "\nSelect reference block: ")))
(eq "INSERT" (cdr (assoc 0 (entget ref))))
)
(progn
(setq tobj (car (*find* (*get_atts* ref) '("NUMB")))
tstr (vla-get-textstring tobj)
ttag (vla-get-tagstring tobj)
)
(while tstr
(setvar "ErrNo" 0)
(if
(not
(setq sel (car (entsel "\nSelect attribute to update: ")))
)
(if (/= 52 (getvar "ErrNo"))
(princ "\nNo object selected, please try again: ")
(progn
(princ "\nRight click detected - Terminate program. ")
(setq tstr nil)
)
)
(cond ((not (setq tstr (itoa (1+ (atoi tstr))))))
((eq ttag "NUMB") (*put* sel tstr '("NUMB")))
)
)
)
)
(*error* (princ "\nNothing selected. *INVALID*"))
)
)