Customizing Toolbar Tools


Now let's move on to more serious customization. Suppose you want to create an entirely new button with its own functions. For example, you might want to create a set of buttons that will insert your favorite symbols. Or you might want to create a toolbar containing a set of tools that open some of the other toolbars that are normally "put away."

Creating a Custom Button

In the following set of exercises, you'll create a button that inserts a door symbol. You'll add your custom button to the toolbar you just created:

  1. Right-click any tool in a toolbar and choose Customize from the shortcut menu to open the Customize dialog box again.

  2. Make sure the Commands tab is selected, and then select the User Defined option at the bottom of the Categories list. The options in the Commands list will change to two items: User Defined Button and User Defined Flyout .

  3. Click and drag the User Defined Button option from the Commands list to your new toolbar. A blank space, which is actually a button, is added to your toolbar.

  4. Click the blank space in your new toolbar. The Button Properties tab is automatically selected in the Customize dialog box, and you see the properties of your new tool.

    click to expand

When you were first introduced to this tab, you saw the properties for the Distance and Line tools. Now you see User Defined Button in both the Name and Description input boxes, a blank icon in the Button Image group , and two ^C s in the Macro Associated With This Button input box. This tells you that the blank tool is waiting for you to add your own properties to it.

Now let's go ahead and add a macro to this tool:

  1. In the Name input box, enter Door . This will be your tool tip for this button.

  2. In the Description input box, enter Inserts a single door . This will be the help message for this button.

  3. In the Macro Associated With This Button input box, enter ^C^C “insert door .

Make sure you include the minus sign before insert . This indicates that you want to use the command-line version of the Insert command.

Tip  

You can put any valid string of keystrokes in the Macro Associated With This Button input box, including AutoLISP functions. See the Bonus Chapter 4 on the companion CD for more on AutoLISP. You can also include pauses for user input by using the backslash (\) character. See the "Pausing for User Input" section later in this chapter.

Note that the two ^C s already appear in the Macro Associated With This Button input box. These represent two Cancels being issued, which is the same as pressing the Esc key twice. It ensures that when the macro starts, it cancels any unfinished commands. If you don't need the two ^C s, you can delete them as in the case of transparent commands. You follow the two Cancels with the Insert command as it is issued from the keyboard.

Warning  

It is important that you enter the exact sequence of keystrokes that follow the command; otherwise , your macro can get out of step with the command prompts. This will take a little practice and some going back and forth between testing your button and editing the macro.

After the Insert command, there is a space, and then the name Door appears. This is the same sequence of keystrokes you enter at the command line to insert the door drawing you created in Chapters 2 and 3. You can go on to include an insertion point, a scale factor, and a rotation angle in this macro, but these options are better left for the time when the door is actually inserted.

Creating a Custom Icon

You have all the essential parts of the button defined. Now you just need to create a custom icon to go with your Door button:

  1. Take a look at the scroll box in the Button Image group containing the icons. Notice that a blank button is currently selected. It looks like a blank square box in the lower-left corner.

  2. Click the Edit button to open the Button Editor dialog box. The Button Editor is like a simple drawing program. Across the top are the tools to draw lines, circles, and points, as well as an eraser. Along the right side, you see a color toolbar from which you can choose colors for your icon. In the upper left, you see a preview of your button.

    click to expand
    Tip  

    If you prefer, you can use any of the predefined icons in the scroll box at the bottom of the Button Image group in the Customize dialog box.Just click the icon you want to use and then click Apply.

  3. Draw the door icon shown here. Don't worry if it's not perfect; you can always go back and fix it.

  4. Click Save and then click Close.

  5. In the Button Properties tab, click Apply. You'll see the icon appear in the button in your toolbar.

  6. Now click the Close button in the Customize dialog box.

  7. Click the Door icon on your new toolbar. The door appears in your drawing ready to be placed.

    Warning  

    The Door drawing must be in the default folder or in the Acad search path before the Door button will be inserted.

There are a number of other options in the Button Editor dialog box that you'll want to know about. Here is a listing of those options and their purpose:

Grid     Turns a grid on and off in the drawing area. This grid can be an aid in drawing your icon.

Clear     Erases the entire contents of the drawing area.

Undo     Undoes the last operation you performed.

Open     Opens a .bmp file to import an icon. The .bmp file must be small enough to fit in the 16 16 pixel matrix provided for icons (24 24 for large-format icons).

Save As     Saves your icon as a .bmp file under a name you enter.

Save     Saves your icon under a name that AutoCAD provides, usually a series of numbers and letters .

Close     Exits the Button Editor.

Help     Displays helpful information about the features of the Button Editor.

You can continue to add more buttons to your toolbar to build a toolbar of symbols. Of course, you're not limited to a symbols library. You can also incorporate your favorite macros or even AutoLISP routines that you accumulate as you work with AutoCAD. The possibilities are endless.

Now suppose you've decided that the Door tool is not what you wanted. Here's a quick way to clear the properties of a button:

  1. Open the Customize dialog box again. By now, you should know how to do this.

  2. Click the Door tool in your custom toolbar.

  3. Right-click the Door tool and then choose Reset from the shortcut menu.

Notice that the Button Properties settings revert to the previous settings when you first added the new tool. You can also reset the tool properties by clicking the Reset button in the lower-right corner of the Button Properties tab, but here I've shown you that right-clicking a button offers some additional options when the Customize dialog box is open.

The options in the shortcut menu you saw in step 3 are self-explanatory except for the Begin A Group option. This option adds a vertical bar to the toolbar to act as a visual divider between buttons. Let's see how this works:

  1. Right-click the blank tool in your custom toolbar and then choose Begin A Group. Notice that a vertical line now appears to the left of the button.

  2. Right-click the blank tool again. You now see a checkmark to the left of the Begin A Group option.

  3. Select Begin A Group again. The line disappears.

  4. You don't need a blank tool in your toolbar, so click and drag the blank tool into the drawing area to delete it. You then see a message asking whether you are sure you want to delete the user-defined button from your toolbar. Go ahead and click OK.

Setting the Properties of Flyouts

Just as you added a new button to your toolbar, you can also add flyouts. Remember that a flyout is really just another form of a toolbar. This next example shows how you can add a copy of the Zoom toolbar to your custom toolbar and then adjust the properties of the flyout:

  1. Click the Line tool in the toolbar you just finished to open the Customize dialog box at the Button Properties tab.

  2. Click the Commands tab and then click the User Defined option at the bottom of the Categories list.

  3. Click and drag the User Defined Flyout option from the Commands list box in the Customize dialog box to your custom toolbar.

You now have a blank flyout to which you can assign any existing toolbar. Let's see what options are available for flyout buttons:

  1. Click the blank flyout that you just added to your toolbar. You see a message telling you that you need to associate a toolbar with this flyout.

  2. Click OK. The Customize dialog box switches to the Flyout Properties tab. Notice that the Flyout Properties tab has replaced the Button Properties tab and that it contains a different layout.

    click to expand
  3. Scroll down the Toolbar Associated With This Flyout list and then select Zoom. You see a preview of the selected toolbar in the right side of the dialog box.

  4. Click Apply. The blank flyout you added to your toolbar changes to the Zoom flyout.

  5. Click the Close button to close the Customize dialog box.

    Tip  

    To delete a button from a toolbar, open the Customize dialog box and then click and drag the tool you want to delete away from the toolbar.

Now if you click and drag the flyout that you just added to your toolbar, you'll see that it contains the same Zoom tools found in the Standard toolbar.

So now you've seen how to create your own custom toolbar, and you've seen how to add new and existing tools. Although you used your own custom toolbar in these exercises, you can also add and remove buttons and flyouts to existing toolbars.

Tip  

If you want to delete a toolbar entirely, click the Toolbars tab in the Customize dialog box, select the toolbar from the Toolbars list, and then click the Delete button.

Creating Keyboard Shortcuts

The last feature that we'll explore in the Customize dialog box is the Keyboard tab. The Keyboard tab lets you create keyboard shortcuts for any tool, command, or menu option. AutoCAD already has a set of shortcuts that you see displayed in the pull-down menus , usually to the right of the menu option. For example, if you open the File menu from the menu bar, you see that the New option shows a Ctrl+N to the right. This means that, if you prefer, you can use the Ctrl+N keystroke combination to open the New File dialog box. You can add other Ctrl key shortcuts to other commands by using the Customize dialog box.

First, take a look at how the Ctrl+N keyboard shortcut option looks in the Customize dialog box. This will give you an idea of how to structure a custom keyboard shortcut.:

  1. Right-click any toolbar and choose Customize from the shortcut menu to open the Customize dialog box.

  2. Click the Keyboard tab.

    click to expand
  3. Select Acad from the Menu Group list box and then select New from the Commands list box. Notice that the Current Keys list box shows the Ctrl+N shortcut.

Next, try adding a shortcut to your custom toolbar:

  1. Select Custom from the Menu Group list. You see the two commands that you've added to your custom toolbar in the Commands list box.

  2. Select Arc Start End Direction from the Commands list.

  3. Click in the Press New Shortcut Key input box and then press Ctrl+D for Direction . Ctrl+D appears in the input box, but you also see a message just below the input box that warns you that Ctrl+D is already assigned to something (it controls the display of the coordinate readout).

  4. You don't want to redefine an existing shortcut so press the Backspace key to remove this shortcut.

  5. Press Ctrl+Shift+D. The Ctrl+Shift+D appears in the input box, and the message shows that the shortcut you've indicated is unassigned .

  6. Because you know that the Ctrl+Shift+D shortcut is unassigned, click Assign in the upper- right corner of the dialog box. The shortcut now appears in the Current Keys list box.

  7. Click Close and then press Ctrl+Shift+D. You'll see the Arc command start. You can then select points for the beginning and end of the arc, plus the arc direction.

  8. Place your cursor on the Arc Start End Direction tool in your custom toolbar (My Toolbar). It now shows the Ctrl+Shift+D option as part of the tool tip.

Shortcut keys are great for those options that you use frequently. Perhaps the most commonly used Windows shortcuts are Ctrl+C for Copy, Ctrl+V for Paste, and Ctrl+X for Cut. You won't want to redefine those shortcuts in AutoCAD because you might find them useful for copying, pasting, and cutting objects in AutoCAD.

start sidebar
The Windows Menu Files

AutoCAD stores all of the menu information in a set of files that you can look at on your computer. The standard AutoCAD menu is stored in the Acad.mns file, which is a plain-text file. You can open this file with a word processor and make changes to the AutoCAD menu system. In addition, a file called Custom.mns is offered for your custom options.

When you started the process of creating a custom toolbar earlier in this chapter, you selected Custom from the Menu Group list of the Customize dialog box. This tells AutoCAD to add your custom tools to the Custom.mns file, which is located in C:\Documents and Settings\ UserName \Application Data\Autodesk\ AutoCAD 2005\R16.1\enu\Support . If you keep your custom changes in a separate menu file, such as the Custom.mns file, you can more easily move your custom tools to other computers or future AutoCAD upgrades.

You also saw Acad and Express options in the Menu Group list of the Customization dialog box. By selecting Acad, you can make your custom modifications directly to the main AutoCAD menu system, which is stored in a file called Acad.mns . You will see a warning message if you attempt to add or delete custom items to the ACAD menu system, but you are not barred from doing so. The warning is there to remind you that preserving your custom changes might be difficult when you move to a different computer or upgrade AutoCAD.

After you create or change the menus by using the Customization dialog box, AutoCAD saves the changes in the Acad.mns or Custom.mns files, and then creates some additional files that it uses to streamline its menu access. Here's a brief rundown of those additional menu files for the Standard ACAD menu system:

Acad.mnu     One of the source text files that contains the information required to build the AutoCAD menu. If you are a programmer, you can use this file to customize the AutoCAD menu in detail. Here, you can edit the pull-down menus, image tiles, buttons, and so on. Most users won't have a need to edit this file.

Acad.mnc     AutoCAD's translation of the Acad.mns file described later in this list. AutoCAD translates , or compiles, the Acad.mns file so that it can read the menu faster.

Acad.mnl     AutoCAD's AutoLISP macro language offers an easy way to add functionality to AutoCAD. The Acad.mnl file contains AutoLISP code that is utilized by other parts of the ACAD menu system.

Acad.mns     A text file that is similar to the .mnu file with some additional comments. This file is rewritten whenever an .mnu file is loaded. If you make changes or additions to toolbars, you'll want to keep a backup copy of this file to preserve those changes. You can use the Acad.mns file as you would use an Acad.mnu file as a source text file to build the AutoCAD menu.

Acad.mnr     The menu resource file. This is a binary file that contains the bitmap images used for buttons and other graphics.

These descriptions show the files for the ACAD menus, but the Custom and Express menus also have similar files. For example, the Custom menus will have the files Custom.mnu , Custom.mns , Custom.mnc , and Custom.mnr . Express tools use files with the Acetmain filename prefix. As you create or edit icon buttons and toolbars, AutoCAD first adds your custom items to the Custom.mns , Acetmain.mns , or Acad.mns file. It then compiles this file into the .mnc and .mnr files for quicker access to the menus. If you reload the .mnu version of your menu, AutoCAD re-creates the .mns file, thereby removing any toolbar customization you might have done.

If you make changes to the ACAD menu system, you'll need to copy the Acad.mns file to other computers in order to transfer your custom buttons and toolbars. Also, if you create your own pull-down menu files, as in the Mymenu.mnu example in this chapter, AutoCAD creates the .mns source file and then compiles it and creates the resource files for your Mymenu file.

end sidebar
 

Several other shortcuts are also built into AutoCAD. Although you are creating shortcuts with the Customize dialog box, you can get a quick list of the existing shortcuts by clicking the Show All button in the Keyboard tab. The Shortcut Keys dialog box appears, listing all the existing AutoCAD shortcut keys that are currently active.




Mastering AutoCAD 2005 and AutoCAD LT 2005
Mastering AutoCAD 2005 and AutoCAD LT 2005
ISBN: 0782143407
EAN: 2147483647
Year: 2004
Pages: 261
Authors: George Omura

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net