I want to set the value of a field in an attribute equal to value of another attribute in the same b

I want to create a title block where one attribute value is automatically duplicated in another attribute.

For example, the user would set the sheet name "SHEET" (for example "230a").
The plotfile name elsewhere in the title block would then be automatically updated using this number:
    "plotfile: SHEET-DWGFILE.plt"
(For example "plotfile: 230a-673p v02.plt" (where "673p v02.dwg" is the name of the dwgfile).

The dwgfile name part I can set using a field,
but I can't figure out how to use a field to duplicate the value of another attribute in the same block.

I have several attributes like this in a number of titleblocks.

I guess I could use a lisp to update the other attributes according to the value of the first attribute,
but I would like this to be  transparent to my users so that when they change one attribute,
the others update automatically.
Maybe a reactor?

Comments

  • Hi Yaacov,

    It is possible to get a field to reference another field or to reference itself. To reference a field defined within the attribute of a block you need to use the following bit of LISP to grab its entity name

    [code](setq ent (car (nentsel)))[/code]

    This creates a lisp variable called ent containing the entity name of the selected attribute.

    Then in another attribute definition of the same block create another field using the following steps:
    • Right click and select "Insert Field"
    •  Select the Object property option.
    • Pick on the button to select an object on your drawing.
    • On the command line type !ent and press enter.
    • Back in the fields dialogue select Contents from the property list for the object.
    • pick the OK button to insert.
    Attach a screen grab from a drawing, and the drawing file to illustrate. You will see that it works, but it doesn't recognise the Mtext codes, instead it looks to treat the contents as just text. Suggest that you raise a support request if this is something you need and have been able to use in this way elsewhere.

    You can use the above method to get a piece of MTEXT or similar to reference itself in the field. You can see this in the example I've attached, which has some MTEXT that displays its X and y coordinates. To do this you would use entsel instead of nentsel in the LISP code e.g.
    [code](setq ent (car (entsel)))[/code]

    Other alternatives you could explore:
    • Use filename property without extension.
    • Use CTAB system variable if you want the current layout name.
    • Populate information in the drawing properties, then reference that information from a field.
    • Use some Lisp to set a variable such as USERS1 that you then reference from a field.
    • Use sheet sets to create a custom field for this purpose.

    Regards,

    Jason Bourhill

    CAD Concepts


    TestFields.zip

    imageDrawingProperties.png
    imageSelfRefFields.png
  • Wow! thanks!
    It works perfectly.
    The rest I've more or less figured out, but the self-reference had me stumped.
    Thanks again!
This discussion has been closed.