Playing Dynamically with Blocks (Learning Curve AutoCAD Tutorial)1 Sep, 2007 By: Bill Fane
A lesson in AutoCAD 2006's Dynamic Block function.
It was another hot, sticky, humid afternoon. Captain LearnCurve and three associates were drifting lazily through the channels and lakes of the Summer Palace, propelled by a gondolier who stood at the stern of their boat.
He had finished his special assignments in Taicang and Shenyang, China, where he had visited the Chien-Shiung Institute of Technology and the Shenyang Institute of Engineering, respectively. He was now in Beijing for a couple of days of R&R before heading home.
The Pearl Street and Silk Road markets were experiences not to be missed. He had done enough haggling over prices in Mexico and the Dominican Republic, but even those adventures had not prepared him for these markets in Beijing. The Silk Road merchants in particular were so aggressive that they grabbed me by the arm and physically dragged me into their stalls. The going rate seems to be just 10-15% of their initial asking price.
The idyllic cruising at the Summer Palace was certainly the opposite extreme. They rode past the legendary Stone Boat tied up dockside. It looked ready to set sail, except that it is made from blocks of solid marble . . .
That's it! This month's topic! Dynamic blocks!
Blocks have been around in AutoCAD pretty much since Day One. They certainly were in use when the Captain started using AutoCAD version 2.17g in 1986, and in fact they didn't change at all until AutoCAD 2006.
Let's start with a basic review of blocks and then go on to explore that dramatic change that came into being with dynamic blocks in AutoCAD 2006.
A block is a collection of objects grouped into a single super-object. You can create a drawing of a bathtub that will comprise several lines and arcs. You can then link them together into a new object called a "bathtub," which can be copied, moved, rotated, erased, and so on as though it were a single object.
Blocks have several big advantages. First, they save space. No matter how big a block definition is, each insertion of it only adds 100 or so bytes to the file size. Each insertion of the block is simply a pointer back to its definition, so about all it holds is the name of the block, the insertion point, the layer it is on, the three scales (x, y, and z), and the rotation angle.
Next, they speed editing. If you change the definition of the block, then all insertions of it update. This can be used to speed drawings. For example, consider a 1,000-room hotel. During the working phase, you can use a simple rectangle with perhaps an X in it to indicate the bathtubs. This will open and plot quickly.
Now, just before you do the final plots, redefine the bathtub block definition to a more detailed one and all 1,000 insertions update.
Finally, they can save creation time from the start. You can easily create library drawings that contain your standard block definitions then use the Design Center or custom tool palettes to simply drag and drop them into the current drawing.
Block that Object . . .
So far, so good, but blocks have a minor inconvenience. Suppose you are creating a factory layout. You are placing a large number of workbenches into the layout, so this would seem to be a perfect use for blocks. It is. Your problem is that your workbenches may all be the same height and style, but they come in three different standard widths and 10 different standard lengths.
Previously, you would have had to define a separate block for each of the standard sizes, but dynamic blocks solve all this. A single block definition can be used for all the workbench sizes. You get to specify the exact size of each bench after you insert it.
The beautiful part is that they all point back to the same definition, so that if it is decided to add a drawer to the benches, then all existing insertions get the new drawer added automatically.
The traditional way to create a block definition is to simply draw the objects and then invoke the Block command (Draw | Block | Make . . . ). This method brings up a fairly standard-looking dialog box with which I'm sure you all are familiar.
On the other hand, many users have avoided dynamic blocks because the interface used to create them seems a little intimidating at first. But, as we will see, it's actually quite friendly.
Let's create a simple example of our workbench block. In this case, we don't create the geometry first; instead, we invoke the Bedit command (Tools | Block Editor). It starts innocuously enough by displaying the Edit Block definition dialog box.
The Bedit command starts with the Edit Block Definition dialog box.
Enter a suitable name, such as Workbench, and then click OK. Here is where it seems to get a little wild, as AutoCAD brings up the block editor environment. Note that I did not call it a dialog box, because it's actually a separate drawing environment.
The Block Editor environment.
If you look closely you will see that it's basically the standard AutoCAD drawing environment, complete with the standard menus and toolbars. The only significant difference is the addition of the Block Authoring tool palettes, which we will ignore for now. We can ignore the insignificant background color change as well.
Start by drawing a rectangle. Its lower left corner should be at the origin (0,0). Make it 36 units long (x direction) and 24 units wide (y direction).
If we were to close the block editor now, we would simply have a standard block definition. On the other hand, let's play with the tool palettes. To paraphrase Sir Isaac Newton:
For Every Action There Is a . . .
. . . parameter. Two steps must be performed to turn a standard block into a dynamic one. I like to think of them as a married couple; one partner issues the action orders while the other does the work. You can figure out the genders yourself.
Anyway, we need to start by defining a parameter. Then we will come back to the action. Make sure the Parameters palette tab is active and then click on the Linear Parameter tool. AutoCAD will ask you to Specify Base Point or . . .
Use an Endpoint or Intersect object snap to select the upper-left corner of the rectangle and then snap again to the upper-right corner to define the endpoint. Pick a location for the parameter, which looks suspiciously like a dimension except that it has the word Distance instead of a value.
We have added a Distance parameter to our rectangle.
The exclamation mark in the yellow box indicates that it doesn't have an action associated with it yet, which we will now rectify. But first we need to set the parameter.
Click on the parameter to select it, right-click to select Grip Display in the context menu, and then click on the number 1 in the flyout menu. The blue triangle at the left end of the parameter will disappear, leaving just the black X.
Click on the parameter again to select it. Next, 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. Select Increment from the drop-down list.
The Dist Increment, Dist Minimum, and Dist Maximum windows now become active. Enter the values 2, 18, and 60, respectively, as shown below.
We have specified the value set for our parameter.
Close the Properties palette and note the series of small vertical hash marks that have appeared under the parameter. They display the increment and range of our values.
The hash marks display our range of values.
Okay, we're almost done. Select the Actions palette tab then select the Stretch Action tool. Select the Distance parameter that we just created and click Enter.
Click on two points, the upper right and then lower left, to define a crossing window that encompasses the right end of the rectangle.
When prompted, select a crossing window.
The next prompt asks you to select objects, so click on the rectangle and select Enter.
You can place the action icon at any convenient location, but it's logical to place it close to the distance parameter it controls.
Done! Now click on the Close Block Editor button to return to AutoCAD's normal drawing environment. Congratulations, you have just defined your first dynamic block.
Next, Insert (Insert | Block) an instance of it into your drawing in the usual manner. It doesn't look too spectacular; it's just a plain rectangle.
Time for a Change . . .
Ah, here comes the magic. Click on the block insertion to select it, and a blue arrow grip appears at the upper-right corner. Click on the blue arrow grip, and it turns red and the series of hash marks appears. A bit of experimenting will show that you can stretch the rectangle to be any length from 18 to 60 units, in two-unit increments. You cannot make it smaller than 18 or larger than 60, and you cannot select anything between the two-unit increment spacing.
Once a dynamic block has been placed, we can grip-edit its size.
Insert a few more instances of the Workbench block and note how you can stretch each block individually and independently.
Although the process may seem a little complex, it's actually quite simple.
- Create your block definition.
- Add parameters as appropriate.
- Configure the parameters. This step is optional. If you don't configure them, each parameter is simply continuously variable and isn't restricted to specific increments or limits.
- Apply the action.
Okay, let's see if you've learned anything. Double-click on any Workbench block insertion to activate the Block Editor. Now draw a circle within the rectangle, and add another stretch parameter to the left side with an increment of two and minimum/maximum values of 22 and 26. Close the block editor to save your changes.
We can edit the block definition to add details and more parameters.
Observe what has happened in your drawing. All the existing insertions have the circle added to them, and all insertions now have two editing grips.
This lesson has been a quick start in dynamic blocks. Be sure to come back next month when I dig even deeper into more of the options and capabilities of this powerful functionality.
By the way, the Captain is probably the first tourist in history to visit China for the first time and not visit the Great Wall or the Forbidden City. He is waiting until he and his gorgeous wife go to China on vacation in October.
Now for Something Completely Different . . .
When haggling for a string of pearls in the Pearl Street market in Beijing, there are two easy ways to tell fake pearls from genuine ones.
First, rub two of them together. Fake ones will slide smoothly past each other, but genuine ones will feel almost gritty due to stick-slip friction.
Second, gently scrape the surface with a sharp knife and then rub the wound with your finger. Fake ones will leave a permanent scar, but genuine ones will completely heal over.
Autodesk Technical Evangelist Lynn Allen guides you through a different AutoCAD feature in every edition of her popular "Circles and Lines" tutorial series. For even more AutoCAD how-to, check out Lynn's quick tips in the Cadalyst Video Gallery. Subscribe to Cadalyst's free Tips & Tools Weekly e-newsletter and we'll notify you every time a new video tip is published. All exclusively from Cadalyst!