Block Attribute - Concatenated value
in 2D Drafting
Dear All,
Is there any way to calculate automatically the value of a block attribute according the values of others attributes. For example :
Attribute 1 value = DN100
Attribute 2 value = 30m3/h
Attribute 3 value = DN100 - 30m3/h
Attribute3 value results from Attrubute 1 et 2 values.
It will be very apprecited if someone could provide an example.
Thanks for your help. BR
Is there any way to calculate automatically the value of a block attribute according the values of others attributes. For example :
Attribute 1 value = DN100
Attribute 2 value = 30m3/h
Attribute 3 value = DN100 - 30m3/h
Attribute3 value results from Attrubute 1 et 2 values.
It will be very apprecited if someone could provide an example.
Thanks for your help. BR
0
Comments
-
YES, you will need to edit to suit your block.
; add 2 attributes and put the value as a field into the 3rd attribute.
; BY AlanH
(defun c:test ( / obj lst x )
(setq oldatt (getvar 'attdia))
(setvar 'attdia 0)
(command "-insert" "yourblockname" (getpoint "\npick point") 1 1 0 (getstring "\nEnter Att1 ") (getstring "\nEnter Att2 ") (getstring "\nEnter Att3 ") "-")
(setq obj (vlax-ename->vla-object (entlast)))
(setq lst '())
(foreach att (vlax-invoke obj 'getattributes)
(princ "\n")
(setq lst (cons (strcat "%<\\AcObjProp Object(%<\\_ObjId "
(vlax-invoke-method (vla-get-Utility (vla-get-activedocument (vlax-get-acad-object))) 'GetObjectIdString att :vlax-false)
">%).Textstring>%"
) lst ))
)
(setq str nil)
(setq x (length lst))
(setq str (strcat "%<\\AcExpr "
(nth (setq x (- x 1)) lst) " + "
(nth (setq x (- x 1)) lst) " + "
(nth (setq x (- x 1)) lst) ">%"
)
)
(setq x 1 y 4)
(foreach att (vlax-invoke obj 'getattributes)
(if (= x y)
(Vla-put-textstring att str)
)
(setq x (+ x 1))
)
(setvar 'attdia oldatt)
(princ)
)
(c:test)
0