Block attribute with prefix and suffix

Dear All,

How can I show a block with an attribute value inculding a prefix and suffix.

Do I have to make the attribute invisible and insert a field made like :

"Prefix" & AttributeValue & "Suffix"

If Yes does anyone can tell me what will be the correct syntax ?

Are the fields automatically updated when modifying the value of the attribute.

TY

Comments

  • Hello.

    I couldn't find a reliable way to reference an attribute inside another one, using a field.
    Depending on the design intent, maybe, a visibility parameter could be useful here.

    Something that works is to use a field and a text using opposing alignments, meaning left and right.
    Opposing alignments are required to avoid overlapping.
    This approach would be useful for a text (field) and a suffix or prefix (not both).

    Concerning updating fields, using the UPDATEFIELD command is mandatory to update the value displayed by a field.

  • If the number of characters is fixed in the attribute like say ABC 123 DEF then you could add the ABC & DEF as text in the block. using lisp yes can update an attribute say only inputting "123" to a lisp getstring so add prefix and suffix. The lisp would be very short. The issue is how many different prefixes and suffix values do you use,. the same in a field you can have text, so you would edit a text value somewhere and it would show in the attribute.

    Using (vla-fieldcode obj) you can get the field coding in the attribute string so using strcat make a new textstring and use (vlax-put obj 'textstring newstring.) which can have a prefix and suffix.