To Whom Do You Attribute That Information? (Learning Curve AutoCAD Tutorial)1 Mar, 2007 By: Bill Fane
Use attributes to attach a quality or a value to a block insertion.
Have you ever noticed that whenever writers become desperate for a clever opening for an article they revert to the old trick of starting with the dictionary definition? Well, it works for me. This month's topic is block attributes, so let's start with the dictionary definition.
According to my Shorter Oxford English Dictionary, the word "attribute" means "to ascribe to as belonging or proper." For example, a literary work is attributed to its author. Wait a minute, that doesn't seem to match attributes in AutoCAD! Okay, let's look further. This time we come up with "a quality ascribed to a person or thing." English is a wonderful language. Both definitions use the word "ascribe," and yet they mean different things. In the first case, it is pronounced attribute and is a verb, whereas the second case is the substantive one and is pronounced attribute. This definition is the one we want.
Dress Up that Block
In AutoCAD, attributes allow us to attach a quality or a value to a block insertion. In the simplest sense, they are fill-in-the-blank text objects that we can include within a block definition. AutoCAD asks for specific values to be attached each time we insert the block into a drawing.
It can save a great deal of time and can lead to better standardization of our drawings because the attribute definitions include all the text formatting, including the location.
Blocks with attributes have a number of different uses, but it's quite safe to say that every user can probably make good use of them. I'll explain this later.
Creating a block with attributes is a simple three-step process. First, we create the objects to be included within the block definition. They can consist of the usual cast of characters, such as lines, circles, arcs and so on, plus one or more attribute definitions.
Next, we create the block definition, which uses the desired normal objects along with the attribute definition or definitions. Finally, we insert the block. This step follows the usual routine, except that at the end it asks us to supply a specific value for each attribute.
Let's try a quick example to see what I mean. Maintaining the long-standing tradition for technical writers, I'll begin with a trivial example that bears little connection to reality.
Suppose the boss comes in one day and asks you to draw an organization chart for the company. There are several ways you could do this, ranging from hardest to easiest:
- You could begin by drawing a whole bunch of simple rectangles, one per person, and then going back to use the Text command to fill in each name.
- You could draw a single rectangle, make a block of it, Insert it repeatedly and then use the Text command to fill in each name.
- The easiest method is to use attributes, so that each time you insert the block AutoCAD asks for the person's name. It automatically appears in the correct location within each rectangle, properly centered and justified.
Okay, let's go. Begin by using the Rectangle command to draw one that is two units wide and one unit high. Next, draw a line diagonally across it, being sure to snap to the intersection of the two opposite corners of the rectangle.
Next, you need to define an attribute. Start the AttDef (ATTribute DEFinition) command by selecting Draw / Block / Attribute Definition from the menu, which brings up the Attribute Definition dialog box.
The AttDef dialog box is used to create attribute definitions.
Fill it in, starting from the upper right-hand corner.
The most significant item here is the Tag box. Every attribute must have an identifying tag or label. Tags are used if you decide to extract attribute values out to disk for use by other programs (see an old column of mine, "Extract Those Attributes," for more information).
Tags don't have to be unique within a drawing, but it's usually a good idea. Tags can contain any combination of letters, numbers and punctuation marks but they can't contain spaces. AutoCAD converts all letters to uppercase when you finish the definition.
As its name implies, the contents of the Prompt box appears as a prompt to the user when the block is inserted. AutoCAD automatically enters a colon (:) at the end of it, so that Please enter a name appears as Please enter a name:. This box is optional. If you don't supply a prompt, then AutoCAD displays the tag instead during block insertion.
The Value box is also optional. If you enter a value, then it's the default during block insertion. If you just press Enter at block insertion time instead of supplying a specific value, then the default value is used. It can be blank, but a blank entry can create a null attribute, which can cause problems later.
Moving down to the lower-right corner of the Attribute Definition dialog box, we come to the Text Options region. We can enter suitable values for the height and rotation angle, and we can select any of the normal text justification modes from the drop-down list. For our example, select Middle Center.
The Text Style drop-down list lets you choose from any text style that is currently defined in the drawing. You can thus create attribute definitions using any combination of font plus effects such as backwards, upside-down and slanted.
Let's leave the other dialog box options alone for now and just click on OK. The dialog box closes, and you are asked for a location for the attribute. Snap to the mid-point of the diagonal line.
The rectangle and attribute objects are ready to be included in a block definition.
Now, use the Block command (Draw / Block / Make) to create a block definition. Following the usual block definition procedure, you need to give it a name such as Name_Tag and specify an insertion point. The mid-point of the upper side of the rectangle is a logical choice.
Block that Attribute
Now just select the rectangle and the attribute as the components of the block. You can ignore the diagonal line.
That's it! Now insert the block several times. Each time you do, you are prompted to Please enter a name:. Supply a suitable name each time and, as if by magic, it appears each time with the correct justification, text style, size and so on. The sample organization chart below took less than five minutes to create, including the time required to create the attribute and the block definitions. I did not use the Text command at all.
This organization chart took less than five minutes to create, using blocks with attributes.
Now let's back up and cover some of the things we skipped over earlier.
Filling In The Blanks
Attribute modes are turned on or off by selecting the appropriate box in the Mode region in the upper-left corner of the dialog box when you are defining the attribute:
- Invisible attributes are not displayed or plotted, but their values are available for later extraction and manipulation. This ability can be handy if you want to record background information that you don't want to display in the drawing. The Attdisp command can be used to turn invisible information on and off.
- The Constant mode doesn't prompt for a value, but it always inserts a predefined constant value. This value cannot be changed later, so at first glance it doesn't seem much different from a simple line of text included in the block. The difference is that it's an attribute value that can be extracted for later analysis and so could be used, for example, to give a count of all door blocks in a building, or all 20hp motors in a factory.
- The Verify mode lets you type in a value, then asks if it's OK or not. If not, you can correct it. This idea sounds good, but the extra keystrokes can be a little frustrating.
- The Preset mode doesn't ask for a value when the block is inserted but instead automatically inserts the default value. This mode is often used when running scripts or programs to insert the blocks automatically. Users can come back later and edit the values.
Blocks can contain more than one attribute definition. A feature in the Attribute Definition dialog box can simplify the creation and alignment of multiple definitions.
If you check the Align below previous attribute definition box, then AttDef doesn't ask for the text insertion point when you click on OK but instead automatically spaces and aligns it below the previous definition. Now here's another trick: in AutoCAD you can always press the space bar to repeat the last command.
Putting these two facts together, you can easily create a neatly aligned set of attributes such as what you might find on an electric motor nameplate.
Here's yet another trick: a block definition doesn't have to contain any regular objects at all. It can consist simply of one or more attributes.
It's getting a little late, so I think I had better send this off to my editor. Be sure to come back next time when we get into some of the fun uses for attributes, how to edit their values and how to edit their definitions.
And Now for Something Completely Different . . .
The wattage and voltage markings on a light bulb often fade with age and can be difficult to read. If you breathe on them, the condensation from your breath often will make them briefly readable.