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 double, queen-sized, 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 will learn to:

  • Work with 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

cert.eps

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.

Opening the Block Editor

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 saved from earlier exercises and freeze the Notes layer. 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 (see 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 group.

Figure 18-1 The Edit Block Definition dialog box

c18f001.tif
3. With the KITCHEN block name selected, click OK. You see an enlarged view of the kitchenette in the drawing area with a light gray background (see Figure 18-2).

Figure 18-2 The Block Editor and its components

c18f002.eps

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.

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 18-3 shows the Block Editor tab and tools.

Figure 18-3 The Block Editor tab

c18f003.tif

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, “Making ‘Smart’ Drawings with Parametric Tools.” Let’s continue our look at the basic features of the Block Editor.

Editing a Block and Creating New Blocks

cert.eps

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 Block Editor on the Block Editor tab’s Close panel (see the right side of Figure 18-3).
3. A message appears asking if you want to save your changes to the Kitchen block. Click Save The Changes To KITCHEN. 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.

Figure 18-4 The unit plan with the edited Kitchen block

c18f004.tif

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

c18uf001.tif

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.

Creating a Dynamic Block

cert.eps

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 Block Editor tool in the Home tab’s Block panel.
c18uf002.tif
2. In the Edit Block Definition dialog box, enter Sink in the Block To Create Or Edit box and then click OK.
c18i001.tif
3. Use the Rectangle tool on the Home tab’s Draw panel to draw a rectangle that is 12 units in the x-axis and 15 units in the y-axis.
4. Zoom into the rectangle so your view looks similar to Figure 18-5.

Figure 18-5 The rectangle for the Sink block

c18f005.tif

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.

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 Basepoint 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.
c18uf003.tif

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:

c18i002.tif
1. Click the Linear tool on the Parameters tab of the Block Authoring palettes, or expand the Parameter tool (Point) on the Block Editor tab’s Action Parameters panel and click Linear.
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.

Figure 18-6 Placing the Linear parameter

c18f006.tif

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. Turn off osnaps and then click the Actions tab in the Block Authoring palettes and select Stretch.
c18uf004.tif
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] <Start>: 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.
c18uf005.tif
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 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 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 circle with the 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:

c18i003.tif
1. Click the Insert tool in the Home tab’s Block panel.
2. In the Insert dialog box, enter Sink in the Name box and then click OK. The sink appears at the cursor.
3. Place the block at the location shown in Figure 18-7.

Figure 18-7 The Sink block in place

c18f007.eps
c18i004.tif
4. Make sure the Dynamic Input feature is turned on by checking the Dynamic Input tool on the status bar, and then click the newly inserted sink. You see two arrows at the vertical midpoints of the block.
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 width of the block changes to 15 inches from the original 12.

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

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.
c18uf006.tif
5. Click in the Dist Increment input box just below the Dist Type options, and enter 1 for an increment distance of 1 inch.
c18uf007.tif
6. Close the Properties palette, and then click Close Block Editor on the Block Editor tab’s Close panel.
7. Save the changes.
8. Click the Sink block to expose its grips.
9. Click and drag the right arrow grip to the right. 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″ apart, as shown in Figure 18-8.
10. Set the width of the sink back to 12″.

Figure 18-8 Grip-editing the Sink block with the Linear parameter’s increment value set to 1

c18f008.eps

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 3 through 5. You can enter values for these settings that define the range of movement allowed for the grip edits.


Understanding the Cycling Option
You can turn on the Cycling option in the Misc group of the Properties palette of any parameter grip. Cycling allows you to use the parameter grip as an insertion point. With this option turned on, you can press the Ctrl key to cycle between the standard insertion point and the cycle-enabled grip of a parameter while inserting the block.

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 ⇒ Modify Selection Set. You can also choose Action Selection Set ⇒ New Selection Set if you want to change the object of the action.

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 (see Figure 18-9).

Figure 18-9 Adding the sink drain

c18f009.tif
3. Select the Dimension1 linear parameter, and then right-click and select Properties.
4. In the Properties palette, scroll down to the bottom and look for the Base Location setting under the Misc section.
5. Click the Base Location option, and then select Midpoint from the drop-down list that appears to the right.
c18uf008.tif
6. Close the Properties palette.
7. Click Close Block Editor in the Close panel, and save the Sink block changes.

Now try grip-editing the block to see how the Stretch 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 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 you’ve already worked with function. 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 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 change the scale. But when you scale the door, all 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:

c18i005.tif
1. Click the Edit tool in the Home tab’s Block panel.
2. In the Edit Block Definition dialog box, select DOOR and then click OK.
c18i006.tif
3. Click the AutoConstrain tool in the Block Editor tab’s Geometric panel, and then select the rectangle representing the door, as shown in Figure 18-10. To select the door using a window, click above and to the left of the door, and then click below and to the right.
4. Press ↵ when the door has been selected. You’ll see the geometric constraint icons appear around the door.

Figure 18-10 Select the rectangle representing the door.

c18f010.tif

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:

c18i007.tif
1. Click the Coincident tool in the Geometric panel.
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:

c18i008.tif
1. Click the Aligned tool in the Block Editor tab’s Dimensional panel.
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.

Figure 18-11 Select the locations for the door opening dimensional constraint.

c18f011.eps
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. With the dimension highlighted, press ↵. Your drawing will look similar to Figure 18-12.

Figure 18-12 The aligned dimensional constraint applied to the door opening

c18f012.tif

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:

c18i009.tif
1. Click the Aligned tool again from the Dimensional panel.
2. Select the left end of the bottom horizontal line again as you did in the previous exercise (see Figure 18-13).

Figure 18-13 The door with the opening and door constraints added

c18f013.tif
3. Select the right end of the bottom horizontal line, as shown in Figure 18-13.
4. Place the dimension line below the door roughly the same distance away from the door as the first dimensional constraint.
5. With the newly placed dimension highlighted, enter d1↵. This will cause the door rectangle to follow the dimension of the d1 door opening dimensional constraint.

Finally, add the dimensional constraint for the arc:

c18i010.tif
1. Click the Radius tool in the Block Editor tab’s Dimensional panel.
2. Click anywhere on the arc.
3. Position the radius dimensional constraint anywhere toward the outside of the arc.
4. With the radius dimension highlighted, enter d1↵. This will cause the arc to follow the dimension of the door opening dimensional constraint.
5. You now have all of the constraints in place and are ready to try out your dynamic block (see Figure 18-14). Click Close Block Editor in the Close panel to save the block and return to the drawing.

Figure 18-14 The door with all the constraints added

c18f014.tif

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.

Figure 18-15 The Door block with its grips exposed

c18f015.tif
2. Click the door to select it. The added aligned constraint arrow appears as a grip on the right end of the Door block.
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↵ to change the door width to 24″.

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

1. Double-click the door to open the Edit Block Definition dialog box and then click OK.
c18i011.tif
2. In the Block Editor tab’s Dimensional panel, click the Block Table tool.
3. At the Specify parameter location or [Palette]: prompt, place the block table in the location shown in Figure 18-16.

Figure 18-16 Placing the block table

c18f016.tif
4. At the Enter number of grips [0/1] <1>: prompt, press ↵. The Block Properties Table dialog box appears (see Figure 18-17).

Figure 18-17 The Block Properties Table dialog box

c18f017.tif
c18i012.tif
5. Click the Add Properties tool in the upper-left corner of the Block Properties Table dialog box. The Add Parameter Properties dialog box appears (see Figure 18-18).

Figure 18-18 The Add Parameter Properties dialog box

c18f018.tif
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↵. You see 1′-0″ added to the list.
8. Type 18↵; 1′-6″ is added to the list.
9. Type 243036↵. The values you enter are added to the list in feet and inches format (see Figure 18-19).

Figure 18-19 The Block Properties Table dialog box with the values added

c18f019.tif
10. Click OK to exit the Block Properties Table dialog box.
11. Click Close Block Editor in 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 down-pointing grip below the door, as shown at the left side of Figure 18-20.

Figure 18-20 Selecting a door size from a list

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

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 in the Edit Block Definition dialog box, click OK.
2. Select the d1 dimensional constraint, and then right-click and select Properties.
3. In the Properties palette, select the Name option under the Constraint group and then type Width↵. Notice that all of the dimensional constraints that reference the dimension will change to show the name Width instead of d1.
4. Close the Properties palette, and then click the Close Block Editor tool in the Close panel.
5. To see the change, click the down-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 (see Figure 18-21).

Figure 18-21 The list with the word Width appearing as the column title

c18f021.tif
6. Save and close the file.

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:

c18i013.tif
1. Open the visibilitysample.dwg file, and then click the Block Editor tool on the Home tab’s Block panel.
2. In the Edit Block Definition dialog box, select Bathtub from the list and click OK.
You see the contents of the Bathtub block (see Figure 18-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.

Figure 18-22 The Bathtub block

c18f022.tif

The first thing you need to do is add a Visibility parameter:

c18i014.tif
1. On the Parameters tab of the Block Authoring palettes, click Visibility.
2. Click below the blocks to place the Visibility parameter as shown in Figure 18-23.

Figure 18-23 Adding the Visibility parameter

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

Figure 18-24 The Visibility States dialog box

c18f024.tif

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↵. This is the visibility state for your standard bathtub.
3. Click the New button to open the New Visibility State dialog box (see Figure 18-25).

Figure 18-25 Adding a visibility state

c18f025.tif
4. Enter Jetted in the Visibility State Name 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 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 in the Visibility States dialog box, and click the Set Current button. (You can also double-click the Standard item.) A check mark 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).

Figure 18-26 Locating the blocks

c18f026.eps
2. Right-click, and choose Object Visibility ⇒ Hide For Current State. You can also click the Make Invisible tool on the right side of the Block Editor tab’s Visibility panel.
c18uf009.tif
The selected blocks disappear. They didn’t go anywhere; they are just made invisible.
3. Click the drop-down list on the Block Editor tab’s Visibility panel, and select Jetted. The hidden blocks appear.
c18uf010.tif
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.
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 that 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.
c18i015.tif
2. Click the Insert tool on the Home tab’s Block panel. In the Insert dialog box, select Bathtub from the Name drop-down list.
3. Make sure Specify On-Screen is checked for the Insertion Point group and unchecked for the Scale and Rotation groups.
4. Click OK, and then place the block to the right of the other three blocks.
5. Click the Bathtub block you just inserted, and then click the Visibility grip (see the left image in Figure 18-27).
6. Select Jetted from the list. The jetted bathtub appears (see the right image in Figure 18-27).
7. Click the Bathtub block again, click the Visibility grip, and select Corner. The Corner tub appears.
8. Save and close the drawing.

Figure 18-27 Using the Visibility grip to change the bathtub

c18f027.eps

Controlling the Visibility of Invisible Objects
While you’re editing in the Block Editor, you can set up AutoCAD to display objects whose visibility has been turned off. If you set the bvmode system variable to 1, objects appear gray when their visibility has been turned off. You can also click the Visibility Mode tool in the Block Editor tab’s Visibility panel.

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

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)

c18f028.eps

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

1. Open the 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.
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.
c18i016.tif
3. Click the Show All Geometric Constraints tool in the Block Editor tab’s Geometric panel to reveal some of the existing constraints.

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 18-29).

Figure 18-29 How the parts of the block are constrained

c18f029.eps

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:

c18i017.tif
1. In the Dimensional panel, click the Angular tool.
2. Click the left vertical line toward the top, as shown in Figure 18-30.
3. Next, click the left horizontal line toward the right end of the line, as shown in Figure 18-30.

Figure 18-30 Adding the angular constraint to the gatesample.dwg drawing

c18f030.eps
4. Place the dimension as shown in Figure 18-30.
5. The dimension text is highlighted. You want to keep the current value, so press ↵ to accept the default.

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:

c18i018.tif
1. In the Dimensional panel, click the Angular tool.
2. Click the right vertical line near its top, as shown in Figure 18-31.
3. Click the right horizontal line near its right end (see Figure 18-31).
4. Place the dimension as shown in Figure 18-31.

Figure 18-31 Adding the angular constraint to the second gate

c18f031.eps
5. At the highlighted text, type ang1↵. This will cause this constraint to follow the first one you added.

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↵. Both sides of the block rotate about their own centers to a 45-degree angle (see Figure 18-32).
5. Click the arrow grip again, and type 90↵ to set the gate back to its original position.

Figure 18-32 The two parts rotate in unison.

c18f032.tif

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:

1. Double-click the Gate block to open the Edit Block Definition dialog box, and then click OK. The Gate block opens for editing.
c18i019.tif
2. Click the Construction Geometry tool in the Manage panel.
3. Select the four red lines and press ↵↵. Notice that the lines change from solid to dashed, indicating that they are now construction geometry.
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.
c18i020.tif
2. Click the Parameters Manager tool to open the Parameters Manager palette. You may recall that in Chapter 17, you used this palette to control the size of a concentric circle.
3. Double-click in the Expression column of the ang2 option, and type ang1 * -1↵.
4. Close the Parameters Manager palette, and then save and close the block.
5. Click the gate to select it, and then click the arrow grip.
6. Type 22↵. Now the two parts rotate in opposite directions (see Figure 18-33).

Figure 18-33 The gates moving in opposite directions

c18f033.tif
7. Save and close the file.

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 array objects automatically 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.
c18i021.tif
3. On the Actions tab of the Block Authoring palettes, click the Array action.
4. At the Select parameter: prompt, click the blue Linear parameter (labeled as Distance), as shown in Figure 18-34.

Figure 18-34 Adding the Array action to the Railvertical block

c18f034.eps
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 ↵.
6. At the Enter the distance between columns (|||): prompt, enter 4↵.
7. Click Close Block Editor on the Block Editor tab’s Close panel and save the changes.
8. Click the block to expose its grips.
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).

Figure 18-35 The Railvertical block adds vertical bars as its width expands.

c18f035.tif
10. Exit and save the file.

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.


Using Parameter Sets
You probably noticed the Parameter Sets tab in the Block Authoring palettes. The options in this tab are predefined combinations of parameters and actions that are commonly used together. For example, the Polar Array set inserts a Polar parameter with an Array action. You only need to supply the object. The Polar Array set causes the associated object to rotate about a center point with a grip. You can also array the object by stretching the grip away from the rotation center.
To associate an object with a parameter set, right-click the action icon associated with a parameter (usually appearing below the parameter), and then select Action Selection Set ⇒ New Selection Set. At the Select objects: prompt, select an object. If a stretch is employed, select a stretch frame and an object to stretch.

Including Block Information with Data Extraction

In Chapter 13, “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 18-36 shows the door inserted into a drawing using different door sizes and left and right variations.

Figure 18-36 The door block inserted several times into a drawing with various widths and handedness

c18f036.tif

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 dynamic door block that is similar to the one you created earlier with the addition of a left and a right Visibility parameter.
c18i022.tif
2. From the Annotate tab’s Tables panel, click the Extract Data tool to start the Data Extraction Wizard.
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 check mark 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 check mark 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).

Figure 18-37 Set up the Select Properties screen to look like this.

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

Figure 18-38 The resulting table to be extracted, as shown on the Refine Data screen of the Data Extraction Wizard

c18f038.tif
9. You don’t really want to extract this data, so once you’ve taken a good look at this screen, click Cancel and then Yes in the Quit Wizard dialog box.

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


Take Care Using the Mirror Tool
If you use the Mirror command to mirror a block that contains a Visibility parameter to control left- and right-hand doors, the Attribute Extraction command will report erroneous results. Therefore, be sure that if you set up a block with a visibility parameter to control mirrored states, you use those actions to edit the door and don’t rely on standard editing tools. That way, you’ll ensure the accuracy of your extracted data.

The Bottom Line

Work with 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. A dynamic block is a block you add grips to so you can modify the block in a number of 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 that 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.249.220