Using AutoCAD's powerful tool palettes to your fullest advantage, Part 215 Dec, 2004 By: Lynn Allen Cadalyst
Use basic macros to create a customized masterpiece, then share it with other users
Last month we covered the basics of customizing those powerful AutoCAD tool palettes. If you need to catch up -- and so this sequel doesn't confuse you -- click here to link to last month's installment.
This month we're going to dive in a little bit more to ensure you become the office guru when it comes to all the little nuances in the world of tool palettes.
So far I've written about two methods of getting tools onto your tool palette -- from DesignCenter or from existing objects in your drawing. This month we'll take a look at two other methods -- from existing toolbars or from the Customization dialog box -- and we'll venture lightly into the world of macros.
Remember from Part 1 that Ctrl+3 will display the tool palette on your screen (in AutoCAD 2004 and 2005 only). You can launch the Customization command by keying in the word Customize or by right-clicking on any existing toolbar and selecting Customize from the shortcut menu.
We'll be using the Commands tab of the Customization dialog box (figure 1) to drag and drop AutoCAD commands to the palette. To make things easy on you, use the slider bar under Categories until you get to All Commands (which really should be conveniently located at the top of the list). All Commands lists all the possible commands you can place on a toolbar or tool palette. Search the list for the command you'd like to add to your tool palette and simply drag and drop it into place. For this example, select the Erase command from the list and add it to your palette.
Figure 1. Use the Commands tab of the Customization dialog box to drag and drop AutoCAD commands to the palette.
Let's take a look at the various properties you can modify (figure 2). The Name option controls the name that appears on the tool palette. The Description is the friendly tool tip that displays when your cursor hovers over the tool. I changed Erase to Erase Last, and my tool tip indicates that this command will erase the last object drawn. I will need to modify the programming behind this tool to get it to do exactly that -- so we'd better explore some macro basics.
Figure 2. Modifying properties in the tool palette.
Basic Macros for Customizing Tool Palettes
You don't need to be a programming expert to write some very powerful basic macros. The basic code is super simple, so anyone can create fantastic tools that will dazzle coworkers.
^C^C Cancel ; Enter \ Pause for user input - (dash) Force the command line version of a command
You will see ^C^C in front of most AutoCAD macros. This code will cancel any existing AutoCAD command that is active and send you back to the Command prompt so we can execute another command. We all know what happens when we are in one command and we try to execute a new one -- it just doesn't work! So we'll need to make sure when writing our macros that we get everyone to the command line first. Note: If you are executing a transparent command such as Pan or Zoom, you don't need to worry about canceling first, just use the apostrophe to drive its transparency.
If you want AutoCAD to execute an enter in your macro, simply use the semicolon. For example, below is the macro to define a Zoom Previous.
Zoom;p = Zoom (enter) P (enter)
AutoCAD will automatically add one enter to the end of any macro line that doesn't end in a semicolon, backslash (\), or plus (+) sign. If I wanted a macro to erase the last item on the screen:
^C^Cerase;L;; Cancel, erase (enter) L (enter) (enter)
Two enters at the end get the user all the way out of the Erase command and back to the Command line. I have to force it by including two semicolons.
Another crucial key character for menu macros:
\ Pause for user input
The following macro would draw a three-point circle:
^C^Ccircle;3P;\\\ Cancel, circle (enter) 3P (enter) pause pause pause
The triple pause at the end allows the user to select the three points of the 3P circle.
- execute the Command line interface of the command when placed in front of a command.
When writing macros, you'll need to use the Command line version of most commands because you can't talk to a dialog box. So you'll need to dust off those old commands you are now programmed to use via dialog boxes, such as Layer, Insert, Array, and so forth.
Cancel, command line version of the Insert command (enter) bolt (block name) (enter) pause for insertion point enter enter pause for rotation angle
This lets the user pick where the bolt should go, enter for an X scale factor of 1, enter for a Y scale factor of 1, pause so the user can determine the rotation angle.
One more character you won't need to use unless you become quite the pro, but will see in the AutoCAD menus, is the underscore (_). This placed in front of a command or option will force the English source command. You only need to worry about this should you decide to write your menus for use in multiple languages!
So that's the Cliffs Notes version of menu macros. You can include your menu macros in your tool palettes for optimal customization. I have a Revcloud tool that creates a red revcloud using the new Calligraphy option, with specific arc sizes (figure 3). This function saves me many steps whenever I use it.
Figure 3. My tool palette includes a customized Revcloud tool with color and calligraphy.
Exporting Tool Palettes for Other Users
So what happens when you create the ultimate in tool palettes and you want to share them with someone? You can export each of the tabs in your tool palette to an XTP file. This is done in the Tool Palettes tab of the Customization dialog box (figure 4). Select the tab you wish to export, then right-click to select Export from the shortcut menu.
Figure 4. Use the Tool Palettes tab of the Customization dialog box to export tabs in your tool palette to an XTP file.
You may also notice that you can group your tool palettes for maximum organization. This makes it easy to switch the tabs in your tool palettes for different projects. Right-click to select New Group from the shortcut menu. Name your group and simply drag the intended tabs into the proper group. It's easy to swap the palette groups by selecting the lower right corner of the tool palette bar (figure 5).
Figure 5. Swap the palette groups by selecting the lower right corner of the tool palette bar.
You can also control the icon that displays on your tool palettes by right-clicking on the existing image in the Properties dialog box and selecting an alternate image. AutoCAD accepts JPG, BMP, PNG, TIF, and GIF files. I have a lovely picture of my dog Alex on my tool palette! You can also use the laborious Button Editor in the Customization dialog box to design your own primitive icon. (Can you tell I don't care for the Button Editor?)
If you are a CAD manager and want to limit the ability of others to customize the tool palettes, the new Tbcustomize command will disable the Customization dialog box and prohibit your users from adding to the existing tools via the Customization dialog box. Of course, if they know the magic words, they can easily turn the dialog box back on using the Tbcustomize command. You can also place a read-only attribute on the folder that holds your toolbars -- much more secure. This will prohibit anyone from deleting existing tools, and any changes made will only be valid for the current AutoCAD session. They will reset back to their original toolbars the next time the user executes AutoCAD. The Files tab of the Options dialog box has a setting that displays the location of your current tool path folder.
I hope this mini-tutorial on tool palettes has inspired you to give this powerful feature a good college try! Before you know it, you'll become a tool palette junky just like I am. Until next month, Happy AutoCAD-ing!
In her easy-to-follow, friendly style, long-time Cadalyst contributing editor 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!