Interesting suggestion BIGAL,
I think that this modification may be more effective:
- ; Increment Attribute with grread - Grrr(defun C:test ( / e enx n tag b bnm SS mv i o grr Stop m ) (and (setq e (car (nentselp "\nPick numerical attribute from block: "))) (setq enx (entget e)) (member '(0 . "ATTRIB") enx) (numberp (setq n (read (cdr (assoc 1 enx))))) (setq tag (cdr (assoc 2 enx))) (setq b (cdr (assoc 330 enx))) (setq bnm (vla-get-EffectiveName (vlax-ename->vla-object b))) (setq SS (ssget "X" (list '(0 . "INSERT") (cons 2 (strcat "`*U*," bnm)) '(66 . 1)))) (setq mv (progn (initget "Below Above") (eval (cadr (assoc (cond ((getkword "\nModify values [below/Above] : ")) ("Above")) '(("Below" ))))) ) ) (princ "\nPress [+/-] to increment/decrement the values: ") (while (not Stop) (setq grr (grread T)) (cond ( (or (eq grr '(2 13)) (member (car grr) '(25 3))) (setq Stop T) ) ( (and (= (car grr) 2) (setq m (eval (cadr (assoc (cadr grr) '((43 1+) (45 1-))))))) (repeat (setq i (sslength SS)) (cond ( (not (eq bnm (vla-get-EffectiveName (setq o (vlax-ename->vla-object (ssname SS (setq i (1- i)))))))) ) ( (vl-some (function (lambda (x / v) (and (eq tag (vla-get-TagString x)) (numberp (setq v (read (vla-get-TextString x)))) (mv v n) ; _$ (>= 3 2) -> T (setq v (m v)) (progn (vla-put-TextString x (vl-prin1-to-string v)) T) ); and ); lambda (x) ); function (vlax-invoke o 'GetAttributes) ); mapcar ) ); cond ); repeat ) ); cond ); while ); and (princ)); defun
But I'd advise first to do some tests with the above code (because for example if you increment too much - up to the value's limit the values would stack).
For instance decrement too much from number 3 the values above (5 6 7 8...)
by pressing "-" they'll all become (3 3 3 3...) therefore no fix for this. |