Playing Dynamically with Blocks, Part 3 (Learning Curve AutoCAD Tutorial)31 Oct, 2007 By: Bill Fane
Learn how to use AutoCAD's Rotate parameter and action.
It was a warm, sunny, and breezy afternoon. Captain LearnCurve was taking Bryan, one of his 5-year-old twin grandsons, for a sail on his Hobie Cat. They had been out for a while but now Bryan's time was up, and it was time for Brodie to have a turn . . .
Time! That's it! This month's topic!
Wait a minute! We worked on dynamic blocks in September's and October's "Learning Curve" columns, and you ended the last one by promising to teach us even more about them.
Correct. We'll start off this month's column with instructions on how to build a clock face using a dynamic block. Each insertion of the face can be set easily to show a different time. Okay, you may not need a clock, but what we are really learning is how to use the Rotate parameter and action.
By now, you don't need a review of the basic concepts and procedures, so let's jump right in.
Open the Block Editor (BEdit) and create a new block called Clock. Draw the basic face for your clock using the usual AutoCAD draw commands. For the best results, place the center of the circle at 0,0 in the block editor window, because this is a logical insertion point for the block.
I used a tapered polyline (Pline) for the hour marks and then polar arrayed them. For the hour hand, I used a two-segment polyline with appropriate start and end widths for each segment. Zero is an appropriate value; it produces the sharp point.
The basic clock face plus the hour hand, as drawn in the Block Editor.
Now, make sure the Parameters palette is active and click on the Rotation parameter. This time we are going to get a little clever; instead of simply jumping right in and applying the parameter, type L on the keyboard. AutoCAD now prompts for a Label for the parameter and offers the default value of Angle. Type in Little Hand.
When you press Enter, AutoCAD asks for the base point. Snap to the center of the circle. It's going to be the base point about which the little hand will rotate.
Next, AutoCAD asks you to specify the radius of the parameter. Snap to the pointy endpoint of the little hand. It can be any arbitrary location, but what you are really specifying is the location of the editing grip after the block is inserted. It's a good idea to specify a logical location, such as the end of the particular clock hand to be rotated.
AutoCAD now places our little hand parameter.
Next, go to the Actions palette and apply a Rotate Action to our little hand parameter, and then select the polyline as the object to be rotated. Now AutoCAD asks for a location for the action. As we have seen previously, it's usually logical to place it close to the parameter it's controlling. You now should have something like the item depicted below showing on your screen.
We have applied a Rotate action to our little hand parameter.
Close the block editor and place an insertion of your Clock block. Single-click on it, and two blue editing grips appear. The square one on the left end is the insertion base for the clock, and it can be used to relocate the whole clock. The round one on the right can be used to drag the little hand to any desired time.
Double-click on the block insertion to activate the Block Editor again so we can finish our clock.
Time on Our Hands
You can add big hand and second hand polylines, parameters, and actions. You also might want to modify the properties of the parameters so their action sets are six-degree increments. That way, the hands will always snap to one-minute time intervals (360 degrees divided by 60 minutes per hour = six degrees per minute).
Close the block editor and say Yes, you want existing insertions to update. Note how your existing insertion has updated to show the additional hands. Add more insertions of your Clock. Click on each in turn and use the round editing grips to rotate the big hand, the little hand, and the second hand to appropriate values. I used Array to create a cluster of clocks, such as the ones you often see behind the front desk of better hotels. Each clock shows the current time at different major cities around the world.
A group of clocks that shows the time in cities around the world.
Say, shouldn't the big hand be pointing to the same minute in every clock?
Yes and no. For starters, Newfoundland, Canada, is one-half hour different from everyone else. Besides, have you ever taken a close look at the clocks in a typical hotel reception area? What I have shown is anatomically correct.
Speaking of anatomical correctness, as we have seen in previous articles, if you edit the block definition to change the spelling of the name, the shape of the hands, or whatever, then all existing insertions will update while continuing to display their individual time settings.
Did you hear that they are going to put a clock in the leaning Tower of Pisa? If you have the inclination, you might as well have the time . . .
Mix and Match
So far all the dynamic blocks that we've created have used the same type of parameter and action. As we have seen, we can have more than one dynamic action in the same block. In our earlier workbench example, we stretched the width and length, and in our current clock example, we applied angles to three hands.
Ah, but there is nothing that says we can't have more than one type of dynamic action in the same block. For example, we could set up a desk wherein we can stretch the desk size and rotate the chair that sits in front of it.
Let's explore this a little further. Suppose we don't always want the second hand to show. No problem; we don't have to create another block definition. We can simply add a Visibility parameter.
Open your Clock block for editing again and click on Visibility Parameter in the Parameters palette. You will be asked to select a location, but then nothing much else seems to happen. A closer inspection reveals that several new tools have become active in the upper-right corner of the Block Editor window.
Click on the Manage Visibility States button . This brings up the Visibility States dialog box.
The Visibility States dialog box manages the visibility of objects within a dynamic block.
Let's start by clicking on the Rename button and changing the name of VisibilityState1 to All.
Next, click on New to bring up the New Visibility State dialog box.
This dialog box is used to create and define a new visibility state.
Enter the new name No Seconds, and make sure the Show All Existing . . . radio button is active. Click OK to return to the previous dialog box, where No Seconds should be the active state. Click OK.
Now notice the three icons to the left of the Visibility States Manager icon. Click on the right-hand one of the set, which is the Make Invisible button. AutoCAD asks you to select objects. Click on the second hand and then press Enter. Close the Block Editor.
Do You See What I See?
Click on a Clock insertion to show the editing grips. You will also see an inverted triangle icon at the location where you placed the Visibility parameter. Click on it, and a list of all the defined visibility states appears. Click on No Seconds, and the second hand disappears from this one insertion. The other insertions are unaffected.
Let's go back to the Block Editor for a moment so we can check the other two visibility buttons. The middle Make Visible button makes currently invisible objects visible again within the current visibility state.
The left-hand Visibility Mode button toggles the BVMode system variable, which controls the display of invisible objects within the block editor. When it is on (1), objects that are tagged as invisible in the current visibility state are visible but grayed out. When it is off (0), objects that are invisible in the current state are invisible in the editor. Using this latter mode, you can preview almost exactly how each visibility state will appear when the block is inserted.
Another significant point to note is that the state at the top of the list is the default when the block is inserted, regardless of the state that is current. Use the Move Up/Move Down buttons in the Visibility States Manager dialog box to put the preferred state at the top of the list.
You can create as many visibility states as you want, with objects being off in some views and on in others and vice versa. I could thus add a new brand label piece of text to my clock along with a matching Brand visibility state, so I could set individual insertions to be either Rollecks or Timeless as desired.
There is a great deal more functionality in dynamic blocks. Three articles are sufficient to give only a brief introduction. I could write an entire book on the subject, but hopefully I have piqued your interest so you will explore further and unlock the power lurking within dynamic blocks.
And Now for Something Completely Different . . .
When you go whitewater rafting, remember, the seats in the front of the raft tend to get a more exciting ride but also tend to be much wetter than those towards the back. This is particularly true when you drop over the 14' Husum Falls on the White Salmon River in Washington State.
About the Author: Bill Fane
For Mold Designers! Cadalyst has an area of our site focused on technologies and resources specific to the mold design professional. Sponsored by Siemens NX. Visit the Equipped Mold Designer here!
For Architects! Cadalyst has an area of our site focused on technologies and resources specific to the building design professional. Sponsored by HP. Visit the Equipped Architect here!