Chapter 17
IN THIS CHAPTER
Introducing blocks
Creating block definitions with Block
Inserting blocks with Insert
Adding attributes to blocks with ATTdef
Removing unwanted block definitions with PUrge
In Chapter 11, you can see how to copy objects within a drawing, or even to another drawing. That’s one way to use AutoCAD to improve drafting efficiency. You can make a copy of a DWG file and then modify it to create a similar drawing, which can be an even better productivity booster as long as you’re in the habit of making similar drawings. But those are all baby steps compared with the techniques I cover in this chapter and in Chapter 18: treating parts of drawings as modules that can be reused and updated. AutoCAD calls these modules blocks.
This block treatment applies also to entire drawings, drawings saved in web format (Design Web Format, or DWF), Autodesk Inventor 3D models, PDFs, MicroStation DGN files, and raster images.
In this chapter, I present the ABCs of blocks, including the basic creation of blocks and their insertion into drawings, adding attributes (data), and getting rid of block definitions you no longer need or want. In Chapter 18, I show you how to make even more of existing drawing data, including dynamic blocks, associative array objects, and several flavors of external reference files (including PDFs and MicroStation DGN files) and raster images.
A block is a collection of objects grouped to form a single object, like the lines that make up a chair. You can insert this collection more than once in the same drawing, and when you do, all instances of the block remain identical — that is, the drawing has lots of identical chairs.
By redefining the block definition, you can automatically change all instances of the block’s insertion at one time. You might do this, for instance, if your boss decides to save money by changing all armchairs to armless chairs. Although a block lives in a specific drawing, you can transfer copies of it to other drawings. Draw the chair once in one drawing, and you can use it in any other drawing.
And you can add fill-in-the-blank text fields, or attributes, to blocks. These attributes might be information about the chair, such as its price, where it was purchased, and its current owner. You can create single-line or multiline attributes; in addition to having more than one line, multiline attributes have many of the formatting options of multiline text, including fields. And blocks both with and without attributes can be defined as annotatively scaled objects to boot. See Chapter 13 for a rundown on annotative objects.
To use a block in a drawing, you need two elements: a block definition and one or more block insertions. AutoCAD doesn’t always make clear the distinction between these two items, but you need to understand the difference to avoid terminal confusion about blocks. Maybe this syndrome should be called blockheadedness?
A block definition lives in an invisible area of the drawing file: the block table. It’s one of those sets of named symbols that I describe in Chapter 9. The block table is a book of graphical recipes for making different kinds of blocks. Each block definition is a recipe for making one kind of block. When you insert a block, as described in the later section “Inserting Blocks,” AutoCAD creates a special object: a block insertion. The block reference points to the recipe and tells AutoCAD, “Hey, draw me according to the instructions in this recipe.”
Although a block may look like a collection of stored objects that is given a name, it’s a graphical recipe (the block definition) — plus, one or more pointers to that recipe (one or more block references). Every time you insert a particular block, you create another pointer to the same recipe.
You benefit from using blocks because you can
If you need to group objects only so that you can more easily select them for copying or moving, for example, use the AutoCAD Group feature (described more fully in Chapter 10). Type Group and press Enter, or simply click the Group button in the Groups panel on the Home tab. Then select some objects and you’re done. When you’re editing drawings that contain groups, press Ctrl+Shift+A to toggle “group-ness” on or off. If you’ve toggled group-ness on, picking any object in a group selects all objects in the group. If you’ve toggled it off, picking an object selects only that object, even if it happens to be a member of a group. For more information, refer to Chapter 10 or visit the online Help index.
Blocks — along with external references, DWF and PDF underlays, raster images, and DGN files — enable you to reuse your work and the work of others, giving you the potential to save tremendous amounts of time or to cause tremendous problems if you change a file that other people’s drawings depend on. Use these features when you can to save time, but do so in an organized and careful way so as to avoid problems.
To create a block definition from objects in the current drawing, use the Block Definition dialog box. The other way to create a block definition is to insert another drawing file into the current drawing as a block, which I explain in the later section “Inserting Blocks.” The following steps show you how to create a block definition by using the Block Definition dialog box:
On either the Home or Insert tab of the Ribbon, click the Create button on the Block panel, or type Block and press Enter.
The Block Definition dialog box appears, as shown in Figure 17-1.
Pay attention to layers when you create the objects that make up a block. As a rule, block geometry created on most layers retains the color, linetype, lineweight, transparency, and plot style properties of those layers. The exception to the rule is object geometry created on Layer 0 (zero). If you create a block by using geometry drawn on Layer 0, the block takes on the properties of any layer into which you insert it.
Type the block definition’s name in the Name text box.
If you type the name of an existing block definition, AutoCAD warns you when you click OK at the end of the process. This isn’t always a bad thing because AutoCAD asks whether you want to replace that block definition with the new objects you select. This process is known as block redefinition. For example, if you have a drawing with a large number of block insertions such as the bathtubs in a 1,000-room hotel, you can use a simplified block representation during the design process and redefine it to a more complex definition just before final plot time.
To see a list of the names of all current blocks in the drawing, open the Name drop-down list.
Specify the base point (also known as the insertion point) of the block, using either of the following methods:
The base point is the point on the block by which you insert it later, as I describe in the next section.
Use an obvious and consistent point for the base point on the group of objects, such as the lower-left corner or center, so that you know what to expect when you insert the block. If you do not define a base point, AutoCAD uses 0,0,0; when you later insert the block, it may appear in an unexpected location.
Click the Select Objects button and then select objects to become part of the block.
AutoCAD uses the selected objects to create a block definition and displays an icon showing those objects next to the block name. Figure 17-2 shows the base point and a group of selected objects during the process of creating a new block definition.
The components of a block definition can include other block insertions and so on and so on, as many levels deep as you need. If you try to create a circular reference, however, AutoCAD will object. For example, block A can contain block B, which can contain block C as long as block C doesn’t also contain block A.
In the Objects area, select a radio button to tell AutoCAD what to do with the objects that are used to define the block: Retain them in place, convert them into a block instance, or delete them.
The default choice, Convert to Block, is usually the best. See Step 9 for a description of what happens with each choice.
Specify the insert units to which the block will be scaled in the Block Unit drop-down list.
As you learn later in this chapter, you can copy an existing block from another drawing and insert it into the current one. When you do so, the units you specify here and the units of the drawing you’re inserting into control the default insertion scale factor. The list contains 17 different units, from angstroms to parsecs, but doesn’t include fathoms or furlongs, unfortunately.
Three additional features in the Block Definition dialog box give you even more control over what happens to blocks as they’re inserted:
Enter a description of the block in the Description text area.
You don’t have to enter a description to create a block, but it isn’t a bad idea. Think like a database manager and enter a useful description that identifies the block to yourself and others, such as “Sink, Kitchen, 2D.” Note that this book includes just about everything, including the kitchen sink.
Make sure that the Open in Block Editor check box is deselected.
You don’t need to use the Edit Block Definition dialog box unless you add dynamic features to the block. See Chapter 18 to find out more about dynamic blocks.
Click OK to complete the block definition process.
AutoCAD stores the block definition in the current drawing’s block table. This list describes the behavior of the radio buttons you choose from in Step 5:
AutoCAD provides a number of ways to insert a block or a whole drawing file, but the most commonly used and most flexible method is using the Insert button on the Ribbon menu. To insert a block, follow these steps:
Set an appropriate layer current, as described in Chapter 9.
Insert each block on a layer that has something to do with the block’s geometry or purpose:
If any of the block definition’s geometry was created on Layer 0 (zero), the geometry inherits the color, linetype, and other object properties of the layer on which you insert the block. It’s like chameleons changing color to match their surroundings or politicians changing their position to match the day’s opinion polls. Any block components on layers other than layer 0 retain their respective layer’s properties.
On the Home tab of the Ribbon, click the Insert button on the Block panel.
A slideout panel drops down, displaying a thumbnail view of all block definitions in the current drawing.
If you want to do something fancier, in older AutoCAD releases you click the More Options button at the bottom of the thumbnail preview slideout panel to produce the Insert dialog box, as shown in Figure 17-3, left. In AutoCAD 2020, click the Recent Blocks button of the preview panel to launch the Blocks tool palette, as shown in 17-3, right.
I won’t bore you with the minute details of every option, but here are a few to give you an idea.
Enter the block definition name (or external filename) by using one of these methods:
Use the Name drop-down list to select from a list of block definitions in the current drawing or click the appropriate preview image.
The Name drop-down list supports autocomplete. As you begin to type the desired block name, AutoCAD searches through the drawing’s list of block names and finishes filling in the name for you.
Click the Browse button to select an external DWG file and have AutoCAD create a block definition from it.
Browse to any existing drawing and then insert it into the current drawing to create a new block definition in the host drawing. Note that nothing is magical about the incoming drawing. Any existing drawing can be inserted into any other drawing. The new definition retains no connection to the source drawing.
Ah, but here’s the real magic of inserting an existing drawing to create a block definition. A great many manufacturers and suppliers have standard AutoCAD drawings of their products available, often online. Building a conveyor system and need a particular motor-gearbox unit? No need to draw it from scratch; just download it from the manufacturer’s website and plug it in.
You can use an external drawing to replace a block definition in the current drawing. If you click Browse and choose a file whose name matches the name of a block definition that’s already in the drawing, AutoCAD asks you to confirm the update and, if you agree, updates the block definition in the drawing with the current contents of the external file. In this process, block redefinition, AutoCAD automatically updates all block insertions that point to the block definition.
Earlier in the chapter, I mention the example of using a simplified representation of a bathtub during the design process and then replacing it with a detailed version later. Block redefinition by inserting an existing drawing is the fastest and easiest way to do this.
AutoCAD 2020 added one more bit of magic. Not only can you import an existing drawing, but you can also browse within it and just import the specific definition or definitions that you need. This feature can be accessed at the bottom of the drop-down panel from the Insert button of the Ribbon menu, or from the Other Drawing tab of the Blocks palette.
Enter the insertion point, scale, and rotation angle of the block.
You can either select the Specify On-Screen check box in each area to specify the parameters onscreen at the command prompt or type the values you want in the text boxes in the Insertion Point, Scale, and Rotation areas.
Select the Uniform Scale check box to constrain the X, Y, and Z scaling parameters to the same value (which is what you want in almost all cases).
After you insert a block, all the objects displayed in the block reference behave as a single object. When you select any object in the block reference, AutoCAD highlights all the objects in it.
AutoCAD gives you three more ways to insert a block:
The DesignCenter palette: Drag a block definition from the Blocks section of the DesignCenter palette and drop it into the current drawing window. Turn to Chapter 9 to find out how to use DesignCenter.
You can import Inventor part (IPT) and assembly (IAM) models directly into AutoCAD. Inventor is AutoCAD’s 3D parametric and associative sibling, intended primarily for mechanical design. Imported Inventor files come across as dumb 3D solids that lose their parametrics and associativity, but they can be modified and edited like any other AutoCAD 3D solid. I cover the 2D parametrics of AutoCAD in Chapter 19, and introduce you to 3D modeling in Chapters 21–23.
The Tool Palettes window: As is true of using the tool palette for hatching (as described in Chapter 15), you first must create and configure appropriate tools. The easiest method is right-clicking a drawing in DesignCenter and choosing Create Tool Palette. A new tabbed page is added to the Tool Palettes window, containing all block definitions from the drawing you right-clicked. Simply click and drag a tool to insert its corresponding block into a drawing.
Dragging blocks from a tool palette doesn’t give you the chance to specify a different insertion scale, nor can you use all the precision tools in AutoCAD to specify the insertion point precisely, so you may need to move the block into place after inserting it. You should first master the other block insertion methods described in this chapter, especially using the Insert dialog box and DesignCenter palette. Then if you find yourself inserting the same blocks frequently, consider creating a tool palette containing them. Check out the Add Content with DesignCenter topic in the AutoCAD online Help system for more information.
You may think of attributes as the good (or bad) qualities of your significant other, but attributes in AutoCAD are fill-in-the-blank text fields that you can add to blocks. When you create a block definition and then insert it several times in a drawing, all the ordinary geometry elements (lines, circles, and regular text strings, for example) in all instances are exactly identical. Attributes provide a little more flexibility in the form of text strings that can be different in each block reference.
Suppose that you frequently designate parts in drawings by labeling them with distinct numbers or letters enclosed in a circle. If you want to create a block for this symbol, you can’t simply draw the number or letter as regular text by using the mText (T) or TEXT (DT) commands. When you create a block definition with a regular text object (for example, the letter A), the text string is the same in every instance of the block (always the letter A). That’s not much help in distinguishing the parts.
Instead, you create an attribute definition, which acts as a placeholder for a text string that can vary every time you insert the block. You include the attribute definition when you create the block definition. Refer to the “Creating Block Definitions” section, earlier in this chapter. Then every time you insert the block, AutoCAD prompts you to fill in an attribute value for each attribute definition.
When the block attribute value was first introduced, and for a long time afterward, it was limited to a single line of variable text with a maximum of 255 characters. AutoCAD 2008 and later supports multiline attributes; in addition to offering more than one line, multiline attributes have many of the formatting options of multiline text. For more information on creating and inserting blocks with multiline attributes, look up Define Block Attributes in the online Help system.
You use the Attribute Definition dialog box to create attribute definitions. Clever, eh? The steps are similar to creating a text string except that you must supply a little more information. Create attribute definitions by following these steps:
To run the ATTdef command, click Define Attributes in the Block panel slideout on the Home tab.
The Attribute Definition dialog box appears, as shown in Figure 17-4.
You rarely need to use any of the first four Mode settings (Invisible, Constant, Verify, or Preset). Leave them deselected. If you’re curious about what the modes do, hover the mouse pointer over an item; if that doesn’t give you enough information, click the Help button in the dialog box to find out more.
Select or deselect the Lock Position check box.
If Lock Position is selected, the attributes can’t be relocated within the block reference and the whole thing is treated as a single object. Deselecting Lock Position allows attributes to be moved by dragging their grips, without moving the block reference as a whole.
Select or deselect the Multiple Lines check box.
Selecting Multiple Lines in the Mode area disables the Default text box and displays a button to open the Multiline Editor. By default, you don’t see the whole panoply of formatting options of the mText command’s In-Place Text Editor, but you can overscore or underscore text; and from a right-click menu, you can import text, assign a background mask, or choose from a number of other options. Setting the value of the system variable ATTIPE (Attribute In-Place Editor) to 1 enables all formatting options in the In-Place Text Editor. See the online Help system for more information.
In the Attribute area, type values for the tag (the unique identifier for the attribute), the user prompt, and the default value.
The name you type in the Tag text box can’t contain spaces. The Prompt and Default text boxes may contain spaces, though.
Attribute values can include fields that update automatically, such as date, filename, and system variable settings.
(Optional) Click the Insert Field button to the right of the Default text box to insert a field.
See Chapter 13 for more information on fields.
(Optional) If you select the Multiple Lines check box in Step 4, click the Multiline Editor button (it shows three periods) to enter the multiline default attribute value and add any formatting; then click OK.
The text you enter in this step is the default value stored in the attribute definition, and you can change it when you insert the block.
In the Text Settings area, specify the justification, text style, annotative property, text height, rotation, and boundary width (the last for multiline attributes only).
The text properties for attribute definitions are the same as those for text objects, as covered in Chapter 13.
Select the Specify On-Screen check box to choose an insertion point for the attribute definition.
An attribute definition’s insertion point is similar to a text string’s base point. Remember to use snap, object snap, or another precision tool if you want the eventual attribute values to be located at a precise point.
Repeat Steps 1–10 for any additional attribute definitions.
To create a series of attribute definitions in neat rows for a single block, create the first one by following Steps 1–9, and then select the Align Below Previous Attribute Definition check box for the subsequent definitions. To make a series of nonadjacent attributes, create the first one by using Steps 1–10, and then copy the first attribute definition and edit the copy by using the Properties palette. You can prevent attributes from being dragged around the block by selecting the Lock Position check box in the Attribute Definition dialog box.
After you create one or more attribute definitions and any other geometry that you want to include in the block, you’re ready to create a block definition that contains them. Follow the steps in the earlier section “Creating Block Definitions.” At Step 4 in that section, you can select any attribute definitions before or after you select the other geometry. However, you should select each attribute definition one by one (clicking each attribute definition rather than selecting multiple attributes with a selection window) in the order you want the attribute value prompts to appear in the Edit Attributes dialog box. (See Figure 17-5.) If you don’t select the attributes one by one, the block and attributes still work, but the order of the attribute prompts in the Edit Attributes dialog box may not be what you want.
After you create a block definition that contains attribute definitions, you insert it the same way you insert any other block. Follow the steps in the earlier section “Inserting Blocks.” At the end of the steps, AutoCAD displays the Edit Attributes dialog box, as shown in Figure 17-5. The dialog box contains one row for each of the attribute definitions and has any default values filled in. You simply edit the values and then click OK.
The ATTDIA (ATTribute DIAlog box) system variable controls whether AutoCAD prompts for attribute values in a dialog box (ATTDIA=1) or at the command line (ATTDIA=0). If you insert a block and see command line prompts for each attribute value, type a value and press Enter for every attribute value you want to set. When you return to the command prompt, type ATTDIA, press Enter, type 1, and press Enter again. When you insert blocks with attributes into this drawing in the future, AutoCAD displays the Edit Attributes dialog box instead of prompting you at the command line.
After you insert a block that contains attributes, you can edit the individual attribute values in that block reference with the EATTEDIT command. Click the Single drop-down button in the Block panel on the Home tab and click any object in the block reference. AutoCAD displays the Enhanced Attribute Editor dialog box with the current attribute values, as shown in Figure 17-6. The most common attribute editing operation is to edit the text value, which is the text string that appears in the block reference. You also can change properties of the attributes, such as layer and text style.
Many people use attributes only in the way I describe in this chapter, as fill-in-the-blank text fields in blocks. But attributes also can work with data extraction tools. For example, you can export attribute values, such as part numbers and quantities, to a table object in AutoCAD or to a text, spreadsheet, or database file for analysis or reporting.
Selecting Extract Data from the Linking & Extraction panel on the Insert tab of the Ribbon starts the Data Extraction Wizard. You can find out much more about this specialized function in the online Help system. Check out User’s Guide ⇒ Share Data between Files ⇒ Extract Data from Drawings and Spreadsheets. And if you use AutoCAD LT and don’t have this wizard, you can still extract attribute information to space- or comma-delimited text files by using the Attribute Extraction dialog box. These files can be imported into spreadsheets and database programs for further processing. For more information, visit the online Help system.
In a regular block definition (not a dynamic block), the objects in each block reference act like a well-honed marching squadron: If you move or otherwise edit one object in the block reference, all objects move or change in the same way. Usually this cohesion is a benefit, but occasionally you need to break up the squadron to modify a single object and not affect the others.
To explode a block reference into individual objects, click Explode in the Modify panel on the Home tab; or type X, press Enter, and select the block reference. When you explode a block reference, AutoCAD replaces it with all objects (the lines, polylines, and arcs, for example) specified in the block definition. You then can edit the objects individually or perhaps use them to make more block definitions. Only the block you select is exploded.
Both AutoCAD and AutoCAD LT have an NCOPY command that you can use to copy objects contained within blocks without having to explode the block. AutoCAD users who are familiar with the Express Tools may already be familiar with NCOPY; the command is now in the core of the program and therefore available to LT users. In both versions, you can find the Copy Nested Objects tool in the Modify panel slideout on the Home tab or simply type NCOPY.
Each block definition increases the size of the DWG file, as do other named objects, such as layers, text styles, and dimension styles. In the case of a large, complex block definition, the size increase can be significant. If you delete (or explode) all block references that point to a particular block definition, that block definition no longer serves any purpose.
You should run the PUrge command periodically in each drawing to purge unused block definitions. Click the Application button to open the Application menu, choose Drawing Utilities on the left side, and then choose Purge to display the Purge dialog box. Click the Purge All button to purge all unused named objects in the current drawing.
Figure 17-7 shows the rearranged Purge dialog box introduced in AutoCAD 2020. The dialog box in earlier releases has the same basic functionality but it’s arranged differently.
As I mention earlier in this chapter, you can insert any existing drawing into the current one where it becomes a block definition. In a common scenario, you know that another drawing of a 1,000-room hotel contains a block definition of a bathtub you want to use in the master bathroom of a house drawing. No problem: Simply insert the hotel drawing into the house drawing, and then erase or delete the hotel drawing insertion. The drawing now contains a block definition for the bathtub. Oops! Here’s a problem. The house drawing file size has suddenly increased to government-spending numbers because it now contains the hotel drawing and all its block definitions, along with elements such as layer, text style, and dimension style specifications. It’s PUrge to the rescue!
3.139.90.131