Categories

AutoCAD 2015 and AutoCAD LT 2015 BibleAutoCAD 2015 and AutoCAD LT 2015 Bible

The most comprehensive AutoCAD book around!

Tutorial: Use fields to automatically label dynamic blocks

You can use fields (AutoCAD 2005 and later) to create automatic labels that provide information about objects.

I’ve covered aspects of this topic before. In “Tutorial: Display the area of an enclosed figure,” I show how to use fields to create a label that displays an area.

In “Tutorial: Create attributes,” I mention that you can use fields in attributes.

In this tutorial, I’ll expand on the idea of using fields in attributes, which are labels attached to blocks. This example shows the use of fields that label geometric parameters of dynamic blocks.

  1. Open the Block Editor. (Tools> Block Editor or Blocks & References tab> Block panel> Block Editor.
  2. Create the objects for the block.
  3. Create the parameter and action you want to label. For example, for a desk, I created a Linear Parameter and a Stretch Action. I renamed the Linear parameter’s label to Length in the Properties palette. If you need further instructions, you can download my complete dynamic blocks tutorial from my “Dynamic blocks tutorial” page.

  1. Start the ATTDEF command (Draw> Block> Define Attributes or Blocks & Reference tab> Atrtributes panel> Define Attributes).
  2. In the Attribute Definition dialog box, type in a tag name, such as Length. For the Deafult entry, type the text that you want to appear before the value, such as Length: . (Add a space after the colon.) Check the Constant check box so that you won’t get a prompt. The whole point is to make the label automatic. Set the Text Settings section as desired.
  3. Then right-click in the Default text box or click the Insert Field button at the right to open the Field dialog box. From the Field Category drop-down list, choose Objects. Then choose BlockPlaceholder as the field name. The Block reference property should be the name of the parameter you used. This is Length in our example. Set the format as desired, and click OK.

Note: The Length property is on the list only because I created a parameter named Length. The other properties are available for all blocks.

  1. You’re now back in the Attribute Definition dialog box, which should look like the figure below. Click OK. Place the label where you want it.

  1. Save the dynamic block by clicking the Save button in the Block Editor. Close the Block Editor.
  2. Back in your drawing, insert the block (Insert> Block or Blocks & References tab> Block panel> Insert). Before you specify the insertion point, you’ll see the following for the label.

After you insert the block, you’ll see the value of the field.

  1. After you modify the dynamic block, you’ll need to update the field. In this example, changing the length makes the desk longer. Enter updatefield on the command line to update the field.

Tested in AutoCAD 2009.

13 comments to Tutorial: Use fields to automatically label dynamic blocks

  • Peter

    If I make the field constant I get ################.
    If it is NOT constant it works fine.
    I’ve looked through all the other sites I can find but have not found a solution to this.
    Can you help?

  • Michael

    I have same problem as Peter. Using AutoCAD MEP 2013.

  • Michael

    As a work around I used a dimension that stretches with the dynamic block, then turned off all the leader lines.

  • Ellen

    That’s a great idea!

  • Jason

    Great post. Do you know of a way to quickly label a block? Say, perhaps, a leader which allows you to click on the block and automatically attaches the block name on the mText?

  • Ellen

    I suppose you could write a script or AutoLISP file; otherwise, I’d say that attributes would be the most automated solution.

  • Nick

    Does anyone know how to make a field within a leader? I’m looking to make dynamic labels that automatically update in other sheets.

  • James Probert

    Create a custom property in the file/drawing properties/ dialogue box – use the add option to create your filed. Then when you create the leader, right click in the text area, select insert field and choose from the ‘document’ listing – your custom properties will be shown there.

  • James Probert

    the issue with the original post seems to be solved by using PRESET in the attdef sequence rather than CONSTANT

  • Balaji

    Thanks Ellen, for explaining the steps. Very useful.

    Thanks James,
    Your suggestion made the original post work in AutoCAD 2013.

  • Mark

    No matter what I try, when I stretch the block, the number in the Length attribute stays the same. I have to enter the regen command to see the text update. I even have regenauto set to “On”.

  • David

    Great website! I’ve lost count of how many times you’ve solved my AutoCAD problems.

    I’ve created a dynamic block pretty much identical to your desk block, but for closet rods (or shelves or drawer fronts). After I draw the elevations of a closet complete with multiple instances of the closet rod dynamic block, is there a way AutoCAD can calculate total linear feet of all closet rod (i.e. can AutoCAD calculate the total length of all closet rod dynamic blocks used in one drawing)?

  • Celeste

    The regen command also works for me as a way to update the field – I like it because I don’t have to select the block the way I do with the updatefield command.

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>