Hello!
I have made a lisp routine that does the following:
1)adds a block reference to the model space;
2)changes the value (text string) of an attribute;
3)gets the real width (through bounding box) of the attribute;
4)changes a dynamic block property so that the width of the block reference fits the new text.
It works beautifully, when the attribute is a single-line one. But sadly my colleagues requested I make it a multi-line attribute, so they could use subscripts and superscripts in it.
The problem seems to be that Bounding box of a multi-line attribute is always as if it had it's default text string.
Maybe there is another way to get the width of a multi-line attribute?
Code below:
(defun c:ko
-addmyblock
() (setq blkname
"MyBlock") ;name of my block (setq attrname
"NR") ;block attribute name (TagString) that I want to change (setq newattrvalue
"MyNewValue") ;the new value I want to give to the attribute (setq propname
"Width") ;block property name that is supposed to change depending on width of the attribute (setq pt
(getpoint "Insertion point for block")) ;get insertion point for the block
;;get the relevant attribute as vla-object
);vl-member-if
);car
);setq
;;get the relevant property as vla-object
);vl-member-if
);car
);setq
(vla-put-value propobj (+ 2.0 attrwidth)) ;change it's value
);defun
The block is a really simple one with one attribute called "NR", and one custom property called "Width".
EDIT (John): Fixed code tag.