Playing Dynamically with Blocks, Part 2 (Learning Curve AutoCAD Tutorial)1 Oct, 2007 By: Bill Fane
Using AutoCAD's Block Editor to specify insertion points and adjust distances.
It was a dark and rainy morning. Rain is unusual for this time of year, but there it was, pouring down. Captain LearnCurve was on special assignment, as his driver skillfully navigated . . .
Oh, no, not more China anecdotes!
No, that was last week.
This week he was in Kansas City, Missouri, acting as technical support for the technical-drafting competition in the SkillsUSA national championships. His driver was none other than the legendary Dave Espinosa-Aguilar, who was skillfully navigating around the block to avoid the road construction . . .
That's it! This month's topic! Let's play around some more with the dynamic blocks we started with last month.
We'll begin with a quick review. As we saw, a single-block definition can be created that supports a multitude of variations. For example, we created a single-block definition that can be used to show workbenches ranging from 18 to 60" wide and 22 to 26" deep, in 2" increments.
Initially, each insertion is the default size, but after it has been inserted, we can simply click on it and grip-edit to stretch it to any one of the standard sizes.
We skimmed pretty quickly over some of the details, so let's go back and dig into them in a little more depth.
We began by launching the BEdit (Tools | Block Editor) editor. It started by displaying the Edit Block definition dialog box. We supplied the block name Workbench and then clicked OK. This action brought up the Block Editor environment. Note that I did not call it a dialog box because it actually is a separate drawing environment.
Next, we drew a 36 x 24 rectangle, with its lower-left corner at the origin (0,0).
Here's the first detail we skipped over last month. By default, the insertion point of the block is located at the origin (0,0) of the Block Editor environment. We placed the lower-left corner of the rectangle at the origin so that we would have a meaningful insertion point later.
The Point Is . . .
On the other hand, there may be occasions when we want to specify an insertion point other than 0,0. Not a problem. In the Block Authoring Palette of the Block Editor, select the Parameters tab. You'll find a Base Point parameter icon at the bottom of the list. Simply place one insertion point at a suitable location. Object snaps can be used.
Obviously, there can only be one base point, so if you change your mind, you'll need to move it to a new location or delete it and place a new one.
**Caution. **Changing the base point location after parameters have been applied can have bizarre side effects!
Next, we selected and placed a linear parameter using suitable object snaps. You may recall that parameters are used to control the actions to be performed on the dynamic block. In the current context, it is a linear dimension that controls a subsequent stretch action.
After reading last month's column, you may have wondered why I told you to suppress the display of the blue triangle at the left end of the parameter. (As a reminder, we did this by clicking on the parameter to select it and then we right-clicked. We selected Grip Display in the context menu and then clicked on the number 1 in the flyout menu. The blue triangle at the left end of the parameter disappeared, leaving just the black X). We did this because a linear parameter displays a grip at each end by default when we edit the block insertion. But later we are going to set up the stretch action so that only the right-hand grip does anything useful. If we leave the left-hand grip visible, it just confuses users.
Here is where you have to plan and keep track. We know we want the right-hand grip to be visible, but the Grip Display function doesn't let us choose which one. We can only choose one or both -- or none. How do we know which one will be displayed?
The answer: Displaying a single grip displays the one at the second end of the parameter. We applied the parameter from left to right, so when we display one grip, it will be the right-hand one.
The next step we did last month was to set up a predefined range of acceptable values. This is where we said "18 to 60", 2" increments." This step is optional. If we had omitted it, the parameter could have been grip-edited in a continuous range from as far positive to as far negative as we wanted.
Now let's take a look at the other range options. Click on a parameter to select it. Now invoke the Properties command by right-clicking and then selecting Properties from the context menu.
Go to the fourth (Value Set) section and click in the window to the right of Dist Type. Last month, we selected Increment from the drop list, but this time we want it to be None. We can still enter minimum and maximum values for the range, but there is no step increment. The distance parameter is infinitely variable within this range.
The third and final option for the distance type is List. Select it and then click on the little three-dot button to the right of the Dist Val . . . window. This brings up the Add Distance Value dialog box.
Its operation is pretty obvious. You can type single entries into the Distances To Add window and then click on Add to have them appear in the list window. To speed things, you can add multiple values separated by commas, and they will all be added at once as individual values.
To delete an entry, click on the entry in the list and then click Delete. To edit a value, right-click on it in the list and then select Edit from the context menu.
Close the Add Distance Value dialog box and then close the Block Editor. Click on any insertion of the block, then click on the editing grip, and you will see that hash marks appear, allowing you to move the grip only to the specific values defined in the list.
Where's the Action?
When we applied the stretch action last month, you may have noticed that it behaved a little differently from AutoCAD's standard Stretch command.
Specifically, with the standard command, you select objects using crossing windows, then you select a base point, then you select the end point. Note the use of the plural case, because you can use multiple crossing windows.
With the stretch action of the Block Editor, on the other hand, you select the parameter first, then the parameter point to associate with the action (the base point for the stretch). Then you are allowed one crossing window, and then you select specific objects. Consider the following illustration:
This is part of a block definition. In it, we want to be able to stretch the left and right mesas in unison, but we don't want to stretch the middle one.
To accomplish this goal, first select the Distance parameter. Select the upper end of it as the base point then select the dashed-line crossing window rectangle. Next, select the six dashed-solid object lines. Don't select the five solid lines of the middle mesa.
Close the Block Editor and place an insertion of the new block.
As advertised, we now can drag the height of the two outer mesas in unison without affecting the middle one.
In this column, we've explored a few of the details and options of dynamic blocks. By no means has this been a definitive article; we've barely scratched the surface of this powerful functionality. Be sure to come back next month as we dig even more deeply into this subject.
And Now for Something Completely Different . . .
Shanghai's new Pudong International Airport is very well equipped on the international side, but if you are using it to take a departing domestic flight, be forewarned that there are virtually no services in the domestic wing. If you plan on eating while waiting in the departure lounge, bring your own food. All we could find was a paper cup of noodles, to which you then add hot water from a dispenser.
In her easy-to-follow, friendly style, long-time Cadalyst contributing editor and Autodesk Technical Evangelist Lynn Allen guides you through a new feature or time-saving trick in every episode of her popular AutoCAD video tips. Subscribe to the free Cadalyst Video Picks newsletter and we'll notify you every time a new video tip is published. All exclusively from Cadalyst!