Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
Книги_AutoCad_2 / AutoCAD 2006 and AutoCAD LT 2006 Bible_2004г__.pdf
Скачиваний:
142
Добавлен:
09.04.2015
Размер:
17.83 Mб
Скачать

Chapter 29 Customizing Commands, Toolbars, and Tool Palettes

949

 

The FILEDIA system variable determines whether a dialog box opens for commands, such

 

as SAVEAS and OPEN, that request file names. When FILEDIA is set to 1, the default dialog

 

boxes open.

Note

Even if FILEDIA is set to 1, if a script or AutoLISP/ObjectARX program is active, the command

 

prompt is used instead of a dialog box. You can still set the FILEDIA system variable to 0, but

 

be sure to change it back again at the end of your script or program. (Scripts are available in

 

AutoCAD LT, but not AutoLISP or ObjectARX programs.)

Documenting your files

Placing comments in customized files to explain how you customized them is standard practice. Although your customizations may seem obvious at the time, if you go back to a file later, you may not understand what you were trying to accomplish. Also, other people may need some explanation.

You can place comments in many of the customizable files by placing a semicolon (;) before any line of text.

Now that you know the basics of customizing files, you can move on to creating keyboard shortcuts and customizing toolbars.

Creating Keyboard Shortcuts for Commands

You can create keyboard shortcuts for commands, thereby enabling you to enter commands on the command line without remembering and typing the full command name. Shortcuts are stored in the acad.pgp file for AutoCAD and the aclt.pgp file for AutoCAD LT. You can use this file for three purposes:

To create shortcuts to Windows programs (AutoCAD only)

To create shortcuts to DOS commands (AutoCAD only)

To create keyboard shortcuts for AutoCAD and AutoCAD LT commands

The new auto-complete feature completes commands that you start to type in the dynamic input tooltip or on the command line. Type as many letters as you know, and then press Tab to cycle through all of the commands that start with those letters.

Cross- You can also create keyboard shortcuts, such as Ctrl+G or F11, for commands. See Chapter Reference 33 for more information. The shortcuts in acad.pgp and aclt.pgp use only letters and

numbers.

Creating shortcuts to Windows programs

In AutoCAD, you can use the acad.pgp file to create shortcuts to Windows programs. For example, you may often open Notepad while customizing files. The acad.pgp file includes the following three shortcuts to Windows programs:

EXPLORER,

START EXPLORER,

1,,

NOTEPAD,

START

NOTEPAD,

1,*File to edit: ,

PBRUSH,

START

PBRUSH,

1,,

950 Part VI Customizing AutoCAD

The AutoCAD LT aclt.pgp file does not include shortcuts to Windows programs.

The first column is the command name that you type at the command line. The second column is the command that you want Windows to execute. The number 1 specifies to start the application but not to wait until you’ve finished using it. This lets you return to your drawing at any time. After the 1, you can finish with two commas. However, notice that the Notepad entry has *File to edit: before the last comma. This is a prompt that you see on the command line. Type the name of the file to edit, and Windows opens it in Notepad. (You need to type in the complete path of the file.) To open Notepad without a file, press Enter at the *File to edit: prompt.

Creating keyboard shortcuts to commands

Most of the acad.pgp or aclt.pgp files contain aliases, or keyboard shortcuts, for common commands. You can change these or add your own. After you become used to them, it’s often faster to type shortcuts at the command line than to click the toolbar button or menu item, especially if your hands are already on the keyboard. You cannot include a command option in the acad.pgp file. To do that, you need to create a menu item, toolbar button, or AutoLISP routine.

The Express Tools contain an Alias Editor that enables you to edit the acad.pgp file through a dialog box interface. Choose Express Tools Command Alias Editor.

On the

Quickkey is an expanded replacement for acad.pgp that supports commands with their

CD-ROM

options, such as ZOOM Previous. Look in \Software\Chap29\Quickkey.

The format for creating an alias is as follows:

Shortcut,*Full command name

Refer back to Figure 29-1 for some examples of shortcuts. Note that the space between the columns is not necessary — it simply improves readability.

Note

The acad.pgp and aclt.pgp files contain a special User Defined Command Aliases section at

 

the end for creating your own aliases. Aliases in this section override aliases in the main section.

You can use aliases transparently if the command itself can be used transparently. Aliases cannot be used in script files or menus. Note that you cannot use control or function keys in command aliases in the PGP file.

Caution

If you’re working on someone else’s computer, don’t do the following exercise without that

 

person’s permission. It isn’t good computer etiquette to modify other people’s files without

 

asking first.

Chapter 29 Customizing Commands, Toolbars, and Tool Palettes

951

STEPS: Customizing the acad.pgp File

1.Start AutoCAD or AutoCAD LT.

2.Place a blank disk in your floppy disk drive. Do one of the following:

If you have AutoCAD, type explorer . After opening a preliminary window, the acad.pgp shortcut opens Windows Explorer.

If you have AutoCAD LT, open Windows Explorer by right-clicking the Windows Start button and choosing Explore.

Note

To find the location of acad.pgp or aclt.pgp, choose Tools Options and click the Files

 

tab. Double-click Support File Search Path to display the location of the support files.

3.Find acad.pgp or aclt.pgp, click it, and drag it to the drive (in the Folders window) that contains your floppy disk. Windows copies acad.pgp or aclt.pgp to the disk. If you haven’t already backed up your other customizable files, copy acad.lin, acad. lsp, acad.mln, acad.mnl, acad.mnu, and acad.pat to the disk as well, if you’re using AutoCAD. If you’re using AutoCAD LT, back up the aclt.lin, aclt.mnu, and aclt.pat files. (If they don’t fit, you may need to use two disks or a CD-ROM.) Remove the disk and label it “AutoCAD or AutoCAD LT customizable files — original form.”

4.In AutoCAD or AutoCAD LT, choose Tools Customize Edit Program Parameters to open acad.pgp or aclt.pgp.

5.In AutoCAD only, scroll down roughly two screens until you see the three Windows commands, as shown in Figure 29-2. Place the cursor at the end of the PBRUSH line and press Enter.

Figure 29-2: The Windows commands in the acad.pgp file.

6.In AutoCAD only, type the following and press Enter (the uppercase format and spaces are used to match the format of the rest of the file):

WORDPAD, START WORDPAD, 1,,

7.Look at the next section of acad.pgp or aclt.pgp. Read the guidelines for creating new aliases.

8.Scroll down until you see the following two lines:

CH, *PROPERTIES -CH, *CHANGE

The alias for the CHANGE command follows the guideline of using a hyphen to distinguish command-line versions of commands. Suppose you have trouble finding that hyphen quickly (you end up typing =ch instead). You want to change the alias to cg (with no hyphen).

952 Part VI Customizing AutoCAD

On the

CD-ROM

9.Scroll down to the end of the file until you see the User Defined Command Aliases section. Place the cursor at the very end of the file and press Enter. Type the following and press Enter (don’t worry about the spaces; I’ve matched the spacing of the acad.pgp or aclt.pgp file):

CG, *CHANGE

10.Choose File Save.

11.Close Notepad. Generally, acad.pgp or aclt.pgp is accessed only when you load a new

or existing drawing. However, you can use the REINIT command to reload the file at any time. Type reinit . The Re-initialization dialog box opens, as shown in Figure 29-3.

Figure 29-3: The Re-initialization dialog box.

12.Check the PGP File check box and click OK. In your drawing, draw any line.

13.Type cg . The CHANGE command starts. Select the line, right-click to end selection, and pick a new endpoint location. The endpoint of the line changes accordingly.

14.Do not save your drawing.

The edited acad.pgp file is on the CD-ROM in the Results folder. Although you made only two changes, if you want, you can copy the acad.pgp file from the CD-ROM over your original acad.pgp file. Of course, you can make additional changes to suit your needs.

Customizing Toolbars

In the Windows environment, you frequently find yourself using toolbar buttons for many of your tasks. Nevertheless, how many times have you found yourself typing a command because you couldn’t quickly find an equivalent button on a toolbar, or because it was on a flyout that was too annoying to deal with? In addition, think of how often you start a command with a toolbar button, only to return to the keyboard to type in a simple option.

You can customize the toolbars to make your work easier and faster. You can create new toolbars from scratch, or edit existing ones. You can even create your own toolbar buttons. When you create a toolbar button, you can attach any sequence of commands to it, such as a complex macro or even an AutoLISP expression (for AutoCAD only).

Using the Customize User Interface dialog box

The new Customize User Interface dialog box (choose Tools Customize Interface, or type cui ), shown in Figure 29-4, combines all of the tools that you need to manage toolbars. You can create new toolbars, delete toolbars, and customize existing toolbars.

Chapter 29 Customizing Commands, Toolbars, and Tool Palettes

953

Figure 29-4: The Customize User Interface dialog box with the Toolbars item selected.

Cross-

Reference

The Customize User Interface dialog box controls customization of many aspects of the user interface. When you make a change and click Apply or OK, all aspects of the interface are updated, including the new Workspaces feature, which provides a way to create and save multiple interface displays. Therefore, you may find various toolbars and palettes suddenly open when you return to your drawing. To learn how to control workspaces, see Appendix A.

Removing buttons from an existing toolbar

You can customize any existing toolbar by removing buttons that you rarely use. To remove buttons from a toolbar, follow these steps:

1.Choose Tools Customize Interface to display the Customize User Interface dialog box.

2.In the Customizations In pane, with All Customization Files selected in the drop-down list, double-click the Toolbars item to expand the list of all of the toolbars.

3.Double-click the toolbar that you want to work with to expand its list of buttons.

4.Right-click the button that you want to delete, and choose Delete from the shortcut menu.

Creating a new toolbar

You may want to create your own toolbar from scratch that contains buttons for commands that you use often. To avoid changing the main menu, you should use the custom.cui file. This file is a separate partial customization file. Using a partial customization file helps you to keep your customization files separate from the standard menu file (acad.cui or aclt.cui). For more information on partial customization files, see Chapter 33.

954 Part VI Customizing AutoCAD

 

To create a new toolbar, first choose custom.cui from the drop-down list at the top of the

 

Customizations In pane of the Customize User Interface dialog box. Then right-click the

 

Toolbars item and choose New Toolbar.

Tip

You can also create a new partial customization file. On the Transfer tab of the Customize User

 

Interface dialog box, choose New from the Customizations In drop-down list. From the drop-

 

down list, choose Save As. In the Save As dialog box, name the new file. Make sure that you

 

use a name that is different from all other CUI files. To use the file, go to the Customize tab and

 

choose Main CUI File from the drop-down list in the Customizations In pane. Then click the

 

Load Partial Customization File button to the right of the drop-down list. In the Open dialog

 

box, locate the partial CUI file and click Open. Again choose Main CUI File from the drop-down

 

list. You should now see the new file listed under the expanded Partial CUI Files item.

 

A new toolbar appears under the Toolbars item, called Toolbar1. You can immediately

 

rename this toolbar or right-click it and choose Rename.

 

Your toolbar now appears in the Toolbars list of the Toolbars dialog box. If you click Apply, a

 

small, new toolbar appears on the screen, as shown in Figure 29-5.

Figure 29-5: The new toolbar shown in the Toolbar list and on the screen.

The new toolbar is just a baby, but as you add buttons to it, it grows automatically.

Adding buttons

If you’ve created a new toolbar, you need to add buttons to it. One method is to add a command from the Command List pane of the Customize User Interface dialog box. Follow these steps:

1.In the Customizations In pane, double-click the Toolbars item to expand the list of toolbars.

Chapter 29 Customizing Commands, Toolbars, and Tool Palettes

955

2.Select the toolbar that you want to work with.

3.From the Categories drop-down list of the Command List pane, choose All Commands or a category that displays the command that you want to add.

4.Drag the command from the list to the toolbar item in the Customizations In pane until you see an arrow pointing to the toolbar, as shown in Figure 29-6.

Figure 29-6: To add a button to a toolbar, you can drag a command from the Command List to a toolbar in the Customize User Interface dialog box.

 

You can also move a button from one toolbar to another. In the Customize User Interface

 

dialog box, expand the toolbar that contains the button that you want to move. Then drag the

 

button to your new toolbar or to any other toolbar. This moves the button, deleting it from

 

the original toolbar.

 

To copy a button from another toolbar, use the same technique as for moving a button, but

 

hold down the Ctrl key as you drag a button from one toolbar to another toolbar. This proce-

 

dure leaves the first toolbar intact.

Tip

To help organize your toolbars, you can add separator spaces. With the toolbar expanded, right-

 

click the button above where you want to add the space and choose Add Separator. You can

 

also drag buttons up or down to change their order.

Creating your own button definition

You can also create your own button definition from scratch. Follow these steps:

1.In the Customizations In pane, double-click the Toolbars item and choose the toolbar that you want to work with.

956 Part VI Customizing AutoCAD

Cross-

Reference

Caution

2.In the Command List pane, click the New button. The Properties pane shows the properties of the new toolbar button, as shown in Figure 29-7.

Figure 29-7: You define a toolbar button in the Properties pane of the Customize User Interface dialog box.

3.In the Name text box, replace the default name (Command1) with your own name for the button. This name appears as a tooltip, so don’t make it too long.

4.Type a helpful description in the Description text box. This text appears on the status line to further explain the function of the button.

5.Write the macro in the Macro text box. The ^C^C cancels any other command that may be active when you use the button. After that, place any valid menu command string as it would be typed on the command line, or even an AutoLISP expression (for AutoCAD only).

You should use menu syntax for the macro. I explain the details of creating command strings in Chapter 33, where I cover customizing menus.

6.From the Categories drop-down list, choose Custom Commands. Drag the new command onto a toolbar.

Always drag a new custom command onto a toolbar before assigning an icon to it. Assigning an icon to a command that is not on a toolbar corrupts the customization file.

7.Select the button in the Customizations In pane. In the Button Image pane, choose a button icon from the list of button icons, or choose Edit to create your own button, as explained in the next section.

8.Click Apply and click the OK button of the Customize User Interface dialog box to close it.

Tip

To check the results of your customization before closing the Customize User Interface dialog

 

box, click Apply and then move the dialog box so that it doesn’t cover the new toolbar. If you are

 

satisfied, click OK to close the dialog box.

Chapter 29 Customizing Commands, Toolbars, and Tool Palettes

957

Using the Button Editor

The Button Editor, shown in Figure 29-8, enables you to make your own button icons. In the Customization In pane of the Customize User Interface dialog box, select the toolbar command that you want to work with. Open the Button Editor by clicking Edit in the Button Image pane of the Customize User Interface dialog box. You can choose one of the provided buttons and edit it — which I recommend — or start from scratch if you have artistic tendencies.

Figure 29-8: The Button Editor.

The center of the editing area shows an enlarged view of the button. You see the button’s actual size at the top-left corner of the dialog box. Check the Grid check box to show a grid of pixels — this is just a drawing aid. Choose a color from the color palette and then choose one of the four tools at the top of the dialog box:

The Pencil tool draws any shape. To draw, click anywhere to draw pixel by pixel, or drag across the editing area.

Click and drag the Line tool to draw a straight line.

The Circle tool draws circles and ellipses. You click the center and drag out to the circumference to indicate the radius.

The Erase tool erases. You can click to erase pixel by pixel, or drag to erase a series of pixels.

Here are the other features of the Button Editor:

Click Clear to clear the editing area and start from scratch.

Click Open to open an existing button for editing. Button icons are stored as BMP files.

Click Undo to undo your most recent action.

Click Save As to save an existing BMP file under a new name. If you create a new (or edited) button, use the Save As button and remember where you saved the BMP file. The default is the main Support File Search Path location, which you can find on the Files tab of the Options dialog box (Tools Options).

Click Save to save the button icon as a BMP file. The default file name is ICON.bmp.

958 Part VI Customizing AutoCAD

Click Close to close the Button Editor.

Click More to select a standard index color or true color. (True colors are available in AutoCAD only.)

If you edited an existing button and saved the changes, then you’re done. However, if you saved your button image under another file name (using the Save As button), you need to associate the new file name with the toolbar button. In the Properties pane, click the Small Image text box, and then click the Ellipsis (. . .) button. Browse to the BMP file and choose it. Click Open. The file location appears in the Small Image text box. You can now click Apply, or if you want to return to your drawing, click OK.

If you think you might ever want to display large toolbar buttons, do the same for the Large Image text box. By default, when you create a button image, the Both option button is selected in the Button Image section, and so you create both a small and a large image. To display large toolbar buttons, choose Tools Options and click the Display tab. In the Window Elements section, check the Use Large Buttons for Toolbars check box.

Creating flyouts

You can use the Customize User Interface dialog box to create your own flyouts, or you can use one of the existing flyouts. To use an existing flyout, you just drag one toolbar onto another one. Expand the Toolbars item in the Customizations In pane. Then expand the toolbar that you want to work with. In the same pane, locate the toolbar that you want to turn into a flyout, and drag it to any location on the expanded toolbar.

To create your own flyout from scratch, follow these steps:

1.Expand the Toolbars item in the Customizations In pane.

2.Right-click any toolbar and choose New Flyout.

3.Right-click the new flyout (named Toolbar1 by default) and choose Rename. Type a name for the flyout.

4.From the Command List pane, drag commands to the flyout, using the same technique as described in the “Adding buttons” section earlier in this chapter.

The following exercise loads a partial customization file on top of the main customization file. After the exercise, I explain how to undo the changes if you want. If you’re working on someone else’s computer, don’t do this exercise without that person’s permission. I explain more about main and partial customization files in Chapter 33.

STEPS: Customizing Toolbars

1.Open Windows Explorer. Copy acad.cui (for AutoCAD) or aclt.cui (for AutoCAD LT) to a floppy disk, a CD-ROM, or your AutoCAD Bible folder as a backup. If you don’t do this step, you won’t have a way to undo the changes that you make to the menu file.

Note

To find the location of these files, choose Tools Options and click the Files tab. Double-click

 

the Customization Files item, and then double-click the Main Customization File item to dis-

 

play the location of the menu file.

2.Start a new drawing using any template. Save the file as ab29-01.dwg in your AutoCAD Bible folder.

3.Choose Tools Customize Interface to open the Customize User Interface dialog box. You should see All Customization Files in the drop-down list. Double-click the Toolbars item to expand it. Scroll down, and double-click the Zoom toolbar to expand it.

Chapter 29 Customizing Commands, Toolbars, and Tool Palettes

959

Note

Tip

4.To delete a button from the Zoom toolbar, right-click the Zoom Center button (or the button that you use least) and choose Delete. Confirm the deletion. Note that you can preview the results in the Preview pane by clicking the toolbar name. Double-click the Toolbars item again to collapse it. Click the Save All Current Customization Files button to the right of the drop-down list.

5.To create a new toolbar, start by creating a new partial customization file. Click the Transfer tab of the Customize User Interface dialog box.

6.From the drop-down list in the Customizations in Main CUI (left) pane, choose New. From the drop-down list, choose Save As. In the Save As dialog box, type ab29-01 in the File Name text box and click Save. (This saves the file in the Support folder, which is the default location for CUI files.)

7.To load the new partial customization file, ab29-01.cui, click the Customize tab. Make sure that All Customization Files shows in the Customizations In pane’s drop-down list. If it doesn’t, choose it. To the right of the drop-down list, click the Load Partial Customization File button. In the Open dialog box, choose ab29-01.cui and click Open. You see the file name in the drop-down list.

You may see a warning that workspace information in partial CUI files is ignored. This file doesn’t have any workspace information in it, so click OK. I discuss workspaces in Appendix A.

8.To check that the new partial CUI file is loaded along with the main CUI file, choose Main CUI File from the drop-down list. Double-click the Partial CUI files item. You should see ab29-01 on the list.

9.In the Customizations In pane, choose All Customization Files from the drop-down list. Double-click the Partial CUI Files item and then double-click the AB29-01 item. Right-click the Toolbars item and choose New Toolbar. Type Special and press Enter. (If the toolbar name is not selected and editable, right-click the new toolbar and choose Rename. Then enter the new name.)

10.From the Command list drop-down list, choose All Commands. Find the Donut item and drag it to the new Special toolbar. You should see a left-pointing arrow when you have dragged the command onto the toolbar.

11.From the Categories drop-down list in the Command List pane, choose the Modify category and find Polyline. (This is the PEDIT command.) Drag it to your new toolbar.

To find a command in the long list, you can click any command and type the first letter of the command you want. The list jumps to the first command with that letter. You can then scroll down and quickly find the command you want.

12.With All Commands displayed in the Categories List, drag the HIDE command to the toolbar.

13.To create a custom command, click the New button to the right of the Categories dropdown list. You see the new command listed as Command1 in the Properties pane.

14.Complete the Properties pane as shown in Figure 29-9. Type the macro as follows after the ^C^C (which is already there), being careful to also include the spaces:

pedit \w .1 ;

15.Select the Special toolbar item. From the Categories drop-down list, choose Custom Commands. Drag the pline_tenth command to the Special toolbar.

960 Part VI Customizing AutoCAD

16.With the pline_tenth button selected, in the Button Image pane, click the PEDIT icon. (It looks similar to the icon in Figure 29-10.) Then choose Edit to open the Button Editor.

Figure 29-9: The completed Properties pane for the custom command.

17.You want to change the button so that it looks as if a zero-width polyline is being changed to a wider polyline, because that’s what the macro does. Click the red color. Choose the Pencil tool (by default, it is already chosen). Click the Grid check box to help you work. Click (or drag) the point of the Pencil tool in each box, using Figure 29-10 as a guide. (Figure 29-10 shows the button in black and white.) When you’re done, click Save.

18.In the Create File dialog box, type pline_tenth in the File Name text box and click Save. (Note that the file is saved in the Support folder by default. You can find this path by choosing Tools Options, clicking the Files tab, and double-clicking the Support File Search Path item.) Click Close.

Figure 29-10: You can create a new button in the Button Editor.

Chapter 29 Customizing Commands, Toolbars, and Tool Palettes

961

Tip

Note

If you make a mistake, it’s easy to correct it. If you place a red pixel over an existing black pixel, choose black and redraw the black pixel. If you place a red pixel in a wrong spot, choose the Erase tool and click the pixel.

19.To assign the icon to the button, in the Properties pane, click the Small Image item, and then click the Ellipsis button to the right. Browse to the Support file where you saved the icon file. Choose pline_tenth.bmp and click Open. (If you are using large icons, use the Large Image item instead, or assign the icon to both.)

20.Click Apply. If necessary, move the dialog box so that you can see the new toolbar. If it seems okay, click OK to close the Customize User Interface dialog box. (If not, continue to make changes in the dialog box.)

If you don’t see the toolbar when you close the Customize User Interface dialog box, rightclick in any empty toolbar area (off all toolbars) and choose AS29-01 Special to display the toolbar.

21.Choose Polyline from the Draw toolbar and draw any series of polyline segments. Choose the Pline_tenth button from the new toolbar. At the Select polyline or [Multiple]: prompt, pick the polyline. Its width changes to 0.1. (If it doesn’t work, return to the Customize User Interface dialog box and check the macro.)

22.Save your drawing.

Here’s how the pedit macro that you used in the previous exercise works:

pedit \w .1 ;

1.Pedit issues the PEDIT command. The space after pedit is equivalent to pressing Enter after you’ve typed the command on the command line. The PEDIT command then displays the Select polyline: prompt.

2.The backslash (\) is a special character that pauses the macro for your input. When you select the polyline, the macro continues, displaying the Enter an option [Close/Join/ Width/Edit vertex/Fit/Spline/Decurve/Ltype gen/Undo]: prompt.

Undoing Toolbar Changes

To undo the changes that you made, you need to take two steps. To unload the partial customization file, right-click it in the Customize User Interface dialog box and choose Unload. Confirm the decision. This file is separate from the main customization file, and so it doesn’t affect the main customization file directly.

To undo the changes that you made to the main customization file (acad.cui or aclt.cui), you need to copy the original file over the new one. To find the location of this file, choose Tools Options and click the Files tab. Double-click the Customization Files item, and then double-click the Main Customization File item.

Close AutoCAD. In Windows Explorer, locate the backup copy that you made in Step 1 of the previous exercise. Expand the location of the current main customization file. Press Ctrl and drag the backup file to the current file of the same name.

When you open AutoCAD again, it will load the backup copy of the main customization file.

Соседние файлы в папке Книги_AutoCad_2