Chapter 18. Using Dynamic Blocks

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. Once 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 single-, twin-, queen-, or king-sized shape.

In this chapter, you'll explore the use of dynamic blocks through a series of tutorials. Each tutorial 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.

In this chapter, you'll learn to do the following:

  • Explore the Block Editor

  • Create a dynamic block

  • Add scale and stretch actions to a parameter

  • Add more than one parameter for multiple grip functions

  • Create multiple shapes in one block

  • Rotate objects in unison

  • Fill in a space automatically with objects

Exploring the Block Editor

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 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:

  1. Open the Unit.dwg file you've saved from earlier exercises. You can also use the 18-unit.dwg file.

  2. Double-click the kitchenette in the plan to open the Edit Block Definition dialog box (Figure 18.1). Notice that all the blocks in the drawing are listed in the dialog box and that the Kitchen block is highlighted. You also see a preview of the block in the Preview panel.

    The Edit Block Definition dialog box

    Figure 18.1. The Edit Block Definition dialog box

  3. With the KITCHEN block name selected, click OK.

  4. You see an enlarged view of the kitchenette in the drawing area with a light gray background (see Figure 18.2).

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 18.2.

The Block Editor and its components

Figure 18.2. The Block Editor and its components

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, save, and exit the Block Editor. You can point to each tool in the tab's panels to see its description. Figure 18.3 shows the Block Editor tab and tools.

The Block Editor tab

Figure 18.3. The Block Editor tab

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 17. Let's continue our look at the basic features of the Block Editor.

Editing a Block and Creating New Blocks

The Block Editor lets you edit a block using all the standard AutoCAD editing tools. In the following exercise, you'll modify the kitchen sink and save your changes to the drawing:

  1. Delete the rectangle that represents the sink in the kitchen block.

  2. Click Close on the Block Editor tab's Close panel (see the right end of Figure 18.3).

  3. A message appears asking if you want to save your changes to the Kitchen block. Click Save The Changes. Your view returns to the standard AutoCAD drawing area, and you can see the changes you made to the kitchen, as shown in Figure 18.4.

The unit plan with the edited Kitchen block

Figure 18.4. The unit plan with the edited Kitchen block

As you can see, editing blocks with the Block Editor is simple and 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 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.

The unit plan with the edited Kitchen block

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 input box.

Creating a Dynamic Block

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:

  1. Click the Edit Block tool in the Home tab's Block panel.

    Creating a Dynamic Block
  2. In the Edit Block Definition dialog box, enter Sink in the Block To Create Or Edit input box, and then click OK.

  3. Creating a Dynamic Block
  4. Zoom in to the rectangle so your view looks similar to Figure 18.5.

You could save this block now and you'd have a simple, nondynamic 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 rectangle for the Sink block

Figure 18.5. The rectangle for the Sink block

Adding a Parameter

The first parameter 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:

  1. In the Block Authoring palettes, select the Parameters tab.

  2. Click the Base Point Parameter tool, Shift+right-click, select the Endpoint osnap, and then click the lower-left corner of the rectangle. This is how you determine the base point or insertion point of a block while using the Block Editor.

    Adding a Parameter

Next, you'll add a parameter that will determine the type of editing 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.

  1. Adding a Parameter
  2. At the prompt

    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.

  3. Shift+right-click again, select Midpoint from the Osnap menu, and select the right side of the rectangle.

  4. At the 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 18.6.

Placing the Linear parameter

Figure 18.6. Placing the Linear parameter

The parameter 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 you just added. It tells you that you need to take some further steps to make the parameter useful.

Adding an Action

Next, you'll add a Stretch action that will enable you to use the Linear parameter you just added. The Stretch action will let you stretch the block horizontally 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:

  1. Click the Actions tab in the Block Authoring palettes, and select Stretch.

    Adding an Action
  2. At the Select parameter: prompt, click the parameter you just created.

  3. At the Specify parameter point to associate with action or enter [sTart point/Second point] <Second>: prompt, point to the left-pointing arrow. You see a circle with an X through it showing the location of a parameter point plus an osnap marker on one of the corners.

    Adding an Action
  4. Click the circle with the arrow.

  5. At the 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.

  6. At the Specify objects to stretch: prompt, select the rectangle and the base point you added earlier, and then press

    Adding an Action

You've just added an action to the Linear parameter 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:

  1. Repeat the previous set of steps, but instead of clicking the left arrow of the Linear parameter as you did in step 4 of the preceding exercise, click the right arrow.

  2. Place a window selection around the right side of the rectangle (as you did around the left side in step 5 in the preceding exercise).

  3. At the 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 you need for the parameter. You're ready to save the block and try it out:

  1. Click Close Block Editor on the Block Editor tab's Close panel.

  2. At the message asking if you want to save changes to the Sink block, click Save The Changes To Sink.

Next, insert the sink to see how it works:

  1. Adding an Action
  2. In the Insert dialog box, enter Sink in the Name input box and then click OK. The sink appears at the cursor.

  3. Place the block at the location shown in Figure 18.7.

    The Sink block in place

    Figure 18.7. The Sink block in place

  4. The Sink block in place
  5. Turn on Ortho mode, and click and drag the arrow on the right side of the block. The width of the block follows the arrow as you drag it. You also see the dimension of the sink as you drag the arrow.

  6. Enter 15

    The Sink block in place

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.

Adding an Increment Value

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 you'd like to limit grip movement so that the sink only changes in 1″ increments. Or you might have a dynamic block representing a bolt, and you want the bolt length to increment in 1/16-inch 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 the sink width can be grip edited to 1″ increments:

  1. Double-click the Sink block. Then, in the Edit Block Definition dialog box, make sure Sink is selected and click OK.

  2. Click the Linear parameter's Distance1 label, right-click, and choose Properties.

  3. In the Properties palette, scroll down to the Value Set group and click the Dist Type listing. The Dist Type option changes to a drop-down list.

  4. Expand the list and select Increment.

    Adding an Increment Value
  5. Click in the Dist Increment input box just below the Dist Type options, and enter 1 for an increment distance of 1 inch.

    Adding an Increment Value
  6. Close the Properties palette, and then click Close on the Block Editor tab's Close panel.

  7. Save the Sink block.

  8. Click the Sink block to expose its grips.

  9. Click and drag the right arrow grip to the left. As soon as you click the grip, you see a set of increment marks appear indicating the increment steps for the grip. As you move the grip, the sink width jumps to the increment marks, which are 1 inch apart, as shown in Figure 18.8.

  10. Set the width of the sink back to 12 inches.

Grip editing the Sink block with the Linear parameter's increment value set to 1

Figure 18.8. Grip editing the Sink block with the Linear parameter's increment value set to 1

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 input boxes in the Properties palette in steps 4 and 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.

Editing Parameters and Actions

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

Editing Parameters and Actions

Keeping an Object Centered

Now suppose you want to add a drain to the sink, but to make things a little more complicated, you want to make sure 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:

  1. Double-click the Sink block to open the Edit Block Definition dialog box. Make sure Sink is selected, and click OK.

  2. Add a 3″ diameter circle in the center of the rectangle. This circle will represent the drain (Figure 18.9).

    Adding the sink drain

    Figure 18.9. Adding the sink drain

  3. Select Dimension1 linear parameter and then right-click and select Properties.

  4. At the Properties palette, scroll down to the bottom and look for the Base location setting under the Misc group.

    Adding the sink drain
  5. Click the Base Location option, and then select Midpoint from the drop-down list that appears to the right.

  6. Close the Properties palette.

  7. Click Close Block Editor in the Close panel, and save the sink block.

Now try grip editing the block to see how the Move action affects the sink drain:

  1. Click the sink to select it.

  2. Click and drag the right arrow grip to the right. The drain stays centered in the sink while the two sides expand outward.

In this exercise, you changed the Base Location option for the linear parameter, which caused 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 you've already worked with do. You will learn how these tools work next.

Using Constraints in Dynamic Blocks

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 that you were introduced to 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 would be to change the scale. But when you scale the door, all its features, including the door width, are scaled proportionally. To really be 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:

  1. Using Constraints in Dynamic Blocks
  2. In the Edit Block Definition dialog box, select DOOR, and then click OK.

  3. Using Constraints in Dynamic Blocks
  4. Press

    Using Constraints in Dynamic Blocks
Select the rectangle representing the door.

Figure 18.10. Select the rectangle representing 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, tangent, and horizontal. You'll need to add a constraint to keep the arc connected to the rectangle.

  1. Select the rectangle representing the door.
  2. Place the cursor near the right end of the bottom horizontal line of the rectangle.

  3. When you see the red circle and X marker, click the mouse.

  4. Place the cursor near the lower end of the arc where it meets the rectangle.

  5. When you see the red circle and X marker, click the mouse.

The coincident constraint 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:

  1. Select the rectangle representing the door.
  2. At the 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 18.11.

    Select the locations for the door opening dimensional constraint.

    Figure 18.11. Select the locations for the door opening dimensional constraint.

  3. When you see the red circle with the X appear at the left endpoint of the line, click your mouse.

  4. At the 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 18.11.

  5. At the Specify dimension line location: prompt, place the dimension to the left of the arc (see Figure 18.12).

  6. At the Enter value or name and value <d1=3′-0″>: prompt, press

    Select the locations for the door opening dimensional constraint.
  7. At the Enter number of grips [0/1/2] <1>: prompt, press

    Select the locations for the door opening dimensional constraint.
The aligned dimensional constraint applied to the door opening

Figure 18.12. The aligned dimensional constraint applied to the door opening

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:

  1. The aligned dimensional constraint applied to the door opening
  2. Select the left end of the bottom horizontal line again as you did in the previous exercise (see Figure 18.13).

  3. Select the right end of the bottom horizontal line as shown in Figure 18.13.

    The door with the opening and door constraints added

    Figure 18.13. The door with the opening and door constraints added

  4. Place the dimension line below the door roughly the same distance away from the door as the first dimensional constraint.

  5. At the Enter value or name and value <d2=3′-0″>: prompt, enter d1

    The door with the opening and door constraints added
  6. At the Enter number of grips [0/1/2] <1>: prompt, enter 0

    The door with the opening and door constraints added

Finally, add the dimensional constraint for the arc:

  1. The door with the opening and door constraints added
  2. Click anywhere on the arc.

  3. Position the radius dimensional constraint anywhere toward the outside of the arc.

  4. At the Enter value or name and value <rad1=3′-0″>: prompt, enter d1

    The door with the opening and door constraints added
  5. At the Enter number of grips [0/1/2] <1>: prompt, enter 0

    The door with the opening and door constraints added
    The door with all of the constraints added

    Figure 18.14. The door with all of the constraints added

  6. You now have all of the constraints in place and are ready to try out your dynamic block. Click Close in the Close panel to save the block and return to the drawing.

Now try out your new dynamic block by adjusting the door size:

  1. Pan your view so you can see the entry door clearly, as shown in Figure 18.15.

  2. Click the door to select it. The added aligned constraint arrow appears as a grip on the right end of the Door block.

    The Door block with its grips exposed

    Figure 18.15. The Door block with its grips exposed

  3. Click the arrow grip. The length dimension becomes available for your input, and as you move the mouse, the door changes in size. Note that the thickness of the door doesn't change as you alter its width.

  4. Enter 24

    The Door block with its grips exposed

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″.

Adding a List of Predefined Options

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 this, 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 set up a set of predefined door dimensions.:

  1. Double-click the door to open the Edit Block Definition dialog box, select DOOR, and then click OK.

  2. Adding a List of Predefined Options
  3. At the Specify parameter location or [Palette]: prompt, click the Block Table in the location shown in Figure 18.16.

  4. At the Enter number of grips [0/1] <1> prompt, press

    Adding a List of Predefined Options
  5. Adding a List of Predefined Options
    Adding the Lookup parameter and action

    Figure 18.16. Adding the Lookup parameter and action

    The Block Properties Table dialog box

    Figure 18.17. The Block Properties Table dialog box

    The Add Parameter Properties dialog box

    Figure 18.18. The Add Parameter Properties dialog box

  6. Click the d1 listing at the top of the Add Parameter Properties dialog box and click OK. The Block Properties Table returns with a d1 heading in the list box.

  7. Click just below the d1 listing, then type 12

    The Add Parameter Properties dialog box
  8. Type 18

    The Add Parameter Properties dialog box
  9. Type 24

    The Add Parameter Properties dialog box
    The Property Lookup Table dialog box

    Figure 18.19. The Property Lookup Table dialog box

  10. Click OK to exit the Block Properties dialog box.

  11. Click Close Block Editor from the Close panel to return to your drawing.

Now you can select from the door sizes in a pop-up list:

  1. Click the door to select it.

  2. Click the downward-pointing grip below the door, as shown at the left side of Figure 18.20.

  3. Select 3′-0″ door from the list that appears. The door changes to a 36″-wide door. (See the view to the right in Figure 18.20.)

Selecting a door size from a list

Figure 18.20. Selecting a door size from a 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 on the grip that opens the list, you see d1 as the name. Try the following to change the name from d1 to Width:

  1. Double-click the door, and then at the Edit Block Definition dialog box, click OK.

  2. Select the d1 dimensional constraint, and then right-click and select Properties.

  3. At the Properties palette, select the Name option under the Constraint group and then type Width

    Selecting a door size from a list
  4. Close the Properties palette, and then click the Close Block Editor tool in the Close panel.

  5. To see the change, click the downward-pointing grip below the door as you did in the previous exercise. Now you see the word Width as the heading in the list of door widths (Figure 18.21).

The list with the word Width appearing as the column title

Figure 18.21. The list with the word Width appearing as the column title

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.

Creating Multiple Shapes in One 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 you want.

Try the following exercise to see how this works firsthand:

  1. Creating Multiple Shapes in One Block
  2. In the Edit Block Definition dialog box, select Bathtub from the list, and click OK. Click No if you're asked if you want to see how dynamic blocks are made.

    You see the contents of the Bathtub block (Figure 18.22). It's just the three existing blocks—Standard, Jetted, and Corner—inserted at the same origin.

The Bathtub block

Figure 18.22. The Bathtub block

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 add a Visibility parameter:

  1. The Bathtub block
  2. Click below the blocks to place the Visibility parameter as shown in Figure 18.23.

    Adding the Visibility parameter

    Figure 18.23. Adding the Visibility parameter

  3. Double-click the Visibility parameter you just added to open the Visibility States dialog box (Figure 18.24). One visibility state, VisibilityState0, is already provided.

The Visibility States dialog

Figure 18.24. The Visibility States dialog

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:

  1. Click the Rename button. The existing visibility state in the list to the left becomes editable.

  2. Enter Standard

    The Visibility States dialog
  3. Click the New button to open the New Visibility State dialog box (Figure 18.25).

    Adding a visibility state

    Figure 18.25. Adding a visibility state

  4. Enter Jetted in the Visibility State Name input box.

  5. Make sure the Leave Visibility Of Existing Objects Unchanged In New State radio button is selected, and then click OK.

  6. Click the New button again.

  7. In the New Visibility State dialog box, enter Corner in the Visibility State Name input box.

  8. Make sure Leave Visibility Of Existing Objects Unchanged In New State is selected, and click OK.

    You've just created all the visibility states you need.

  9. Select Standard from the list, and click the Set Current button. (You can also double-click the Standard item.) A checkmark appears to the left of Standard, showing you that it's now the current state.

  10. Click OK to exit the Visibility States dialog box.

You have the visibility states 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:

  1. Select the Jetted and Corner blocks (see Figure 18.26).

    Locating the blocks

    Figure 18.26. Locating the blocks

  2. Right-click, and choose Object Visibility

    Locating the blocks
    Locating the blocks

    The selected blocks disappear. They didn't go anywhere; they were just made invisible.

  3. Click the drop-down list on the Block Editor tab's Visibility panel, and select Jetted. The hidden blocks appear.

    Locating the blocks

    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

    Locating the blocks
  4. On the Block Editor tab's Visibility panel, click the drop-down list again and select Corner. All the blocks appear.

  5. Select the Standard and Jetted blocks, and click the Make Invisible tool. Now only the Corner block is visible.

You've created visibility states and set up the blocks so they appear only when the appropriate visibility state is current. Next, you'll test the blocks:

  1. Click Close Block Editor, and save the changes you've made.

  2. Locating the blocks
  3. In the Insertion Point group, make sure Specify On-Screen is checked, click OK, and then place the block to the right of the other three blocks.

  4. Click the Bathtub block you just inserted, and then click the Visibility grip (see Figure 18.27).

    Using the Visibility grip to change the bathtub

    Figure 18.27. Using the Visibility grip to change the bathtub

  5. Select Jetted from the list. The Jetted bathtub appears.

  6. Click the Bathtub block again, click the Visibility grip, and select Corner. The Corner tub appears.

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-, queen-, and 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 18.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.

The Door dynamic block showing a left- and right-hand door (left), and the Door block as it appears in the drawing (right)

Figure 18.28. The Door dynamic block showing a left- and right-hand door (left), and the Door block as it appears in the drawing (right)

Rotating Objects in Unison

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 they move or change in unison. The following example shows how you can apply more than one Rotate action to a single Rotation parameter to control two objects:

  1. Open the gatesample.dwg file. In this sample file, the part that will move are the two parts in black. The red lines have been added to help facilitate the rotation feature of the block.

  2. Double-click the object in the drawing to open the Edit Block Definition dialog box, and then click OK. The Gate block opens for editing.

  3. Rotating Objects in Unison

You can see how this drawing has been prepared for this exercise. The black parts of the drawing, which I'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 Fix constraint (Figure 18.29).

How the parts of the block are constrained

Figure 18.29. How the parts of the block are constrained

You'll use the red lines to define the rotation angle of the parts. The vertical line is fixed in place while the rest of the parts are constrained in such a way to allow a rotational motion.

Now add some angular constraints to define the rotation.

  1. How the parts of the block are constrained
  2. Click the vertical line toward the top as shown in Figure 18.30.

  3. Next, click the horizontal line toward the right end of the line as shown in Figure 18.30.

  4. Place the dimension as shown in Figure 18.30.

    Adding the Angular constraint to the gatesample.dwg drawing

    Figure 18.30. Adding the Angular constraint to the gatesample.dwg drawing

  5. At the Enter value or name and value <angle1-90>: prompt, press

    Adding the Angular constraint to the gatesample.dwg drawing
  6. At the Enter number of grips [0/1/2] <1>: prompt, press

    Adding the Angular constraint to the gatesample.dwg drawing

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:

  1. Adding the Angular constraint to the gatesample.dwg drawing
  2. Click the vertical line near its top as shown in Figure 18.31.

    Adding the angular constraint to the second gate

    Figure 18.31. Adding the angular constraint to the second gate

  3. Next, click the horizontal line near its right end (Figure 18.31).

  4. Place the dimension as shown in Figure 18.31.

  5. At the Enter value or name and value <angle1-90>: prompt, type ang1

    Adding the angular constraint to the second gate
  6. At the Enter number of grips [0/1/2] <1>: prompt, type 0

    Adding the angular constraint to the second gate

Now you're ready to save the block and try it out:

  1. Click Close Block Editor on the Block Editor tab's Close panel, and save the block.

  2. Click the block to expose its grips.

  3. Click the arrow grip on the horizontal line.

  4. Type 45

    Adding the angular constraint to the second gate
  5. Click the arrow grip again and type 90

    Adding the angular constraint to the second gate
The two parts rotate in unison.

Figure 18.32. The two parts rotate in unison.

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 really there to facilitate the action of the gate and not really part of the drawing. Do the following to hide the red lines:

  1. Double-click the Gate block to open the Edit Block Definition dialog box, and then click OK. The Gate block opens for editing.

  2. The two parts rotate in unison.
  3. Select the four red lines and press

    The two parts rotate in unison.
  4. Click the Close Block Editor tool and save the block. The block now appears without the red lines. If you click on the block, the rotation grip still appears, and you can alter the block as before.

Now suppose 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.

  1. Double-click the Gate block to open the Edit Block Definition dialog box, and then click OK. The Gate block opens for editing.

  2. The two parts rotate in unison.
  3. The two parts rotate in unison.
  4. Double-click in the Expression column of the User1 option and type ang1 * −1

    The two parts rotate in unison.
  5. Double-click the Expression column of the Ang2 option.

  6. Type user1

    The two parts rotate in unison.
  7. Close the Parameters Manager palette, and then close and save the block.

  8. Click the gate to select it, and then click the arrow grip.

  9. Type 22

    The two parts rotate in unison.
The gates moving in opposite directions

Figure 18.33. The gates moving in opposite directions

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, take a look at a way to automatically array objects with dynamic blocks.

Filling in a Space Automatically with Objects

Perhaps one of the more tedious tasks 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:

  1. Open the railsample.dwg file.

  2. Double-click the object in the drawing to open the Edit Block Definition dialog box, and then click OK. This opens the Railvertical block for editing.

    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.

  3. Filling in a Space Automatically with Objects
  4. At the Select parameter: prompt, click the blue Linear parameter, as shown in Figure 18.34.

  5. At the Select objects: prompt, select the dark vertical rectangle representing the vertical bar of the railing, as shown in Figure 18.34, and then press

    Filling in a Space Automatically with Objects
  6. At the Enter the distance between columns (|||): prompt, enter 4

    Filling in a Space Automatically with Objects
  7. Click Close Block Editor on the Block Editor tab's Close panel and save the block.

  8. Click the block to expose its grips.

    Adding the Array action to the Railvertical block

    Figure 18.34. Adding the Array action to the Railvertical block

  9. Click and drag the blue arrow grip to the right. As the rail expands, additional vertical bars are added at 4″ intervals (see Figure 18.35).

The Railvertical block adds vertical bars as its width expands.

Figure 18.35. The Railvertical block adds vertical bars as its width expands.

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.

Including Block Information with Data Extraction

In Chapter 13, you learned how you can 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 18.36 shows the door inserted into a drawing using different door sizes and left and right variations.

The door block inserted several times into a drawing with various widths and handedness

Figure 18.36. The door block inserted several times into a drawing with various widths and handedness

You'll use the Attribute Extraction command to see how the dynamic block data appears as an exported table or a spreadsheet:

  1. Open the 18-extractsample.dwg file. This file contains a door dynamic block that is similar to the one you created earlier, with the addition of a left and right Visibility parameter.

  2. The door block inserted several times into a drawing with various widths and handedness
  3. On the Begin screen, click Next.

  4. In the Save Data Extraction As dialog box, enter Test for the name, and click Save.

  5. On the Define Data Source screen, click Next.

  6. On the Select Objects screen, remove the checkmark from the Display All Object Types option so that only the Door block appears in the list, and then click Next.

  7. On the Select Properties screen, remove the checkmark from all but the Dynamic Block option in the right column, and make sure the Hand and Width options in the left column are the only ones selected (see Figure 18.37).

    Set up the Select Properties screen to look like this.

    Figure 18.37. Set up the Select Properties screen to look like this.

  8. Click Next. On the Refine Data page, you see the data that will be exported to a spreadsheet file or table (see Figure 18.38).

  9. You don't really want to extract this data, so once you've taken a good look at this screen, click Cancel.

This is the end of the door example, so you can exit this file. Save it for future reference if you like.

The resulting table to be extracted, as shown on the Refine Data screen of the Attribute Extraction Wizard

Figure 18.38. The resulting table to be extracted, as shown on the Refine Data screen of the Attribute Extraction Wizard

As you can see in Figure 18.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.

The Bottom Line

Explore the Block Editor

To create dynamic blocks, you need to become familiar with the Block Editor. You can use the Block Editor to modify existing blocks in your drawing.

Master It

What does the Edit Block Definition dialog box allow you to do?

Create a dynamic block

Dynamic blocks allow you to add grips to a block that let you modify the block in a number of different ways.

Master It

Name some of the features of the Block Editor that let you add additional grip editing functions to a block.

Add Scale and Stretch actions to a parameter

You can set up a dynamic block to perform multiple operations with a single grip.

Master It

What do you need to do to have one grip perform two functions?

Add more than one parameter for multiple grip functions

In addition to having one grip perform multiple operations, you can add as many grips as you need to make your block even more customizable.

Master It

What feature do you use to set up a list of options for a block?

Create multiple shapes in one block

Many of the dynamic-block functions let you adjust the shape of the original block. Another feature lets you choose completely different shapes for the block.

Master It

When a block uses the Visibility parameter to set up different shapes, how do you select a different block shape in the drawing?

Rotate objects in unison

Blocks can be set up so the action of one set of objects affects another set. This chapter gives the example of rotating objects in unison.

Master It

Name the dimensional constraint that was used in the object rotation example in this chapter.

Fill in a space automatically with objects

A dynamic block can help you automate the addition of repetitive elements to your drawing.

Master It

What is the name of the action used to produce an array of an object in a block when the block is stretched?

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.216.174