Dynamic blocks are an amazing feature, but they can be complicated. This tutorial will teach you many techniques that you can use in your own blocks. The door will do the following:
- Stretch to 3 sizes
- Flip left/right
- Flip in/out
This tutorial is updated for AutoCAD 2010 and 2011. Follow these steps:
- In a new drawing using architectural units, create a Door layer and make it the current layer.
- Draw a rectangle 1-1/2″ x 30″. This is the door.
- Start the ARC command and use the Center option. Specify the lower-left corner of the door as the center. For the first point, move the cursor to the right at 0°, and type 30 on the command line/dynamic input tooltip. Specify the upper-right corner of the door to draw the arc and complete the swing.
- Select both objects, and start the BLOCK command. Call the block Door. Set its base point at the lower-left corner of the door. Check the Open in Block Editor check box. Click OK. The door opens in the Block Editor with its base point at the 0,0 point of the axes.
- From the Parameters tab of the Block Authoring palettes, choose Linear Parameter. At the prompt, pick the lower-left corner of the door and then the start point of the arc on the right. If prompted, pick a point below the door for the label.
Note: The exclamation point indicates that the process is incomplete or incorrect. You almost always see the exclamation point when you place a parameter, because most parameters need an action.
- Select the parameter, right-click it, and choose Grip Display> 1. This removes the left grip, which is important because you’ll be stretching from the right grip only. If you don’t do this step, the exclamation point won’t go away when you add the action.
- With the parameter still selected, open the Properties palette. In the Property Labels section, click the Distance Name item and change the value to Door width.
- From the Actions tab of the Block Authoring Palettes, choose Stretch Action. At the prompt, select the linear parameter.
- At the Specify parameter point to associate with action or enter [sTart point/Second point] <Start>: prompt, click the right grip (the turquoise triangle).
- At the Specify first corner of stretch frame or [CPolygon]: prompt, pick a point above and to the right of the door. At the Specify opposite corner: prompt, pick a point to the left of the door and down, as you see here.
- At the Select objects: prompt, pick the door (the rectangle), but nothing else. End selection.
- At the Specify action location or [Multiplier/Offset]: prompt, right-click and choose the Offset option. This option lets you change the angle of the stretch action. At the Enter angle offset <0.00>: prompt, enter 90. (In earlier releases, you’ll be prompted for an action location. Pick a point to the right of the grip.) In newer releases, the command ends, placing a small action icon automatically.
- Select the action icon and open the Properties palette. It’s sometimes hard to select the action icon, so check that Stretch Action displays at the top of the Properties palette. In the Overrides section, change the Angle Offset value to 90. As you stretch to the right, the door will stretch upward.
- Before going any further, click the Save Block button on the Block Editor’s toolbar/tab and click the Close Block Editor button. It’s a good practice to test your dynamic block at each stage. In AutoCAD 2010 or later, you can test by clicking Test Block.
- Save your drawing, too. Select the door, click the Stretch grip on the right and drag to the right. The door should stretch in the 90° direction, as you see here. Of course, the arc doesn’t do anything, but we’ll fix that later.
- In order to constrain the width of the door to common widths, select the door and open the Block Editor again or close the Test Block window.
- Save the block again and close the Block Editor. You may see this dialog box or a similar one now or later in this tutorial. Sometimes, saving changes to a block that’s already in your drawing can cause problems, but usually it’s all right. So click Yes.
- Try stretching the door this time. You’ll see those vertical bars again and you’ll be able to stretch only to those distances.
- Now it’s time to get that arc to follow the door. You might think that you could stretch the arc, too, but stretched arcs become distorted. Instead, you want to scale the arc. Because you want the arc to stretch by the same amount that you stretch the door, you use the same parameter and add another action to it, this time a Scale action. So, open the Door block in the Block Editor again.
- On the Actions tab, choose Scale Action. At the Select parameter: prompt, select the linear parameter. At the Select objects: prompt, select the arc and end selection. For earlier releases, at the Specify action location or [Base type]: prompt, place the action label near the arc.
- Save and test. As you stretch the door, the arc scales accordingly. Make sure that there are no gaps at any width. If there are, you need to correct something.
- It would be great to create a door that can flip in all directions because this could replace four separate blocks or remove the necessity to insert a door block at negative values. To do this, return to the Block Editor.
- From the Parameters tab, choose Flip. At the Specify base point of reflection line or [Name/Label/Description/Palette]: prompt, Shift+right-click and choose Mid Between Two Points. Then specify the endpoint at the basepoint of the block and the endpoint at the start point of the arc. At the Specify endpoint of reflection line: prompt, move up 90° and pick. (The length of the reflection line is not important.) At the Specify label location: prompt, pick a location inside the arc.
- From the Actions tab, choose Flip. At the Select parameter: prompt, choose the Flip parameter. At the Select objects: prompt, select the door and its arc. If prompted to do so, place the label next to the Flip parameter.
- Save the block and test .Select the block. Click the flip grip and the door flips. Flip it back again. Now try stretching the door to its maximum width and flip again. There are two problems:
- The stretch grip stays on the right when you flip the door, so now you can’t stretch the door.
- Did you notice that the flip grip stays where it was? It’s no longer in the middle of the door, which means that it won’t flip properly. If you draw two walls with a 3’ gap and flip the door, you’ll see this clearly.
Note: You can see why you need to test dynamic blocks thoroughly!
- To make the stretch grip flip, you need to include it in the selection set of the flip action. In fact, you need to include the linear parameter, the stretch action, and the arc’s scale action so that everything works no matter which way the door is flipped. So, open the door in the Block Editor again.
- Select the flip action icon (not the flip parameter). Right-click it and choose Action Selection Set> New Selection Set. At the Select object to add to action set or [Remove]: prompt, type all and press Enter to end selection.
- Save the block and exit the Block Editor. Start by stretching the door back to its minimum of 30″. Flip the door a couple of times and you’ll see that the stretch grip flips back and forth at all widths. The arc works properly, too.
- To fix the problem with the flip grip not staying at the midpoint, you need to move it when you stretch the door. In fact, you need to move it half the distance that you stretch. This will keep the flip grip centered. Open the door in the Block Editor again.
- From the Actions tab, choose Move. At the Select parameter: prompt, select the linear parameter, because you want the flip parameter to move in concert with (but half the distance of) that parameter. At the Specify parameter point to associate with action or enter [sTart point/Second point] <Start>: prompt, pick the right grip on the linear parameter. At the Select objects: prompt, select the flip parameter (not the action). End selection. Select the Move action icon and open the Properties palette. Set the Distance Multiplier option to .5. If prompted, place the move label near the flip parameter.
- Save and test the door at the 3 widths. Now, when you stretch the door, after you click, the flip grip jumps to the new midpoint of the door.
- Actually, there’s another problem! You don’t see it unless you do the following. Start with the door opening to the right (its original direction) and stretch it to its maximum width, 3’. Flip it. Then stretch it to its narrowest width. Do you see how the block’s insertion point doesn’t move with the block? This makes moving the block difficult. So open the door for editing again.
- From the Parameters tab, choose Base Point. At the prompt, specify the bottom-left corner of the door, which is 0,0 in the Block Editor. You can use the Endpoint object snap to specify the point.
- Now, select the flip action, right-click, and choose Action Selection Set> Modify Selection Set. At the Select object to add to action set or [Remove]: prompt, select the new base point parameter and press Enter to end selection.
- Save and test the block again as you did before (it may have moved — if so, move it back). You’ll see that the block’s base point always stays on the block.
- There’s just one more procedure—to add a flip action going the other way, so that the door can open inward or outward. So open the door for editing again.
- Choose Flip from the Parameter tab and start the reflection line at the lower-left corner of the door — the basepoint. End this horizontal reflection line at the bottom endpint of the arc. Place the label to the left of the door.
- On the Actions tab, choose Flip Action. At the Select parameter: prompt, choose the flip parameter. At the Select objects: prompt, type all and end selection. (That’s what you learned you needed to do in the previous steps.) You should see 13 found. If prompted for a location, place the label beneath the flip parameter label.
- Save and test the door.
- You probably thought you were done, but there’s one more step. As you did before, stretch the door to its maximum width. Flip the door to the left and then stretch it to its narrowest. You’ll see that the new flip grip doesn’t follow. That’s because it isn’t included in the first flip action you created. (It couldn’t be, because the new flip action didn’t exist then.) In fact, you want the in/out flip parameter to flip with the left/right flip action.
- Re-edit the block. Select the first flip action, right-click and choose Action Selection Set> Modify Selection Set. At the Select object to add to action set or [Remove]: prompt, select the new flip parameter. Save, exit, and test again.
As you can see, there is often an iterative process, requiring you to go back and include new objects in actions that you created earlier. Remember to thoroughly test your dynamic blocks!
Watch the video of how the door functions.
Thanks to Edwin Prakoso for helping me debug this block. He suggested typing “all” to select objects.