Blocks are a great way to create and store ready‐made symbols. They can be a real time‐saver, especially when you have assemblies that you use often. Earlier in this book you learned how to create a basic, no‐frills block. When you understand the basics of block creation, you can begin to work with dynamic blocks.
Dynamic blocks have properties that you can modify using grips. For example, you can create a dynamic block of a door and then easily grip‐edit its size and orientation. Or you can use a single block to represent several versions of a similar object. You can have a single block of a bed that can be modified to show a double, queen‐sized, or king‐sized shape.
In this chapter, you'll explore the use of dynamic blocks through a series of exercises. Each exercise will show you a different way to use dynamic blocks. This will help you become familiar with the methods involved in creating dynamic blocks. You'll start by looking at the Block Editor, which in itself makes editing blocks much easier. Then you'll be introduced to the tools used to create dynamic blocks.
Before you start to add dynamic block features to blocks, you'll want to get familiar with the Block Editor. The Block Editor offers an easy way to make changes to existing blocks, and as you'll see a bit later, it's also the tool that you'll use to give your blocks some additional capabilities.
As an introduction to the Block Editor, you'll make changes to the now familiar unit plan from earlier tutorials. Start by editing the Kitchen block in the unit:
Unit.dwg
file that you saved from earlier exercises, and freeze the Notes layer. If you have been working in metric or did not create the file earlier, you can also use the 17‐unit.dwg
file.The gray background tells you that you're in the Block Editor. You'll also see the Block Editor tab along the top of the drawing area and the Block Authoring palettes, as shown in Figure 17.2.
Take a moment to look over the panels and tools on the Block Editor tab. This tab offers several housekeeping tools that let you open and save blocks and exit the Block Editor. You can point to each tool in the tab's panels to see its description. Figure 17.3 shows the Block Editor tab and tools.
Both the Block Editor tab and the Block Authoring palettes offer tools for adding dynamic block features that you'll explore later in this chapter. You may notice that the Block Editor tab contains the geometric and dimensional constraint panels that you learned about in Chapter 16, “Making ‘Smart’ Drawings with Parametric Tools.” Let's continue our look at the basic features of the Block Editor.
The Block Editor lets you edit a block using all of the standard Autodesk® AutoCAD® editing tools. In the following exercise, you'll modify the kitchen sink and save your changes to the drawing:
As you can see, editing blocks with the Block Editor is straightforward. In this example, you deleted part of the block, but you can perform any type of drawing or editing to modify the block. The Block Editor tab also offers other block‐saving options in its panels. You can save the block as you work by clicking the Save Block Definition button. If you need to create a variation on the block that you're currently editing, you can click the Save Block As tool on the Block Editor's expanded Open/Save panel to create a new block or overwrite an existing one with the drawing that is currently in the Block Editor.
If you want to edit a different block after editing the current one, you can click the Save Block tool on the Block Editor's Open/Save panel to save your current block and then click the Edit Block tool.
This tool opens the Edit Block Definition dialog box that you saw earlier. You can then select another block to edit or create a new block by entering a name for your block in the Block To Create Or Edit box.
Now that you've seen how the Block Editor works, you can begin to explore the creation of dynamic blocks. As an introduction, you'll create a rectangle that you'll use to replace the sink in the kitchen. You'll add a dynamic block feature that will allow you to adjust the width of the sink using grips. In addition, you'll add a control that limits the size to one‐unit increments.
Start by creating a block from scratch using the Block Editor:
You could save this block now, and you'd have a simple, static block. Next, you'll add a couple of features called parameters and actions. As their names imply, parameters define the parameters, or limits, of what the dynamic block will do, and actions describe the particular action taken when the grips of the dynamic block are edited. For example, in the next section, you'll add a Linear parameter that tells AutoCAD that you want to restrain the grip‐editing to a linear direction. You'll also add a Stretch action that tells AutoCAD that you want the grip‐edit to behave like a Stretch command that pulls a set of vertices in one direction or another.
The first parameter that you'll add establishes the base point for the block. This will let you determine the point used when inserting the block in your drawing:
Next, you'll add a parameter that will determine the type of editing that you want to add to the block. In this case, you want to be able to grip‐edit the width of the block. For that you'll use the Linear Parameter tool:
Specify start point or [Name/Label
/Chain/Description/Base/Palette/Value set]:
Shift+right‐click and select the Midpoint osnap; then select the left side of the rectangle.
Specify label location:
prompt, the parameter name appears with the parameter label at the cursor. Click below the rectangle to place the label, as shown in Figure 17.6.The parameter that you just added lets you modify the block in a linear fashion. In this case, it will allow you to change the width of the rectangle. As you'll see, the locations of the parameter's arrows later become the grip locations for the dynamic block.
But just adding the parameter doesn't make the block dynamic. You need to include an action before a parameter can be used. You may have noticed the warning symbol in the parameter that you just added. It tells you that you need to take some further steps to make the parameter useful.
Next, you'll add a Stretch action that will enable you to use the Linear parameter that you just added. The Stretch action will let you stretch the block horizontally by using grips. As you add the action, notice that it's similar to the Stretch command. The only difference is that you don't stretch the object; you only specify the vertices to stretch and the object you want to stretch.
Follow these steps:
Select parameter:
prompt, click the Distance1 parameter you just created.Specify parameter point to associate with action or enter [sTart point/Second point] <Start>:
prompt, point to the left‐pointing arrow. You see a red X showing the location of a parameter point.
Specify first corner of stretch frame or [CPolygon]:
prompt, place a selection window around the entire left side of the rectangle. This selects the portion of the rectangle that is to be stretched when you grip‐edit the block.Specify objects to stretch Select Object:
prompt, select the rectangle and the base point you added earlier and then press ↵ to complete your selection.You've just added an action to the Linear parameter that you added earlier. You'll see an action icon appear below and to the right of the Distance1 linear parameter. The icon looks like the Stretch tool in the Actions tab to help you identify the action. If you hover over the icon, the parts affected by the action are highlighted.
Notice that the warning symbol is still showing. You need to add another action to the right side of the parameter because the parameter expects that you'll want to be able to grip‐edit both sides:
Specify objects to stretch:
prompt, select the rectangle again.A second action icon appears next to the first one to the lower right of the Distance1 linear parameter. This time the warning symbol disappears, telling you that you've completed the steps that you need for the parameter. You're ready to save the block and try it out:
Next, insert the sink to see how it works:
Although you entered a value in step 6 to change the width of the sink, you could have clicked the mouse to change the width visually. The rectangle is still a block. You didn't have to explode it to change its width. If you hover the cursor over the dynamic block grip, you see the block's width dimension.
You can grip‐edit your dynamic Sink block to modify its width, and as you saw in the previous exercise, you can enter a specific value for the width as well. But suppose that you'd like to limit grip movement so that the sink changes in only 1″ steps. You can set parameters to have an increment value so that grip edits are limited to a specific distance.
The following steps show how you can set up the Linear parameter of the Sink block so that the sink width can be grip‐edited to 1″ increments:
In addition to an increment distance, you can set a range of movement for the Linear parameter. You may have noticed the minimum and maximum text boxes in the Properties palette in steps 3 through 5. You can enter values for these settings that define the range of movement allowed for the grip edits.
The sink exercise is a simple demonstration of how you can create and use dynamic blocks. But as you can see from the Block Authoring palettes, you can add many other parameters and actions to a block.
In the previous exercises, you inserted parameters and actions using the default settings. These settings give you default names and labels for the parameters and actions, but you can always change them later. To change the label that appears for a parameter, double‐click the label. The label will then appear in a rectangular box showing you that you can change its text.
If you want to include additional objects for an action, click the action icon to select it and then right‐click and select Action Selection Set ➢ Modify Selection Set. You can also choose Action Selection Set ➢ New Selection Set if you want to change the object of the action.
Now suppose that you want to add a drain to the sink, but to make things a little more complicated, you want to make sure that the drain remains centered if the sink is widened or made narrower. You can alter the way the Linear parameter behaves so that both sides of the sink move symmetrically. Here's how it works:
Now try grip‐editing the block to see how the Stretch action affects the sink drain:
In this exercise, you changed the Base Location option for the Linear parameter, which causes the block to behave differently when you edit its grips. You can also employ a completely different method to achieve similar results. The Geometric and Dimensional panels of the Block Editor tab offer a set of tools that work in a way that's similar to how the parameters and actions with which you've worked already function. You will learn how these tools work next.
In the sink example, you added two Stretch actions to a Linear parameter. This enabled the block to be stretched in both the left and right directions. The actions and parameters offer one way of creating dynamic blocks, but you can also use the geometric and dimensional constraints to which you were introduced in the previous chapter.
In this section, you'll turn a simple door block into a dynamic block that will allow you to resize the door to any opening. In the process, you'll learn how to apply geometric and dimensional constraints to create a dynamic block.
At first, you may think that all you need to do to resize a door is to change the scale. But when you scale the door, all of its features, including the door width, are scaled proportionally. To be very accurate, you only want to stretch the door width and scale the door swing, leaving the door thickness at the same dimension. This can be accomplished by adding two aligned dimensional constraints and a few geometric constraints to the door.
Start by opening the Door block in the Block Editor and adding the geometric constraints to the door:
The geometric constraints will make sure that the door maintains its rectangular shape when you apply changes to the door through the dynamic block feature. The constraints used are Parallel, Perpendicular, Coincident, and Horizontal. Note that the Coincident constraint will not show an icon unless you hover over one of the corners of the rectangle.
You'll need to add a constraint to keep the arc connected to the rectangle:
The Coincident constraint that you just added will keep the arc and rectangle connected at the bottom‐right corner of the rectangle.
Next, add a dimensional constraint. Most likely, you'll need to scale the door based only on the door opening, so place a dimensional constraint between the door hinge and the end of the door swing arc:
Specify first constraint point or [Object/Point & line/2Lines] <Object>:
prompt, point to the line at the bottom of the drawing near the left endpoint, as shown in Figure 17.11.
Specify second constraint point:
prompt, place the cursor on the top end of the arc so that you see the circle and X marker again at the left end of the arc, as indicated in Figure 17.11, and click.Specify dimension line location:
prompt, place the dimension to the left of the arc (see Figure 17.12).
Notice that the constraint you just added is named d1. This will be an important feature in the next two constraints that you add.
Next, add another dimensional constraint to the width of the door rectangle. This time, you want the constraint to follow the door opening constraint, so instead of accepting the default value for the dimension, you'll enter the name of the first dimensional constraint:
Finally, add the dimensional constraint for the arc:
Now try out your new dynamic block by adjusting the door size:
Notice that, although you were able to enter a door dimension directly to the block, you didn't change the door thickness when the door size changed. Only the door swing and width changed to accommodate the new door size. This is most apparent if you scale the door to a small size such as 6″ or 12″.
Earlier, you saw how you can add an increment value set to make a dynamic block stay in a set range of sizes. You can also set up a dynamic block to offer a range of sizes in a pop‐up list. To do so, you need to employ the Block Table feature.
In the following exercise, you'll add a selectable list to the Door block to allow the door size to be selected from a list. Start by adding the block table that will allow you to define a set of predefined door dimensions:
Specify parameter location or [Palette]:
prompt, place the block table in the location shown in Figure 17.16.
Enter number of grips [0/1] <1>:
prompt, press ↵. The Block Properties Table dialog box appears (see Figure 17.17).
Now you can select from the door sizes in a pop‐up list:
If at a later time you need to make changes to the list or add more dimensions, you can open the block in the Block Editor and then click the Block Table tool. The Block Properties Table dialog box will appear with the data you entered earlier. You can then make changes to the table.
In this example, you saw that you can easily add predefined sizes to the dimensional constraint that appear in a selectable list. You can also give the list a more meaningful name. Right now, when you click the grip that opens the list, you see d1 as the name. Try the following to change the name from d1 to Width:
As you can see, you have a lot of control over the behavior of various components of the dynamic block. In the next section, you'll learn how you can control the visibility of different parts of your block.
Depending on circumstances, you may need a block to display a completely different form. For example, you might want a single generic bath that can morph into a standard bath, a corner bath, or a large spa‐style bath with jets.
Using dynamic blocks, you can hide or display elements of a block by selecting a visibility state from a list. For example, you can draw the three different bath sizes and then set up a visibility state for each size. Each visibility state displays only one bath size. You can then select a visibility state depending on the bath size that you want.
Try the following exercise to see how this works firsthand:
visibilitysample.dwg
file, and then click the Block Editor tool on the Home tab's Block panel.You see the contents of the Bathtub block (see Figure 17.22). It's just the three existing blocks—Standard, Jetted, and Corner—inserted at the same origin.
If you were to insert this block in a drawing, it would appear just as you currently see it, with each bathtub type overlaid on another. Next you'll see how you can add control over the visibility of each bathtub type so that only one is displayed at a time.
The first thing you need to do is to add a Visibility parameter:
You'll need three visibility states, one for each type of bathtub whose visibility you want to control. You've already got one, but you want a name that is more appropriate to the application:
You've just created all of the visibility states that you need.
You have the visibility states that you need, and you have the objects whose visibility you want to control. Now you need to determine which block is visible for each state.
Remember that in step 9 of the previous exercise, you made Standard the current visibility state. You'll want only the standard Bathtub block visible for this state. Do the following to turn off the other two Bathtub blocks for the current state:
The selected blocks disappear. They didn't go anywhere; they are just made invisible.
The current visibility state is now Jetted, so you want only the Jetted block to be visible. Select the Standard and Corner blocks, and then right‐click and choose Object Visibility ➢ Hide For Current State. You can also click the Make Invisible tool from the Visibility panel. Now only the Jetted block is visible.
You've created visibility states and set up the blocks so that they appear only when the appropriate visibility state is current. Next you'll test the blocks:
In this example, you used a set of bathtubs, but you can use the Visibility parameter for anything that requires a different appearance. As mentioned at the beginning of this chapter, another use might be a block that contains a double, a queen‐sized, and a king‐sized bed. Going back to the door example, you can create a left‐ and right‐hand door in the same block and then use the Visibility parameter to display a left‐ or right‐hand door in the drawing. Figure 17.28 shows such a door block. The Visibility parameter has been renamed Hand in the block. When the door is inserted in the drawing, you see a list that allows you to select Left or Right.
You've seen how actions and parameters can control the behavior of a single object in a block. You can also apply actions to multiple objects so that they move or change in unison. The following example shows how you can apply more than one Angular Constraint parameter to control two objects:
gatesample.dwg
file. In this sample file, the part that will move consists of the two non‐red objects. The red lines have been added to help facilitate the rotation feature of the block.You can see how this drawing has been prepared for this exercise. The non‐red parts of the drawing, which we'll call gates, are blocks that are constrained to the red lines with coincident constraints. The endpoints of the lines are constrained to the center of the arcs. The horizontal red lines are constrained to the vertical ones, also with Coincident constraints, and the vertical lines are constrained at both ends with a fixed constraint (see Figure 17.29).
You'll use the red lines to define the rotation angle of the parts. The vertical line is fixed in place, whereas the rest of the parts are constrained in such a way as to allow a rotational motion.
Now add some angular constraints to define the rotation:
You have the first angular dimensional constraint in place. Next add a second one to the gate on the right, but this time you'll use the name of the first angular constraint as the dimension for the second one:
Now you're ready to save the block and try it out:
You've got the basic function of the gate working, but you don't want the red lines to appear in the drawing since they are there to facilitate the action of the gate and are not really part of the drawing. Do the following to hide the red lines:
Now suppose that you want to have the gates rotate in opposite directions instead of in the same direction. You can add a user‐defined formula to modify the behavior of the angular constraints:
You can go on to add a block table using the Block Table tool to create a predefined set of angles, just as you did for the Door block earlier in this chapter. You can also add incremental values by using the Properties palette to change the angle constraint in a way similar to how you changed constraints in the sink exercise in the first part of this chapter.
Next let's take a look at a way to array objects automatically with dynamic blocks.
Perhaps one of the more tedious tasks that you'll face is drawing the vertical bars of a hand railing for an elevation view. You can draw a single bar and then use the Array command to repeat the bar as many times as needed, but when you have to edit the railing, you may find that you're spending more time adding and erasing bars.
In the next example, you'll see how you can create a block that automatically fills in vertical bars as the width of the railing changes. You'll start with an existing drawing of a single vertical bar and an outline of the railing opening around the bar:
railsample.dwg
file.When the Block Editor opens, notice that the block already has a Linear parameter and a Stretch action added. Recall from the sink example at the beginning of this chapter that the Linear parameter and Stretch action let you vary the width of an object. In this case, the outermost rectangle is being stretched.
Select parameter:
prompt, click the blue Linear parameter (labeled as Distance), as shown in Figure 17.34.
Select objects:
prompt, select the dark vertical rectangle representing the vertical bar of the railing, as shown in Figure 17.34, and then press ↵.Enter the distance between columns (|||):
prompt, enter 4↵.You can now use this block wherever you need to draw a simple railing with vertical bars. Another example of how the Array action might be used is in a side view of a bolt. You could show the threads of the bolt and use the Array action to increase the number of threads as the bolt is lengthened.
In Chapter 12, “Using Attributes,” you learned how you could attach data to blocks through attributes and then extract that data to spreadsheets or AutoCAD tables. You can also include dynamic block information that has been included in a property lookup table. This can be extremely useful for generating data for a bill of materials or in other situations if you need to track the numbers and types of items in your drawing.
To see how this works, you'll return to a version of the Door block that has some additions. This enhanced version of the Door block includes a left‐ and right‐hand version of the door that is controlled with the Visibility parameter. Figure 17.36 shows the door inserted into a drawing using different door sizes and left and right variations.
You'll use the Attribute Extraction command to see how the dynamic block data appears as an exported table or a spreadsheet:
17‐extractsample.dwg
file. This file contains a dynamic door block that is similar to the one that you created earlier with the addition of a left and a right Visibility parameter.Test
file will be saved in the My Documents
folder. If you want to place it somewhere else, make sure that you browse to the location that you prefer.This is the end of the door example, so you can exit this file. Save it for future reference if you like.
As you can see in Figure 17.38, a list is generated that shows each door in the drawing with its size and handedness. You could use this data as part of a door schedule.
3.17.64.72