Tutorial – Make a Dynamic Block for Lockers

With the release of Autocad 2006 we saw the introduction of Dynamic Blocks (DBs), a feature that is as powerful as it is daunting. Dynamic blocks will allow you to substantially reduce the size of your block library by combining similar blocks into one block that can be manipulated by the user after insertion. The following tutorial will demonstrate how to create a DB for a typical elevation of lockers. The DB will do the following:

  • Allow the choice of single tier up to 6 tier locker styles
  • Choose between 5′ high and 6′ high lockers
  • Show either a left hand or right hand hinged door
  • Show either left, right, or both sections of lockers perpendicular to the elevation
  • Make use of up to a 6″ filler on either left, right, or both sides of the elevation
  • Choose between flat topped or slope topped lockers
  • Array the lockers up to 100′

This tutorial will focus mainly on the inner workings of the DB itself and will skip the formalities of most of the basic Autocad tasks such as “draw a 12″x60″ rectangle”. The lockers in this DB were derived from dimensional data in the Penco specifiers manual but you can apply this tutorial to nearly any similar object that you use repeatedly. Also, each figure is a thumbnail link that will open a new window with the full size picture. If you would like a copy of the finished locker DB to follow along with or to just tear apart yourself, Grab it Here! Also, if you like this block, feel free to check out my entire collection of dynamic blocks on Autodesk’s Exchange Apps Service by clicking below:


DB King is a compilation of 300+ dynamic blocks used daily in the Architectural field for producing construction documents. The vast majority of the 300+ blocks have numerous visibility states or other modifying parameters making for a 1000+ item library for only $10.00USD !

So, let’s dive into the wonderful world of Dynamic Block creation!

Before we get started I’d like to give you a little background on myself. My name is Brenton L. Shank and I have been working with Autocad since Version 12 starting somewhere around 1993. All of the positions that I’ve held have been related to the construction industry in some form or another and I am currently employed at Noelker and Hull Architects, Inc. of Chambersburg, Pennsylvania. Recently I’ve taken on the task of standardizing the company block library and that’s where the major use of dynamic blocks began. I would like to give thanks to management at Noelker and Hull Architects, Inc. for giving me the freedom to experiment with this new feature.

Now that you know a little bit about me, let’s start this tutorial off by taking a minute to look at Figure 01 through Figure 05 to get an idea of where we’re heading. Below these Figures are short descriptions of what they represent.

Figure 01 shows the locker DB in its default state. This is what will appear when you initially insert the block.

Figure 02 also shows the default state except now it is selected and ready for modification.

Figure 03 shows the same DB modified to show (4) six-tier lockers with perpendicular sections at both the right and left side. It also shows a sloped top and uses the 6″ filler strip at each end.

Figure 04 is similar to Figure 03 except that it is selected and ready for modification.

Figure 05 shows the completed block as seen in the block editor with all visibility states showing.

The mess that is called Figure 05 should explain the daunting part of DBs but they aren’t as bad as they appear once you break them down into smaller components. The first step in creating any DB is to take an idea and think about the ways that it could be manipulated with the available DB parameters and actions. There are some limitations with the available parameters (particularly being allowed only one visibility state parameter) but there are also some workarounds to these limitations. Once you get familiar with the basics of DBs you will find that there isn’t much that can’t be done if you are willing to take the time and work out a solution.

One other thought to keep in mind while building your DBs is to give names to your parameters and actions that make sense to you and give some idea of what they are doing. This practice will make a world of difference when it comes time to add a feature to a DB six months after you have completed it. Sticking to a standard naming convention will make it much easier to figure out what actions are doing what when you need to make modifications to the DB.

Although I won’t mention it in this tutorial, it is also a good idea to stop and test your DBs at various points along the way. Typically I will stop, save, and test after completing each major action so that any problems can be spotted and fixed before they compound and get out of hand.

 

Once it was decided to do a locker DB, I put some thought into what could be done with it without making the block too complex. The lockers that are specified the most here are 12″ wide and 12″ deep so I decided to start there. Figure 06 shows the linework items that are needed for the different configurations of 12″ wide lockers. What you see, from left to right, are the left and right ends for the 6-tier lockers, the left and right ends for the 1-5 tier lockers, the main outline for the 6-tier lockers, the main outline for the 1-5 tier lockers, and the door styles for all 6 types. The main outline that is circled in red is the base that will be used for the dynamic parameters. I find it is easier to spread everything out and get as many parameters that you can think of in place before introducing the visibility state parameter. This will help eliminate the need to go back later and add/delete items from the visibility states. Things are going to get pretty crowded once all the linework is brought together so making use of polylines for the end sections and base frames will make object selection much easier later on. Also note that there is seperate linework for the 6-tier lockers ends and main outline. I will explain why later in the tutorial.

 

Looking at the main outline circled in red in Figure 06,, we have the main locker outline which is 12″ wide by 60″ high, the floor line which is offset 4″ below the locker, and the back of the sloped top which is offset 4″ above the locker. We can now add some parameters to this outline starting with a basepoint parameter in the bottom lefthand corner. I add a basepoint to nearly all my DBs just to ensure that the basepoint is always forced to be what I want it to be. Next we can add a linear parameter for the width starting at the top left and ending at the top right. Follow that up with another linear parameter for the height starting at the bottom right corner of the locker body and ending at the top right corner of the body. Figure 07 shows these three parameters in place.

Now we need to set the properties for the linear parameters starting with the width. Since I know beforehand that this DB will only be for 12″ wide lockers, the width parameter will be used strictly for an array action. We can set the properties that will be needed for the array as seen in Figure 08. The Dist type is set to increment, the Dist increment is set to 1′-0″ (the width of 1 locker), the Dist minimum is set to 1′-0″ (1 locker), and the Dist maximum is set to 100′-0″ (100 lockers). The Dist maximum could be left blank but I feel it is good practice to put some limitation on the array. Also note that the number of grips is set to 1 since our basepoint is in the lower left and we will always be arraying to the right.

The locker style depicted in this DB comes in both 5′ high and 6′ high models so we can set the height parameter to constrain the height to these two dimensions. Figure 09 shows the properties for the height parameter. Because there are only two different heights, we can set the Dist type to list and type in 60″ and 72″ in the Dist value list. Also, I prefer to use a Lookup to choose the height so we will not be needing any grips on the height parameter. Set the number of grips to 0.

Now that we have some linear parameters in place and configured, we can start applying some actions to them. We know that the lockers are available in both 5′ and 6′ high models so a stretch action for the height is in order. When we stretch the height, we will need to stretch the top of the locker frame, the top of the top door frame, the top door swing line, and the topmost set of ventilation holes. Place a stretch action based on the height parameter and set a stretch window that will include those items mentioned. For the selection set, select the main frame, the top door frames, the top door swing lines, and the topmost set of ventilation holes. The items on the door styles can be selected even though they are outside of the strecth frame since they will be later moved to a position inside the frame. Here’s where we run into the first problem with this DB. In order for the stretch frame to include everything necessary for the single tier locker it has to come below the midpoint of the top door swing line for the four and five tier lockers. This would stretch the center of the hinge line to a position that we don’t want it to be in. The solution to that problem is to make two stretch actions based on the same height parameter. Figure 10 shows the first stretch action named StretchH Tier 1-3. You’ll notice that the hilighted selection set only includes the door styles for single through three tier lockers. Figure 11 shows the second stretch action named StretchH Tier 4-5 that includes a selection set for the four and five tier lockers. The six tier lockers do not need to be included in either of the stretch actions since they are only available in the 6′ high model.

As mentioned earlier, I like to use a lookup grip to select the height rather than have a stretch grip showing on the linear parameter. Place a lookup parameter somewhere near the top of the locker base frame that will be used to select the height. Double click on the lookup parameter and it will insert a lookup action and bring up the Property Lookup Table. Click on the Add Properties button and you will be given a selection of the various parameters that are available in the DB. We are only interested in the linear parameter for the height so select it and click OK. Back in the Property Lookup Table, click inside a row under the Height All Tier column and select 5′-0″. Click in the next row down and select 6′-0″. On the right side of the table, type in a description for the 2 types…60″ Tall and 72″ Tall respectively is what I used. Once that is done you can close the Property Lookup Table and rename the lookup action to something relevant. Figure 12 shows what the Property Lookup Table should look like for the lookup action that I named L-upH All Tier.

There is one more parameter/action that we can setup before introducing the visibility states and combining all the linework…the door flip. Place a flip parameter on the base frame starting at the top middle and extending down vertically. Once the parameter is set, you can move the arrow flip grip to any location that you like. I placed it in the center of the locker and will later include it in stretch actions so that it remains in the center regardless of the locker height. Next, place a flip action based on the previous parameter and select all the door handles and door swing lines as the selection set. Figure 13 shows the flip actions selection set. One limitation that you will discover when testing this block is that the door swing flip must be set before the lockers are arrayed since the flip parameter basepoint is based on the base frame.

At this point I’m going to bring in the visibility state parameter. I like to wait as long as possible to do visibility for a few reasons. One reason is that whenever you bring it in, everything that is in the block up to that point will start out visible in every state. By spreading everything out like we’ve done so far, I find it’s easier to select groups of items and make them invisible than it is to have everything together and try to select them. Also I like to make the parameter and action tags only visible in the states that they apply to. This makes things more comprehensible if it’s necessary to edit the DB at a later date.

Insert the visibility parameter and open up the Visibility States dialog box by clicking the Manage Visibility States button in the top right hand corner of the Block Editor Toolbar. This DB will have a total of 24 visibility states. There are four states for each locker style as can be seen in Figure 14. Set up each state by clicking the New button on the right hand side. Since everything up to this point will be visible in the default state, I set the visibility option for new states to remain unchanged.

Now that the visibility states are all named, we need to go back and setup the linework to show up in the states we want. Take a look at Figure 15 and notice that the visibility state is set to 1 Tier w/Both Ends in the upper right hand corner of the Block Editor Toolbar. Going left from the visibility state name are four buttons…Manage Visibility States, Make Invisible, Make Visible, and Visibility Mode. The Visibility Mode button will toggle between show all objects and show only objects on current state. It should be set to show all objects so we can see everything as we set up the visibility states. Since the current state is set to 1 Tier w/Both Ends, we need to make everything invisible except what is needed for 1 Tier w/Both Ends. Click the Make Invisible button and select the objects. Remember that the base frame and the parameters/actions up to this point will remain visible in all states. Figure 15 shows what should be current for this state. Go down through the list and set object visibility for each state. Figure 16 shows another example for the 5 Tier w/Right End state. When you get to the 6-tier states, remember that there is a seperate base frame and end sections for those states.

I mentioned earlier that one of the limitations of DBs was the fact that only one visibility parameter can be used. One of the workarounds for this issue is to create visibility states for every possible combination of items and then use lookup parameters to select the different states. Technically, this DB if fine with only the one visibility state but the possibility exists that I may add something in the future that would require additional state control. For that reason, we’ll go ahead and set up a lookup parameter for the visibility states now. First, hilite the visibility parameter and open the properties palette. Set the number of grips to 0 since we will use a lookup grip instead. Insert a new lookup parameter and place it on the bottom center of the locker frame. Double click the parameter as you did for the height lookup and the Property Lookup Table will open. Click the Add Properties button and select the visibility parameter. The procedure for setting up the table values is the same as what was done for the height lookup table. Figure 17 shows the completed Property Lookup Table. In this case, the lookup properties happen to be named the same as the input properties but you can assign any name you wish to the right side.

With visibility states out of the way we can now combine our linework and still be able to control what shows on the screen via the Visibility Mode button. Figure 18 shows the linework all combined over the base frame with the Visibility Mode set to show all. Since that is obviously too messy to work with, we can set Visibility Mode to show current and clean it up a bit. Figure 19 shows Visibility Mode at show current with the current state being 1-Tier. Notice that there is a pull-down icon in the upper right hand corner of Figure 19 where 1-Tier is displayed. This is a handy way to switch visibility states without having to open up the State Manager.

We still have some unfinished business with the height stretch action that needs to be taken care of now. When we change from 5’0″ high to 6′-0″ high lockers, there are other items that will have to change along with the overall height. These things would be door swing lines, handles, ventilation holes, and the size of the locker doors themselves. The single tier lockers are the simplest to do and only require one additional stretch action. Place a stretch action based on the height parameter and give it a name that you will recognize later. In this example, I named it StretchHCenter 1-2 Tier which translates to “stretch the center of single and double tier lockers based on the Height parameter”. Figure 20 shows the placement of the stretch frame as well as the hilited items in the selection set. Once that is done, select the stretch action and open the properties palette. In the Overrides tab, set the Distance Multiplier to .5. This will ensure that the handle and the center of the hinge line will always be 1/2 of the distance of the height parameter.

This process must be repeated for 2-5 Tier locker styles. 6-Tier lockers will not need this extra step since they are always 6′-0″ high. Since the process is similar for all styles, we’ll just run quickly through the first two steps for the 5-tier locker style.

Take a look at Figure 21 showing the properties for the stretch action named Stretch 5 Tier-1. Since there are five doors, each door will be 1/5 (.2) of the total height. The stretch frame for this action is set around the division between the first and second door and has the door frame and the door swing lines in the selection set. The distance multiplier is set to .2 for 1/5 of the total height. Similarly, the action named Stretch 5 Tier-2 would have its stretch frame set around the division between the second and third door and would have that frame and adjoining door swing lines as the selecton set. The distance multiplier would be set to .4 for 2/5 of the total height. Incidently, you don’t have to calculate the multiplier decimals yourself. Typing 1/5 in the properties box will calculate automatically to .2.

Now take a look at Figure 22 showing the properties for the stretch action named Stretch 5 TierC-1. These actions are similar but are now moving the door handle, ventilation holes, and the center of the door swing line. We’re now dealing with tenths so the distance multiplier for Stretch 5 TierC-1 is 1/10 or .1.

Continue on and set the stretch actions for all the styles. When finished, you should end up with something similar to whats pictured in Figure 23.

Earlier we set up a linear parameter for the width that hasn’t been put to use yet. We’ll do that now with an array action. Place an array action based on the width parameter and select all the locker styles as the selection set. Figure 24 shows the array action and the hilited selection set. Since we setup the width parameter properties earlier, that is all that needs done for the array action. However, we’re not done with the width parameter yet. As we array our lockers we need to move the right end sections along with that and we can do that with a simple move action. Place a move action based on the width parameter and select the items for both the 1-5 Tier and the 6 Tier right side sections for the selection set. Figure 25 shows the move action along with the hilited selection set. Look closely at Figure 25 again and you may notice a dirty little secret to this DB. There are some lines hilited that are part of the base geometry and not the right end geometry. These are 6″ long lines that are hidden under the main horizontal lines of the locker. These lines will be used later for the 6″ filler strip and must be moved along with the right side section. There are hidden lines on the left side also that will be used for the left side filler.

 

Moving on to the sloped top. We know that all the locker styles are available with either a flat top or a sloped top that is 4″ high. One way to take care of that would be with a visibility parameter to either show or not show the sloped top. But, since we’re fresh out of visibility parameters, we’re going to have to do a workaround. Take a look at Figure 26 and place a new linear parameter that starts at the top of the slope and goes down vertically 4″. In the properties palette for that parameter, set the Dist type to List and enter 4″ and 8″ in the Dist value list. We are going to stretch the sloped tops down and hide them under other linework that is the top of the locker. To do that, we are only interested in two dimensions in the linear parameter…4″=up and 8″=down. You’ll notice in Figure 26 that the linear parameter is actually moved 4″ up from the top of the 5′-0″ locker top. This was done so that the linear grip would be at the top instead of 4″ below the top. But, since I like to use lookups so much, set the number of grips for the slope parameter to 0.

We can now place the stretch actions needed for the slope tops. I say actions because we need one for the 1-5 Tier lockers and one for the 6 Tier. Study Figure 27 to see the stretch frame and selection set for the 1-5 Tier stretch action and Figure 28 for the 6 Tier. Continue on with a lookup parameter and action to select the slope top. The process is exactly the same as before except now you will select the slope parameter in the Add Properties dialog box and set up names for the 4″ and 8″ dimension. Figure 29 shows the lookup parameter and its property table.

In the home stretch now…just the filler strips to deal with and we’re home free. The filler strips are going to be done similar to the slope top except we can use a move action instead of a stretch. The left and right side fillers are done the same so I’ll only go through the left side here.

We are going to limit the amount of the filler on each side to be 6″ so start out by placing a linear parameter starting at the left center of the back of the left side and continuing for 6″ to the left. In the properties palette for the parameters, keep the Dist type set to none but enter 6″ for the Dist minimum and 1′-0″ for the Dist maximum and set the number of grips to 1. By keeping the Dist type set to none, we will be able to move the side section to any dimension between 6″ and 1′-0″. Now move the parameter 6″ to the right so that the grip is on the back of the locker section. Figure 30 shows these parameters in place.

Now place a move action based on the FillerL linear parameter with a selection set to include everything on the left side section. Dont forget to include the secret little 6″ lines that are hidden below the main locker body. Figure 31 shows the move action for the left side hilighted to show the selection set. If you look back at Figure 02 again, you’ll notice a second limitation to this DB. When you don’t have the side sections showing, the grips for the filler strips appear to be out in space. The filler strips can still be utilized but in order to snap them to a wall, you will have to offset the wall line by 12″.

Now comes the fun part…TEST! TEST! TEST! And when you get done testing the dynamic block, TEST it some more! It’s been my experience that most of the little problems with the dynamic blocks won’t show up until after it is released and used in production drawings so be prepared to troubleshoot them in the future.

While doing the initial testing, only some small maintenance issues should remain. For instance, you will need to go back and add the left and right ends to the original stretch action for the height. The sides for the 6-Tier lockers will not have to be added since they only appear in the 6-Tier visibility states.

That reminds me, I said earlier that I would explain why there was seperate linework for the 6-Tier lockers. This is really a personal pet peve because the 6-Tier lockers could actually be set up to utilize the base frame and be included in the height lookup. But, what happens is that the user could possibly set the lockers to display a 6-Tier configuration in the 5′-0″ height. Since this is not an available option I don’t want the possibility of it mistakenly being placed on any drawings. So why not add the height parameter to the Properties in the style lookup that would force the 6-Tier locker to always be displayed at 6′-0″ high? Because (and this is where the pet peve part comes in) then there would be possible conditions that would cause the lookups to show as “custom” when they are selected. Personally, I hate that and try to avoid it if at all possible. Not only is it irritating but it also takes away the ability to hilite a lookup grip to see what the block is currently set at.

So there you have it. Congratulations on getting through this rather lengthy tutorial on Dynamic Blocks. I hope that this tutorial has shown you not only the basics of DB parameters and actions but also some advanced techniques that can be applied to your future library. To see the Locker DB in action watch the short video below and see how quickly mundane tasks can be handled with a single Dynamic Block.

One thought on “Tutorial – Make a Dynamic Block for Lockers

  1. Pingback: Dynamic Block Tutorial - Cad Jedi

Leave a Reply