@jeroendewind wrote:
Hi,
Well, I see a lot of solutions with FIELDS. But the problem is that these things are working like a formula and can subtract and add values of given numbers.
I just want to do come calculation with an old attribute definition to create a new one, keeping my block the same. Not A=B+C, but A(new)=A+200.
Otherwise I have to change my block, add field or more attributes, fill these in, in order to get my new value. More work than just change it manually.
@hmsilva wrote:
Hi jeroendewind,
It should be possible to do what you need.
If you do a search in 'Search This Board' for 'add attrubutes' should appear some thread with some similar request.
If not, block name and TAG, it's a dynamic block?
...
Change to your BLOCKNAME and correct TAG...
Untested
(vl-load-com)
(defun c:demo (/ a dz i newval val obj oldval ss val)
(cond ((and (setq ss (ssget "_:L" '((0 . "INSERT") (2 . "BLOCKNAME") (66 . 1))));<- change to correct
(setq val (getreal "\nEnter value to increase/decrease: "))
)
(setq dz (getvar 'dimzin))
(setvar 'dimzin 0)
(repeat (setq i (sslength ss))
(setq obj (vlax-ename->vla-object (ssname ss (setq i (1- i)))))
(mapcar '(lambda (a)
(if (= (vla-get-TagString a) "TAG");<- change to correct
(progn
(setq oldval (atof (vla-get-TextString a)))
(setq newval (+ oldval val))
(vla-put-TextString
a
(strcat (if (> newval 0.0)
"+"
""
)
(rtos newval 2 3)
)
)
)
)
)
(vlax-invoke obj "GetAttributes")
)
)
(setvar 'dimzin dz)
)
)
(princ)
)
Hope this helps,
Henrique