Chapter 3. Customizing the AutoCAD Interface

You may be working in an office that's conservative about upgrades, and probably for good reason. Because of the fairly recent introduction of the Customizable User Interface (CUI) in AutoCAD 2006, this chapter will contain some sections that apply to most releases, but others that apply only to AutoCAD 2006 and later.

Why should you bother to customize AutoCAD's interface? There are three primary reasons:

  • To make yourself more efficient

  • To encourage the use of office standards

  • To create linetypes that don't already exist in AutoCAD

Efficiency comes from eliminating some steps in using AutoCAD commands and reducing the clutter of toolbars and tool palettes that contain tools you never use. How about making your own toolbar? And while you're at it, how about creating personal commands that eliminate mindless repetition? If you haven't done any customizing before, you'll be surprised at how much easier it is to work when you've streamlined AutoCAD. Face it: We're all a bit lazy, so every little thing that keeps us from working hard is welcome. Sometimes I think the best AutoCAD users are the lazy ones.

In this chapter, I'm covered the areas I think give you the biggest return on your investment of customizing time. Take a look, and I'm certain you'll find something in this chapter that makes the time spent customizing worthwhile.

  • Tool Palettes

  • Menus

  • Accelerator Keys

  • Custom Linetypes

Tool Palettes (All Releases)

Tool palettes began as a place to store blocks and hatch patterns, but they eventually evolved into a useful system for organizing tools and content that you use regularly, including Lisp programs and commands. I particularly like them as a way of organizing and accessing groups of block definitions.

Tool palettes are also an excellent means of helping people enforce standards in an office, because you can set the properties of anything on a tool palette, including the layer it uses when you select it. Don't get too carried away with tool palettes—they're useful only if you streamline them enough that you can easily find what you want. If you create a lot of tool palettes, consider using the group function to combine related palettes into groups.

Note

Open the Tool Palettes window from the command line (TOOLPALETTES or TP), from the menu (Tools → Palettes → Tool Palettes), or by pressing Ctrl+3.

Tool Palettes (All Releases)
Block reference to a source file

Figure 3.1. Block reference to a source file

It's important to remember that tool palettes contain references to a wide variety of AutoCAD operations, all of which are known as tools. A block reference on a tool palette is a reference to a block definition in a saved drawing file. If you move or rename the drawing that contains the block definition, you break its connection to the tool palette. Figure 3.1 shows the Tool Properties dialog box that results from right-clicking the Limit Switch-Imperial block reference. The Source File field contains the name and location of the drawing in which the block definition resides. The block isn't defined in your drawing until you insert one of the block references from a tool palette.

In this section, I'll discuss the specifics of placing block references, creating new tool palette groups, changing the properties of the tools on a tool palette, adding new tools to tool palettes, and exporting tool palettes. Let's get to it.

Adding Block References to a Tool Palette

One of the most powerful features of tool palettes is the ability to create a palette that contains references to all the block definitions in a single reference drawing. Because you undoubtedly already have one or more symbol library drawing files, let's start there. Most of you have a set of sample files that were copied into the C:Program FilesAutoCAD 2008SampleDesignCenter folder during the default installation. I'll use the blocks defined in one of those files—Landscaping.dxf—for this example, so the resulting tool palette is named Landscaping. The following steps walk you through a number of things you can do with tool palettes:

  1. Start DesignCenter (DC, Tools → Palettes → DesignCenter, or Ctrl+2).

  2. Navigate through the folders list to find a file that contains the block definitions you want on a tool palette.

    Note

    You can obtain content from any drawing file (DWG), template file (DWT), Drawing Interchange File (DXF), or even standards file (DWS).

  3. Right-click almost anywhere on the AutoCAD DesignCenter (ADC) palette, and select the menu option Create Tool Palette (see Figure 3.2). AutoCAD automatically creates a single new tool palette that contains all the block definitions in that drawing.

Creating New Groups for Tool Palettes

It's easy to create a new tool palette containing all the block definitions in a symbol-library drawing—so easy that it probably makes sense for you to create one for each of your symbol drawings. You may notice that AutoCAD 2007 displays a lot of long tool palettes. To reduce the clutter on the screen, you can make a new group for the tool palettes you're creating and turn off all the others. Here are the steps:

  1. Open the Customize dialog box by right-clicking an empty area of the tool palette and selecting Customize Palettes (see Figure 3.3).

  2. Right-click in an empty area of the Palette Groups pane, and select New Group to create a group for your new tool palette (see Figure 3.4). Name this new group Sybex.

    Adding block definitions to a tool palette

    Figure 3.2. Adding block definitions to a tool palette

  3. Select the name of a tool palette that you want to make part of a group. Hold down the left mouse button while you drag the tool palette into position under the group name; drop the tool palette by releasing the left mouse button. A horizontal black bar shows you where the palette will be placed in the group list. This adds your new tool palette—in this case, Landscaping—to its own group so you can turn off the default tool-palette groups that come with AutoCAD 2007 (see Figure 3.5).

    Customize Palettes

    Figure 3.3. Customize Palettes

    Creating a new palette group

    Figure 3.4. Creating a new palette group

    Adding a tool palette to a group

    Figure 3.5. Adding a tool palette to a group

  4. Close the Customize dialog.

  5. Right-click the title bar of the tool palette, and select only your new group for display. Doing so turns off the 30 tool palettes that ship with AutoCAD 2007. (See Figure 3.6.)

Changing the Properties of Tools on a Palette

Now that you have a new palette that contains block references, let's control the properties that one of those blocks has when inserted into a drawing. For this example, use the block named Tree - Deciduous Plan. The tree symbol as drawn measures 120 units across. It would accurately represent a tree 10 feet across if I were using it in an architectural drawing where the basic units were inches. However, I want to use it in a civil drawing, where the units are feet. A tree 120 feet across would be much too large. I'd also like the symbol to be placed on the layer L-PLNT-DEMO automatically, so I don't have to remember to set that as my current layer or to change it after the fact. I also don't like the rotation angle at which it the symbol was created, because it looks too regular with the horizontal and vertical lines used for the symbol. Here are the steps you can take to change the properties:

Changing the Properties of Tools on a Palette
  1. Right-click the Tree - Deciduous Plan block on the tool palette, and select Properties as in Figure 3.7.

  2. When the Tool Properties dialog box opens, change the scale, the rotation, and the layer onto which the block is inserted. See Figure 3.8 for an example.

Turning off tool-palette groups

Figure 3.6. Turning off tool-palette groups

Opening the Tool Properties window

Figure 3.7. Opening the Tool Properties window

Changing the properties of a tool

Figure 3.8. Changing the properties of a tool

Note

Note that the block definitions aren't stored in the current drawing until they're inserted. They reside in the original drawing. Objects on the tool palettes are completely independent of the current drawing.

Adding Other Tools to a New Tool Palette

Now that you know how to create a tool palette and add it to a new group, let's create a blank palette and add some other kinds of tools to it.

Create a new tool palette by right-clicking a tool palette title and selecting New Palette. Name this one Drawing. Notice that the first item on the empty palette is Learn About Customizing Tool Palettes. Selecting this option opens the New Features Workshop.

To create a new tool from any existing object, do the following:

  1. Select the object with the left mouse button so it's highlighted.

  2. Place the cursor over the highlighted object, and hold down the right mouse button while dragging the object onto the palette.

In Figure 3.9, I've already dragged a polyline onto the tool palette, and I'm in the process of placing an aligned dimension just below the polyline.

For each of these tools, a flyout is created automatically. This flyout gives you access to all the commands related to that object. Even though you used a polyline as an example when creating the drawing tool, if you select the small arrowhead in the lower right corner of the icon and pause, a flyout with tools for lines, arcs, circles, splines, ellipses, rays, and xlines appears. And no matter what kind of dimension you place, the flyout gives you access to all of them: Aligned, Linear, Arc Length, Radius, Jogged, Diameter, Angular, Ordinate, Quick, Baseline, Continue, Quick Leader, and Tolerance (see Figure 3.10).

The toolbar displays the last option you selected from the flyout. I often place the draw and dimension commands on a tool palette more than once. There are two reasons: First, I can use one tool for lines that are to be placed on a specific layer and a different tool for lines on a different layer. Second, I can place all dimensions on a DIM layer but have different dimension commands displayed so I don't have to go through the flyouts each time I want a different one. (See Figure 3.11.)

Dragging a tool onto a tool palette

Figure 3.9. Dragging a tool onto a tool palette

Tool palette flyouts

Figure 3.10. Tool palette flyouts

You can also add hatch patterns to a toolbar. You can either drag an existing hatch pattern from the drawing onto the toolbar, as I did with the line and dimension commands, or you can use the file-management pane on the left of the ADC to locate a specific hatch-pattern file. The default file is ACAD.PAT for Imperial drawings and ACADISO.PAT for metric. Because they're both buried in your personal settings under the C:Documents and Settings folder, it's far easier to place a hatch pattern using the HATCH command and drag it onto the toolbar. Once it's there, right-click the pattern icon, select Properties, and set the angle, layer, and so on.

Prior to the development of the CUI in AutoCAD 2006, you could drag commands directly from the Customize dialog box. That isn't possible as of AutoCAD 2006. If you want a command that's not represented by an object that can be dragged onto a palette, copy (right-click) an example from the sample Command Tools palette that ships with AutoCAD (See Figure 3.12), and paste it (right-click again) onto yours.

Displaying different flyout options

Figure 3.11. Displaying different flyout options

Copying existing tools from the sample tool palette

Figure 3.12. Copying existing tools from the sample tool palette

Editing the command string

Figure 3.13. Editing the command string

Note

Many tool palettes ship with AutoCAD. As a result, you may not see the Command Tools tab because so many tabs are bunched up at the bottom of the palette. If so, place your cursor on the bunched-up tabs, and left-click. A complete list pops up, and you can select Command Tools.

Once the command is on your palette, you can right-click and edit the properties to add any command string you want. This is particularly useful for running Lisp programs or menu macros from the tool palette, as shown in Figure 3.13.

Exporting a Tool Palette

You can easily export a tool palette for use on a different computer or as a backup. Once you export a tool palette, a different user can then import it. The result is an XLM file, but its extension is .xtp. To export a tool palette, open the Customize dialog box, and right-click the name of the palette you want to export. Give it a name, and save it in the location of your choice. AutoCAD creates a folder with the same name as the tool palette to hold the image files used on the palette.

A different AutoCAD user can't access to this tool palette unless they import it using the same process. The default location of the tool palettes used by AutoCAD is C:Documents and Settings%username%Application DataAutodeskAutoCAD 2007R17.0enuSupportToolPalette (%username% represents the logon name of the current user).

The Customizable User Interface (CUI)

The big customizing change as of AutoCAD 2006 was the creation of CUI files. Users can modify the ACAD.CUI by using the CUI command to open the Customize User Interface dialog box. I like this consolidation, but it means that a lot of customizing is no longer consistent from release to release. You don't need to know much about the CUI files themselves, because they aren't meant to be modified directly—so don't try. They are XML files and easily corrupted by editing. The following is taken directly from the beginning of the ACAD.CUI file:

Warning! Do not edit the contents of this file.
If you attempt to edit this file using an XML editor, you could
 lose customization and migration functionality.
If you need to change information in the customization file, use the
Customize User Interface dialog box in the product.
To access the Customize User Interface dialog box, click the Tools menu >
Customize > Interface, or enter CUI on the command line.

There are three kinds of CUI files and some significant differences of opinion over how to best handle them. Autodesk Support makes the following recommendations:

Enterprise CUI file Use this file type for custom company standards that aren't to be modified by individual users.

Partial CUI files Use this file type for third-party menus or custom menus that will be partially loaded.

Main CUI file (ACAD.CUI is the default) Use this file type to allow modification by each user according to their preferences.

Note

Before you do any customizing, make a backup copy of the ACAD.CUI file, which will be modified indirectly when you use the CUI command in AutoCAD. Don't be fooled by the presence of a file named ACAD.BAK.CUI. Although that file appears when you do any customizing using the CUI command, it's not a copy of the original ACAD.CUI file. It's one CUI modification older than the ACAD.CUI. Make your own backup of the original so you can restore it if things go wrong.

Creating a New Toolbar

The CUI is nice, even for long-time users who have done a lot of customizing in the past. The best thing about the CUI is that most, but not all, customizing is performed using the same techniques, whether you're modifying pull-down menus, toolbars, or any other menu-related item. Here's how to customize the CUI:

  1. Open the Customize User Interface dialog box by typing CUI or right-clicking a toolbar button and selecting Customize.

  2. Select Main CUI File (acad.cui) in the top pane. (See Figure 3.14.)

  3. Right-click Toolbars in the upper-left pane, and select New → Toolbar from the menu.

  4. Name your toolbar—use Sybex for this example.

  5. Select All Commands in the Command List pane, as shown in Figure 3.15. Note that you can list commands in the following groups:

    • All commands available in AutoCAD

    • Only Express Tool Commands

    • Only control elements (windows that control things like plot scale, layer names, and so on)

    • Only commands associated with a specific category of pull-down menu

    Note

    Legacy commands are older versions that no longer appear on a pull-down menu.

    Creating a new toolbar in the CUI

    Figure 3.14. Creating a new toolbar in the CUI

    Selecting commands to add to a toolbar

    Figure 3.15. Selecting commands to add to a toolbar

    Dragging a command to a blank toolbar

    Figure 3.16. Dragging a command to a blank toolbar

  6. Drag any command from the list onto your toolbar. A toolbar button for that command is created. (See Figure 3.16.)

    Most of AutoCAD's existing commands have a toolbar button icon already associated with them. If the command you add has a toolbar button image already, that icon is displayed in the Button Image pane. If not, the image in the pane is blank. You'll create a custom toolbar button later so you'll know how to handle a blank button.

  7. The toolbar isn't actually created until you click either the Apply or the OK button at the bottom of the Customize User Interface dialog box.

The completed toolbar, shown in Figure 3.17, includes some commands, an express tool, and two control windows. Here's a complete list:

  • Layer Properties Manager

  • Layer control window

  • Layer previous

  • A separator

  • Viewport Scale control window

  • A custom text-placement command

  • Match Properties

  • Change Space

  • Change Text Case

  • Quick Dimension

  • Dimension Style control window

  • Dimension Style update

  • Workspace control window

  • Workspace Settings

  • Flyout named Dims

Because this toolbar contains all the tools I want on a toolbar, I can turn off all the toolbars I don't need and get more drawing space. It's like getting a larger monitor.

Maybe you want to reorganize your toolbar buttons. You do that in the listing in the CUI shown in Figure 3.18, not on the toolbar itself. To rearrange any of the elements, just drag and drop them to new locations.

You can also edit the toolbar or any element of the toolbar by right-clicking the element you want to edit. Using the menu that pops up, you can do any of the following:

  • Delete the toolbar or a tool on the toolbar.

  • Rename the toolbar.

  • Add a separation line by selecting Insert Separator (this toolbar includes three).

  • Add a new toolbar.

  • Add a flyout button, which is actually a toolbar attached to a single button.

Custom toolbar

Figure 3.17. Custom toolbar

Writing a Custom Toolbar Button Macro

Although it's possible to add an empty button to a toolbar, if you want it to be useful, it must be based on a command. If the command doesn't exist, you have to define it yourself. So, let's start by creating a new command.

The purpose of this particular command is to create text that's always based on the romans.shx font and always placed on the correct layer, at a height of 0.125 for use in a layout. This is an example of how you can use menu macros to enforce office standards by making those standards easy to follow. When the command is complete, the original layer is made current. You just select the location of the text and type.

Use the following steps to create a new command:

  1. Click the New button in the Command List pane.

  2. In the Properties pane, change the name of the button from Command1 to something more descriptive, such as NewText.

  3. Change the macro, which is a small program that creates your new command. To do so, open the Long String Editor shown in Figure 3.19 by clicking the ellipses button (...) at the end of the Macro pane. The ellipses button won't appear until you move your cursor to the end of the pane, and once the Long String Editor opens, the ellipses button is no longer visible.

CUI panel for the custom toolbar in Figure 3.17

Figure 3.18. CUI panel for the custom toolbar in Figure 3.17

Note

You can create this command using AutoLISP instead of the language of menu macros. Doing so allows much greater control. For example, you can write it so that the text scales automatically to match the plot scale of the current viewport. For an example of the AutoLISP code required to scale text, see Chapter 9, "AutoLISP by Example—Getting Better."

Note

A tooltip can be displayed for your command, but only if you add something meaningful to the Description window.

The new line should read as follows:

^C^C-style;romans;romans.shx;0;1;0;;;;-layer;m;text;;dtext;.125;0;layerp

The purpose of each element in this macro is identified in Table 3.1.

Creating a new menu macro

Figure 3.19. Creating a new menu macro

Table 3.1. Description of Elements of the Menu Macro

MACRO ELEMENT

PURPOSE

^C^C

In menu language, means ESC, ESC. Clicking the button cancels any active command before the command continues. If you're conservative, you can add a third ^C. That used to be necessary if you were editing a polyline vertex using PEDIT, but it no longer is.

-style

Activates the STYLE command. The negative sign used as a prefix is required to prevent a dialog box from opening. If you aren't familiar with this, try typing it that way at the command prompt. Instead of a dialog box, you can create a text style directly. This technique is helpful in creating and troubleshooting menu macros, scripts, and AutoLISP programs.

;

The equivalent of the Enter key. Put a semicolon in a menu anywhere you would press the Enter key if using the command line. For other files you'll use, the semicolon has a different meaning, so be prepared. The next 12 entries are responses to the STYLE command.

romans;

Names the new text style. It's ignored if the style already exists.

romans.shx;

Specifies the use of the romans.shx font for this text style.

0;1;0;;;

Defines a text height of 0, width factor of 1, angle of 0, and format: not vertical, not backward, not upside down.

;

Exits the STYLE command. This semicolon is often overlooked when users write macros.

-layer;

Command-line version of the LAYER command. The next 4 entries are responses to this command, followed by a final semicolon to exit the LAYER command.

m;text;;

Makes a new layer named text and makes it current. If the layer exists, the command is ignored.

dtext;

Activates the DTEXT command.

Pauses for user input, in a menu macro—in this case, the start point of text.

0.125;0;

Sets the text height at 0.125 with a rotation angle of 0. This can be changed, or you can use a pause to let the user set a specific height.

layerp

Issues the LAYERP (layer previous) command to restore the layer that was current at the time the command started. No final semicolon is needed because this command has no options like the LAYER and STYLE commands.

Once you've created a new toolbar button, you must try it to see if it does what you want it to. It probably won't the first time, but don't get discouraged. Customizing requires troubleshooting. If your button doesn't work, you probably left out a semicolon.

Editing Pull-Down Menus

At first blush, it may be hard to imagine why you'd want to add anything to the pull-down menu structure. It seems pretty complete, after all. However, if you use the pull-down menus, you may find something missing, or, more likely, you may want to simplify or rearrange the many existing items. So you can see how to edit the pull-down menu, let's add one overlooked command to the File pull-down: the SAVE command.

I know it looks as if the SAVE command is already there. It's not the same SAVE command you get at the command line, however; it's actually the QSAVE command. But I like the command-line version, because it does something I wish all Windows software did: It lets you save a backup file to a different location, or with a different name, without changing the default path or filename. That's how the SAVE command differs from the SAVEAS command in AutoCAD.

Here is where the CUI starts to look really good, because adding a command to the pull-down menus is almost exactly like adding a new button to a toolbar. First, to avoid confusion, change the name of the existing Save command on the File pull-down menu to Qsave, as shown in Figure 3.20. To do so, select the command, and make your changes in the Properties pane of the CUI. (Notice that the existing macro is ^C^C_qsave.)

Now you can create the new version of the Save command and drag it onto the File pull-down menu. Follow these steps, and look at Figure 3.21 as an example:

  1. Select the New button in the Command List pane.

  2. Move to Properties, and change the command name and description.

    Changing the name of the Save command to Qsave

    Figure 3.20. Changing the name of the Save command to Qsave

    Note

    The ampersand (&) is used in a menu name to make the following character a quick-key. If you hold down the Alt key while the File menu is displayed, typing the letter S selects this command because it's preceded by the ampersand.

  3. Type _save after the ^C^C in the Macro field.

    Note

    The underscore in front of this and other menu commands forces AutoCAD to use the Englishlanguage version of the SAVE command, even if the menu is being used with a version of AutoCAD in another language. Sometimes a period is used in front of a command name so the native version of the command is used even if it has been undefined using the UNDEFINE command. The only reason to undefine a command is so you can redefine it as something else—normally, using an AutoLISP program. Although you can use both a period and an underscore, neither precaution is likely to be necessary. The default menu uses only an underscore.

  4. Drag the new command up to the File menu, and drop it in place.

Adding the command-line version of SAVE to a pull-down menu

Figure 3.21. Adding the command-line version of SAVE to a pull-down menu

Modifying a Cursor Menu

Just so you can see the possibilities, let's modify the OSNAP cursor menu—the one shown in Figure 3.22, which pops up when you hold down the Shift key and press the right button on your mouse (or the middle button if MBUTTONPAN is set to 0). If you've ever wished this menu were shorter or organized differently, here is your chance. The OSNAP menu is known as a shortcut menu in the AutoCAD 2006 CUI. The process of editing the shortcut menu is the same as that to edit the toolbar menu:

  • To add options, drag and drop them from the Command List: pane. Note the addition of the QuickCalc command in Figure 3.23.

  • To change the order, drag the existing osnaps around. Note that Endpoint is now at the top.

  • To eliminate some osnaps, right-click them and select Delete. Note that the Point Filters have been removed. Could this be any easier?

Existing OSNAP cursor menu

Figure 3.22. Existing OSNAP cursor menu

Customized OSNAP cursor menu

Figure 3.23. Customized OSNAP cursor menu

Modifying the Grips Menu

Here is a nice change you can make to the grips menu that will let you grip an object to rotate and copy it at the same time.

This task normally requires three menu picks when using standard grips. Let's get it down to one pick using the following steps (see Figure 3.24 as a guide):

  1. Create a new command.

  2. Give it the name CopyRotate for this example.

  3. Add a description, if desired.

  4. Delete the ^C^C (you don't want to cancel the grip mode, because you're trying to use it).

  5. Add the following line to the Macro field: _rotate;_copy;_base; (you could eliminate the underscore in front of each command. They are used to internationalize the new command).

  6. Drag the command onto the Grips menu. The result is shown in Figure 3.25.

If you use grips, begin noticing where you make more than one menu pick, and consider creating other combination commands for those actions.

Adding a command to the Grips menu

Figure 3.24. Adding a command to the Grips menu

Assigning Keyboard Shortcuts

I don't think I'm the only AutoCAD user who frequently presses the F1 key when I intend to press Esc, particularly on my laptop. Well, not only can you redefine the F1 key, you can redefine many other keys on the keyboard and have them do something immediately when they're pressed. The function keys are the best candidates for customizing; if you don't use the default settings, why not redefine them? Because I don't use the F1 key to get help in AutoCAD or any other Windows program, I define it as a cancel key in AutoCAD. Because I often snap to a point halfway between the endpoints of two lines, I assign the MEE function of the CAL command to the F4 key (this forces a running osnap of endpoint, where M2P would use the current setting for running object snaps). I often need to use a paint program, so I've assigned the F8 key to open it. I like to place a mark using the UNDO command, so I've assigned that function to the F9 key.

Grips menu with the new CopyRotate command

Figure 3.25. Grips menu with the new CopyRotate command

Note

To place a mark with the UNDO command, you type UNDO and select the Mark option. If, after continuing your editing session in AutoCAD for a while, you decide you want to undo all of your actions since you placed the mark, use the Back option of the UNDO command. If you forgot to place a mark, you can enter an integer instead to UNDO that number of steps. Change your mind again, and the REDO command will cancel all the steps.

You should consider using all the other function keys for something useful as well—your favorite object snaps, undoing multiple steps, performing various zoom commands, flipping from a layout to the Model Space tab, or issuing any commands that are difficult to type or to find on a menu.

Note

Unfortunately, ^C in AutoCAD isn't the same as Esc in Windows. If F1 is redefined as a cancel command using ^C^C, it does indeed cancel an active command, but it doesn't clear grips or highlighting from a selected object. To do that, add the AutoLISP function (sssetfirst nil) after the ^C^C, as described next.

When you select Keyboard Shortcuts in the top pane, you see a listing of the shortcut keys and their current assignments, as shown in Figure 3.26. There are two kinds of keyboard shortcuts: accelerator keys and temporary overrides.

Before you can assign an action to an accelerator key or combination of keys, that action must first exist as a command. Although two versions of a cancel command are already defined—one with a single cancel represented by ^C, the other with a double cancel represented by ^C^C—this example uses a triple cancel. That will cover any situations in which you must press the Esc key three times to return to an open command prompt from a deeply buried command option. Figure 3.27 shows the sequence for creating a command and assigning it to a shortcut key.

To assign a command to a shortcut key, follow these steps:

  1. Define a new Cancel command, just as you defined a command for a new toolbar button in the previous section.

    The macro requires an additional ^C (OK, add two, just to be on the safe side—the ^ is added by pressing Shift+6). After the third ^C, add the small Lisp program (sssetfirst nil), which cancels the current selection set so the highlighting and grips are cleared. I named my version of the cancel command abbott-cancel to differentiate it from the other versions and to place it at the top of the list.

    Existing keyboard shortcuts

    Figure 3.26. Existing keyboard shortcuts

    Assigning a command to a keyboard shortcut

    Figure 3.27. Assigning a command to a keyboard shortcut

  2. Open the Shortcut Keys menu, and drag the abbott-cancel command onto it. Once you've done this, a Key(s) field appears below the Macro field in the Properties pane. At the right of the field is a button with an ellipses (...). It will disappear when you click it to open the Shortcut Keys dialog box, shown in Figure 3.28.

  3. Click in the field titled Press New Shortcut Key in the Shortcut Keys dialog box, and then press the F1 key.

Note

In AutoCAD 2006, you must click the Assign button before exiting the Shortcut Keys dialog box, or the key won't be assigned!

You now have a new shortcut key.

The fours keys I've assigned are shown in Figure 3.29; they use the macros listed in Table 3.2. Any command name can be preceded with an underscore to internationalize it, and/or you can add a period to let the command be used on a system where the native command has been undefined.

The Shortcut Keys dialog box

Figure 3.28. The Shortcut Keys dialog box

New shortcut keys

Figure 3.29. New shortcut keys

Table 3.2. New Macros Assigned to Shortcut Keys

NAME

KEY

FUNCTION

MACRO

abbott-cancel

F1

Cancel, and clear selection set

^C^C^C(sssetfirst nil)

abbott-mee

F4

Snap midway between two endpoints transparently—no ^C

'cal;mee;

abbott-paint

F8

Open Paint Shop Pro

^C^Cstart;psp;

abbott-undo-mark

F9

Place UNDO mark

^C^CUndo;m;

Linetypes (All Releases)

Linetypes are one of the few areas of customization not controlled by the CUI. They're defined in an external file named either ACAD.LIN for Imperial units or ACADISO.LIN for metric units. Both files are located in the Support folder of AutoCAD located in the user's Documents and Settings folder. Basic linetypes consist of dashes, dots, and spaces. Complex linetypes include text or shapes.

Note

In Chapter 1, "AutoCAD Productivity," I describe an alternative method for creating a linetype—or at least what looks like a linetype—by placing blocks along a polyline with the MEASURE command.

Creating Basic Linetypes

Linetypes come in two flavors in AutoCAD: complex and basic. Most people never have any reason to create a basic linetype, but I have made several, including dotted linetypes that can be used to create grid paper at 4, 5, 8, or 10 dots per inch; and a hidden linetype that starts with a gap. Let's look at the beginning of the ACAD.LIN file and see how a linetype is defined, and then I'll illustrate several possibilities for customizing.

Note

You've seen this trick earlier in the book, but to open this file quickly, type the following AutoLISP code at the command line, including the parentheses: (startapp "notepad" (findfile "acad.lin")). Back up the original before modifying it.

The beginning of the ACAD.LIN file looks like this:

;;
;;  AutoCAD Linetype Definition file
;;  Version 3.0
;;  Copyright (C) 1991-2006 by Autodesk, Inc.  All Rights Reserved.
;;
;;  Note: in order to ease migration of this file when upgrading
;;  to a future version of AutoCAD, it is recommended that you add
;;  your customizations to the User Defined Linetypes section at the
;;  end of this file.
;;
*BORDER,Border __ __ . __ __ . __ __ . __ __ . __ __ .
A,.5,-.25,.5,-.25,0,-.25
*BORDER2,Border (.5x) __.__.__.__.__.__.__.__.__.__.__.
A,.25,-.125,.25,-.125,0,-.125
*BORDERX2,Border (2x) ____  ____  .  ____  ____  .  ___
A,1.0,-.5,1.0,-.5,0,-.5

*CENTER,Center ____ _ ____ _ ____ _ ____ _ ____ _ ____
A,1.25,-.25,.25,-.25
*CENTER2,Center (.5x) ___ _ ___ _ ___ _ ___ _ ___ _ ___
A,.75,-.125,.125,-.125
*CENTERX2,Center (2x) ________  __  ________  __  _____
A,2.5,-.5,.5,-.5

Each linetype definition requires two lines of text: a description line and a definition line. The description line has two fields separated by a comma. The first field gives the linetype a name, and the second field contains the description you see when you load the linetype. The definition line has multiple fields separated by commas; it always starts with the letter A, which stands for aligned.

Note

In theory, it's possible to use a code other than A in this field and change the way a linetype starts. I've never been able to make this function work, so perhaps it's a legacy function.

The other fields in the definition line define the linetype as containing a dot, a space, or a line segment. Once you've defined the repeating pattern of the linetype, there are no more fields. A linetype can't start with a space. If you want a space at the beginning of a linetype, start with a dot, then the space, and then the line segment. See Table 3.3 for a description of each field.

I've added two new linetypes at the end of this file. One is a dotted line with a dot spacing of 0.1 to use for making grid paper. The other is a hidden line that has a gap at the beginning for use in special situations (see Chapter 4, "Applying Graphics Standards"). Because of the way linetypes are generated, the first gap is larger than those that follow, and a dot will be at both ends of the line. Because this linetype is used to represent a feature that starts at a visible line, the dot won't show:

;;  User Defined Linetypes
;;
;;  Add any linetypes that you define to this section of
;;  the file to ensure that they migrate properly when
;;  upgrading to a future AutoCAD version.  If duplicate
;;  linetype definitions are found in this file, items
;;  in the User Defined Linetypes section take precedence
;;  over definitions that appear earlier in the file.
;;
*Grid01, 0.1 dot spacing for grid paper . . . . . . . . . . . . . . .
A,0,−0.1
*Hidden-gap, specialty hidden line .  --.  --.  --.  --.  --.  --.
A,0,−0.125,0.25

Table 3.3. Function of Fields in a Linetype Definition

VALUE

FUNCTION

0

Represents a dot

-value

Represents a space the length of the value given

+value

Represents a line segment the length of the value given

Working with Complex Linetypes

There are two kinds of complex linetypes: those that include some text, like "Hot Water"; and those that include a shape, like Batting. This section will cover two different techniques for creating linetypes: The first modifies the ACAD.lin or ACADISO.lin file, and the second uses two Express Tools. I like the first technique for complex linetypes containing text and the second for complex linetypes using shapes.

Modifying the ACAD.LIN and ACADISO.LIN Files

If you're in an Imperial drawing with MEASUREMENT set to 0, the ACAD.LIN file is used to load linetypes. If you're in a metric drawing with MEASUREMENT set to 1, the ACADISO.LIN file is used. Both files are in the support directory for the user (C:documents and settings...). Open the one you plan to use in Notepad, and back up the original.

Scroll down to the complex linetypes section. The first group uses shapes from LTYPESHP.shx, which is a compiled shape file that's shipped with AutoCAD. The second group uses text. The quickest way for you to create a text-based linetype is to copy and then modify one that exists. Following is the Hot Water Supply linetype that ships with AutoCAD, followed by a modified version of it for Cold Water Supply. Longer words require different settings for the two gaps, defined here as -.2 and -.2.

HOT_WATER_SUPPLY,Hot water supply ---- HW ---- HW ---- HW ----
A,.5,-.2,["HW",STANDARD,S=.1,R=0.0,X=−0.1,Y=-.05],-.2
*COLD_WATER_SUPPLY,Cold water supply ---- CW ---- CW ---- CW ----
A,.5,-.2,["CW",ROMANS,S=0.1,R=30,X=−0.1,Y=−0.07],-.2

Just as in the basic linetype, each complex linetype definition with text has a pair of lines: The first contains the name and the description used to identify the linetype when you load it, and the second contains the code that defines the linetype. The basic parts of the linetype—dots, line segments, and gaps—are defined as described earlier. The only difference is that text is defined within square brackets.

Note

If you use a text style other than Standard for linetype definitions, make sure your drawings always contain the style you use. Otherwise you'll get a bad linetype definition error when you try to load a linetype.

Within the brackets are six fields separated by commas, as illustrated in Table 3.4.

Note

The final value in the definition (the value -.2 is used here) must create a large enough gap for the text string you define.

Table 3.4. An Explanation of Linetype Fields

FIELD

SAMPLE VALUE

FUNCTION

1

"CW"

The text placed in the linetype. You enter it in quotations.

2

ROMANS

The name of the text style used for the text. The default is Standard, which is why complex linetypes always look so bad. You may want to redefine Standard by basing it on the ROMANS.SHX font. I prefer to use a text style named ROMANS.

3

S=0.1

Controls the text size. In this case, it's 0.1 units, making it a little smaller than the other text on a drawing.

4

R=30

Controls the angle at which the text is placed, in this case 30°.

5

X=−0.1

Controls the offset for the X coordinate start point. Setting it for a negative value that's ½ the gap defined centers the text horizontally.

6

Y=−0.07

Controls the offset for the Y coordinate start point. If the rotation angle used were 0, I'd set this to ½ the text height used. Because I used a rotation angle of 30°, a slightly larger value is required here to have the text centered.

Using Express Tools to Create Complex Linetypes

Creating complex linetypes based on shape files is fairly easy with the Express Tools MKSHAPE (Make Shape) and MKLTYPE (Make Linetype). It's a two-step process: First you use the Make Shape tool to create a shape, and then you use the Make Linetype tool to create a linetype that uses that shape. Let's start with the Make Shape tool:

  1. Draw a shape consisting of vectors with no solid or gradient hatch patterns. Use a shape that's about one unit long.

  2. Select Express → Tools → Make Shape (see Figure 3.30).

    Make Shape Express Tool

    Figure 3.30. Make Shape Express Tool

  3. Save the shape file with an appropriate name in a folder that's in AutoCAD's search path. This should be a folder that has been placed at the top of the search path using OPTIONS (I discuss the OPTIONS command in Chapter 2, "Managing Your System").

  4. Give a name for the shape when prompted at the AutoCAD command prompt.

  5. Identify a resolution. The default value of 128 is normally fine for straight lines.

  6. Pick an insertion point that will locate the shape properly when used as a linetype.

  7. Select the objects you want to use as a shape. Your shape is saved in the file you specified.

Once you've created a shape, you need to use it to create a linetype:

  1. Use the SHAPE command to insert one instance of your new shape using the default height and rotation.

    Note

    Because AutoCAD's SHX fonts are actually shapes, you can use text based on one of them with the Make Linetype tool. You may find that easier than editing the ACAD.LIN file.

  2. Select Express → Tools → Make Linetype.

  3. Create a linetype file in which to place the new linetype definition. Don't select an existing linetype file, such as ACAD.LIN, or it will be overwritten. You can copy the definition into the ACAD.LIN file later, if you choose.

  4. Give the linetype a name. It can be the same as the filename, but it doesn't have to be.

  5. Give the linetype a description.

  6. Pick a starting point and an ending point that have enough room between them for the shape plus some space. (See Figure 3.31.)

  7. When prompted, select the shape you inserted, not the original objects used to create it.

  8. The linetype is created and loaded. If you want to load it into a different drawing, you can select the file it's in from the Linetype Manager dialog box and load it manually.

  9. Select it like any other linetype, and assign it to a layer. The results of using a spline on a layer with the new arrow linetype are shown in Figure 3.32.

Defining the starting and ending points of the linetype definition

Figure 3.31. Defining the starting and ending points of the linetype definition

Arrow linetype

Figure 3.32. Arrow linetype

Linetype definitions become part of the drawings database when they're loaded. This presents no problem with the linetypes based on text, as long as the text font you use is a standard AutoCAD font. However, you may have a problem with the shape-based linetypes if you send the drawing file to someone else. Unless the shape file is on their computer and in the AutoCAD search path, the shapes won't display.

I've used an arrow linetype for creating egress plans for public buildings. But because the files use linetypes that may not be readable on someone else's computer, when you need such a linetype, you may want to make a block representing an arrow and then insert it along a polyline using the Block option of the MEASURE command. It looks best if you change its properties to spline-fit the polyline.

Note

Enable Linetype generation for each polyline that is either spline-curved or fit-curved when using complex linetypes., Otherwise the linetype pattern may not display uniformly along its entire length. As an alternative, you could set the variable PLINEGEN to 1, but that may adversely affects the appearance of other lines.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.129.195.215