rapid customizing: minimum pain, maximum gain...so we will create at least one custom tool button....

28
Walt Disney World Swan and Dolphin Resort Orlando, Florida 11/29/2005 - 8:00 am - 11:30 am Room:S. Hemispheres (Salon 5) [Lab] (Dolphin) Rapid Customizing: Minimum Pain, Maximum Gain Last year this workshop was the top-rated 3.5 hour lab at AU. This hands-on lab will have experienced AutoCAD users customizing in no time. We will take a quick spin through some of the AutoCAD OPTIONS; clarify the process of creating and using template files; see how to make a quick custom linetype; create some very useful external commands (while making sure everyone knows how to create aliases); create a new tool palette; add some custom tool buttons to a custom tool bar; take a brief look at the ACAD menu; and then ... write some understandable, simple, but still very useful AutoLISP programs. Can we do all this in 3.5 hours? You bet we can. CP21-1L About the Speaker: Dan Abbott - Southern Maine Technical College Randy Brunette (Assistant); John Jordan (Assistant) and Dan has been involved with technical education for more than 20 years, the past 16 of which have been as a member of the Architectural and Engineering Design Department at Southern Maine Technical College. Dan trains industry professionals in AutoCAD use and management, AutoLISP, and geometric dimensioning and tolerancing. He works with Knowledge Development Solutions to help create technical exams for Autodesk. Dan earned M.S. and B.S. degrees in Industrial Technology from the University of Southern Maine, and a B.A. degree in Psychology from Swarthmore College. [email protected]

Upload: others

Post on 10-Feb-2021

3 views

Category:

Documents


0 download

TRANSCRIPT

  • Walt Disney World Swan and Dolphin ResortOrlando, Florida

    11/29/2005 - 8:00 am - 11:30 am Room:S. Hemispheres (Salon 5) [Lab] (Dolphin)

    Rapid Customizing: Minimum Pain, Maximum Gain

    Last year this workshop was the top-rated 3.5 hour lab at AU. This hands-on lab will have experienced AutoCAD users customizing in no time. We will take a quick spin through some of the AutoCAD OPTIONS; clarify the process of creating and using template files; see how to make a quick custom linetype; create some very useful external commands (while making sure everyone knows how to create aliases); create a new tool palette; add some custom tool buttons to a custom tool bar; take a brief look at the ACAD menu; and then ... write some understandable, simple, but still very useful AutoLISP programs. Can we do all this in 3.5 hours? You bet we can.

    CP21-1L

    About the Speaker:

    Dan Abbott - Southern Maine Technical CollegeRandy Brunette (Assistant); John Jordan (Assistant)and

    Dan has been involved with technical education for more than 20 years, the past 16 of which have been as a member of the Architectural and Engineering Design Department at Southern Maine Technical College. Dan trains industry professionals in AutoCAD use and management, AutoLISP, and geometric dimensioning and tolerancing. He works with Knowledge Development Solutions to help create technical exams for Autodesk. Dan earned M.S. and B.S. degrees in Industrial Technology from the University of Southern Maine, and a B.A. degree in Psychology from Swarthmore [email protected]

  • Rapid Customizing: Minimum Pain, Maximum Gain

    2

    [Note: this paper is intended to supplement and expand on the workshop. It contains some of the code we will be using, but also contains additional information. It does not include the power point slides.]

    I am sometimes surprised when I do training, at the number of people who use AutoCAD, but who have never done any customizing. There are many ways in which you can make your use of AutoCAD more efficient, consistent, accurate, and just plain interesting with very little knowledge of programming. We will start with those activities. But even programming is not difficult at an entry level, because AutoLISP is very easy to learn for people who already know how to use AutoCAD. We will finish our half-day session with an introduction to AutoLISP.

    I have to make one comment on release 2006. The Customizable User Interface (CUI) in AutoCAD 2006 has made it necessary for part of this paper and part of the workshop to be release-specific. For now, that is limited to toolbars, tool buttons, short-cut menus, pull-down menus, and accelerator keys. In the future, I expect even more of this paper to become release-specific as Autodesk continues to develop the CUI. For now, you will find it useful no matter what release you use, but anything that does NOT apply to Release 2006 is at the end of the paper.

    A summary of what we will be doing:

    1. Template files – no change in 2006

    I hope that most of you already use your own template files, and are not relying on those that ship with AutoCAD. Just in case you aren’t, I will quickly have you go through the process of placing them in a path, the process of creating them, and I will suggest what should be included in a good template file.

    2. External Commands – no change in 2006

    These are commands like NOTEPAD and EXPLORER, which already exist in AutoCAD as external commands. If you didn’t know that, just type either word at the command line and see what happens. In fact, type START and you can fire up any windows program if you know the name of its executable file. I want to make sure that everyone knows how to make your own, quite powerful external commands that start other applications and open folders, files or web-sites automatically.

    3. Aliases – no change in 2006

    Aliases are not too big a deal, and can be created quickly using one of the Express Tools, but you might as well know how to create your own, or change the ones that have been assigned already. It means finding an ASCII file named “ACAD.pgp,” opening it, modifying it, reinitializing it, and making sure its in the path so AutoCAD can find it. In the process I will also make sure that you understand the “Documents and Settings” nested path to support files, since that comes up often, and requires a change to the operating system default settings.

    4. Tool Palettes – small interface change in 2006

    Tool palettes may not seem like a customization technique, but they have some features that really help make you more efficient, and if you aren’t using them, you probably should be. I will have everyone add blocks and commands to a tool palette and change the properties of the blocks or commands to control scaling and layer assignment automatically.

  • Rapid Customizing: Minimum Pain, Maximum Gain

    3

    5. Tool bars – changed in 2006

    Tool bar creation is one of the easiest ways to improve your efficiency and open up some more drawing space. They are easily created from existing commands, control windows, and tool buttons.

    6. Tool buttons – changed in 2006

    Existing tool buttons are fine, but you will get a sense of the real power of tool bars when you create your own tool buttons and assign them to tool bars. So we will create at least one custom tool button.

    7. Linetypes – no change in 2006

    There are a lot of pre-defined linetypes that ship with AutoCAD, but only a handful of complex linetypes. Creating a linetype using shape files may be a little too involved for this workshop, but it is very easy to create linetypes that use text within them just like the existing ones that say “GAS” or “HW.” And I will have you correct an annoying problem with AutoCAD’s existing linetypes, which use “STANDARD” as the default name for the font used for text. Since STANDARD is often considered a bad name to use for a text style, I will show you how to have AutoCAD linetypes use your own text style.

    8. Menu files – major change 2006

    You will be making a couple of changes to the menu structure of AutoCAD. You will add a missing command to a pull-down menu, reorganize the OSNAP menu that pops up at the cursor, and change the behavior of the F1 key, which laptop users (and even keyboard users) often kit by accident when they mean to press the ESC key. While we are at it, I will have you add a transparent call to the CAL command to the F12 key. If you never use the Function keys, you might want to make them useful and start using them – if only to have a quick key for your favorite OSNAP.

    9. Scripts – no change in 2006

    Scripts may seem a little out-of-date now, but I still use them for resetting variables, sending messages to all users on my network, and for a process that allows me to update thousands of drawings automatically. We’ll create some simple ones.

    10. AutoLISP – no change in 2006

    You aren’t going to turn into experts, but in a short time you will be writing a useful program, and understand how it works. After that, we will cover as much ground as possible towards taking some of the mystery out of programming.

    One general note before starting any customization:

    Always backup any file you are about to edit. For this workshop, we will modify copies of the ACAD.pgp, ACAD.lin, ACADISO.lin, acad.cui file (for release 2006), and perhaps the ACAD.mns file for R2005.

  • Rapid Customizing: Minimum Pain, Maximum Gain

    4

    Template files – all releases

    You may create as many template drawings as you want. Start by setting the path. To do that, select the “Files” tab of the OPTIONS dialog box. Under that tab, search for “Template Files” and open it up by selecting the + sign. You will see a heading named “Drawing Template File Location.” You may be surprised to see that the files are located in a very long path. This is done to conform to the windows multi-user environment format. AutoCAD support files are now placed in the users profile folder, which is found under “C:\Documents and Settings\username\.” This is not a good place to keep template files if you need to share them with others in the office. I recommend that you change the location to a common network drive by selecting the current location and typing a new one or using the “Browse” button to find a location that is shared, or just plain easier to find.

    To create a new template, simply begin a new drawing in AutoCAD, set up the drawing, and save it as a .dwt file. The location you placed in the path will open automatically. Now use the NEW command. The template file location you specified will open automatically, allowing you to select your own template file rather than one of AutoCAD’s. In earlier releases, you can select the “template” or “Start with Template” option. You can even specify that AutoCAD always start with this template when the QNEW command (quick new) is used, by specifying it in the same area of the OPTIONS dialog box.

    You can also create you own custom shortcut on the desktop and edit the target window by adding “/t yourown.dwt” at the end of the line that is there. Specify the path and the filename and AutoCAD will start with the specified template. Make several.

    Drawing template files should include the following settings: layers with colors, linetypes and lineweights specified; saved layer states; DIMSTYLES; LIMITS; UNITS; generic VIEWS; text STYLES; BLOCKS defined for title blocks and standard symbols; standard layouts; plot styles; pen styles, and anything else that should be common to all drawings, including variable settings.

    Consider setting the following variables (see Help system for information): UCSICON = OFF for 2D drawings, ON or to OR for 3D drawings; PLINEGEN = 1; MIRRTEXT = 0; REGENAUTO = OFF on very large drawings -- don't forget to do a regen occasionally; CELTSCALE, LTSCALE, and PSLTSCALE set to 1; DISPSILH = 1; ELEVATION = 0; FILLETRAD = 0; FILLMODE = 1; HIDETEXT = 1; INSBASE = 0,0,0; LIMCHECK = 0; MEASUREMENT = 0, for English, 1 for Metric; PSTYLEMODE = 1; PSVPSCALE = 0 for "zoom extents," 1 for 1xp, 1/48 for 1/4"=1', etc.; SKPOLY = 1; SORTENTS = 27; DRAWORDERCTL=3 (2005); THICKNESS = 0; ELEVATION = 0.

    There may be other variables you would like to set in the template drawing. However, many variables are not saved in drawings, but are saved in the registry instead. To see where variables are saved, use the HELP system, and review the variable list. The help for each one indicates the location where the setting is changed, as well as the default value.

  • Rapid Customizing: Minimum Pain, Maximum Gain

    5

    External Commands and Aliases: the “ACAD.pgp” file – all releases

    To find this file, you will have to go deep into the Documents and Settings folder, or use the search function of windows. The default location for the ACAD.pgp file for each user login name is as shown. Your own login name would appear instead of “dabbott2,” which is the logon name I used for this example. Even knowing this, however, you are unlikely to find this file because, bizarrely, you must navigate through a hidden folder, “Application Data” in order to find it. Here’s a command line shortcut: (startapp “notepad” (findfile “acad.pgp”))

    If you don’t know how to make a hidden folder visible, it is as follows: use the “Tools” pull-down menu in Windows Explorer (it is shown in the image to the right); select “Folder Options” then the “View” tab; now select “Show Hidden files and folders.”

    To create new external AutoCAD commands, add lines in the following format to the beginning of the file. Comments must be preceded by a semi-colon, which makes the line a remark.

    WORD, start winword,1,,ri

    AU, start iexplore www.autodesk.com/au,1,,

    PGP, start notepad c:\docume~1\dabbott2\applic~1\autodesk\autoca~2\r16.2\enu\support\acad.pgp,1,,

    WORK, explorer c:\dan\da-work,1,,

    Each of these lines has five fields separated by four commas:

    1. the name of a new AutoCAD command that you are creating;

    2. the external command you want to run when the new command name is typed at the keyboard;

    3. a bit-flagged number that is explained at the top of the file, but for our purposes can just be “1.”

    4. a blank in each of our examples, but you can place a command prompt if it is needed.

    5. a legacy blank; The key is to have four commas.

    To create new command aliases, add lines in the following format OR use the express tool “aliasedit.”

    RI, *REINIT

    CY, *CYLINDER

    K, *CAL

    Each of these lines has two fields:

    1. the name of the alias you are creating;

    2. the name of the AutoCAD command preceded by an asterisk, which lets AutoCAD know that this is a native AutoCAD command, not an external command. Since it is not external, the remaining fields are not used. If a command can be issued transparently, like CAL, than the alias can too.

    After saving the file, use the REINIT command to reload it into AutoCAD. It must be in the path.

  • Rapid Customizing: Minimum Pain, Maximum Gain

    6

    Tool Palettes – all releases

    Tool palettes allow you to organize tools that you use regularly. They started as a place to store blocks and hatch patterns, but have expanded to include commands by example. Let’s start with adding all of the blocks from a single drawing to a single tool palette. This is done through AutoCAD Design Center.

    Type ADC or otherwise start design center, then navigate through the files to find a .dwg file that contains block definitions you want on a tool palette. Although you can easily drag and drop them one at a time (including from the current drawing), this time right-click in any area in either pane on the ADC palette and select the menu option “Create Tool Palette.” AutoCAD will create a single new palette that contains all of the block definitions in that drawing.

    Now, right-click on any of the blocks and select ‘Properties.” You can control the scale, rotation, and the layer onto which a block will be inserted every time. Note that the block definitions do not get stored in the current drawing until they are inserted. They reside in the original drawing. Objects on the tool palettes are completely independent of the drawing you are in.

    Now let’s add some other tools to a new tool palette. Start by creating a new tool palette. This is done by right-clicking in the tool palette window and selecting “new tool palette.” I have named this one “AU2005.” You can create tools by dragging any object from the drawing directly onto the tool palette. The two objects shown create flyouts to give you access to the other similar objects you

    can create. This is the easiest way to add the QDIM command to a tool palette. Change the properties so that all dimensions land on the “DIM” layer.

    You can also add hatch patterns. Drag an existing hatch pattern from the drawing to the tool bar, just like the line and dimension commands. Or, use the file management pane on the left of AutoCAD Design Center to locate a pattern file. The default file is ACAD.pat at the end of that long “C:\documents and settings…” path. Select the hatch pattern you want, then drag and drop it onto a new tool palette. Once it is there, right-click on the pattern icon, select properties and set the angle, layer, etc.

    In 2005, you can drag other commands from the Customize dialog box. That doesn’t appear to be possible in 2006. But you can copy existing commands from the sample tool palette and paste them onto your tool palette. Once they are there, you can right-click and edit their properties to add any command string you want. This is particularly useful for running Lisp programs or menu macros from the tool palette.

  • Rapid Customizing: Minimum Pain, Maximum Gain

    7

    Toolbars and Tool Buttons – Release 2006

    Well, now we need two sections. Let’s start with AutoCAD 2006. Then, for those of you who are a bit conservative about upgrades (which believe me, I understand), I will include a section for prior releases.

    The big customizing change in R2006 is the creation of a new mega file known as a CUI (Customizable User Interface), which is modified using the command “CUI” to open the “Customize User Interface” dialog box. I applaud this consolidation, but it does mean that a lot of customizing that used to be consistent from release to release is no longer consistent. You don’t need to know much about the file itself, except that the .xml format makes it difficult to modify directly. That workshop would be called “MAXIMUM Pain, Minimum Gain.” So, let’s modify it indirectly as intended. It is actually pretty nice, even for long-time users who have done a lot of customizing in the past, but everything in this section applies ONLY to release 2006.

    1. Start the CUI dialog box by typing “CUI,” or right-clicking on a tool button and selecting “Customize.”

    2. Right-click on “Toolbars” in the upper left pane, and select “New” from the menu.

    3. Name your toolbar – “au2005” in the example.

    4. Leave it at the bottom of the list so you can find it quickly.

    5. Select “All Commands” in the Command list pane.

    6. Now just drag any command in the list to your toolbar, and a tool button for that command will be created. We will also create a custom tool button later on. If a tool button image exists for that command, it will be used.

    In the example on the right, I have added an Express Tools command (only available if express tools are loaded, which I strongly recommend that you do), and the Viewport scale control window.

    My completed tool bar includes LAYER, the layer control window, LAYERP, a custom text placement command, MATCHPROP, CHSPACE (I created an icon, but at tool button size it looks a lot like the XLINE icon), QDIM, QLEADER, the Dimstyle control window, Dimension Update, the Workspace window, and WORKSPACE. Since this toolbar contains all of the tools I normally use a toolbar for, I can turn off all of the others and get more drawing room.

    The next page shows both the toolbar, and the listing in the CUI that created the toolbar. If you want to rearrange any of the elements, you just drag and drop them to new locations right in the CUI (not on the toolbar itself). Right-click on any element to delete it.

  • Rapid Customizing: Minimum Pain, Maximum Gain

    8

    Use the shortcut menu shown at the right to rename the toolbar, insert a separation line (there are three in this toolbar), delete a toolbar, add a new toolbar or add a flyout button (which is actually a toolbar attached to a single button).

    Tool Button Creation

    Before you can add a new tool button to a toolbar, it must be a command. So we will start by creating a new command.

    Select the “New” button in the “Command List” pane.

    Change the name of the button from “Command1” to something more descriptive. I called this one “NewText.”

    Change the description, so the tool tip that shows up will be helpful.

    Now change the macro, which is a small program that actually creates your new command.

  • Rapid Customizing: Minimum Pain, Maximum Gain

    9

    The whole line reads as follows:

    ^C^C--style;romans;romans;0;1;0;;;;--layer;m;text;;dtext;\0.125;0;layerp

    ̂ C^C In this macro I left the opening “^C^C,” which in menu language means, ESC, ESC. That way selecting the button will cancel any active command before continuing. You could even add one more ̂ C in case you are using the “Edit Vertex” option of the PEDIT command when you decide to add text via this button.

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

    ; The semicolon is the equivalent of the Enter key. You put it in a menu anywhere that you would have to press Enter if using the command line. (For other files we will be using, the semicolon has a different meaning, so be prepared.) The next twelve entries are responses to the style command.

    romans; Names a new text style. Ignored if the style already exists.

    romans; Specifies the use of the romans.shx font.

    0;1;0;;; Defines text height, width factor, angle, and format: not vertical, not backwards, not upside down.

    ; Exits the STYLE command. This semicolon is often overlooked by customizers.

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

    m;text; Makes a new layer named “text” and makes it current. If it exists, command is ignored.

    dtext; Activates the DTEXT command.

    \ In menu macro language, a backslash pauses for user input. In this case the start point of text.

    0.125;0; Sets text height at 0.125, with a rotation angle of zero.

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

    Once you have created a new tool button, you must try it out to see if it does what you want it to. It probably won’t the first time, so don’t get discouraged. You probably left out a semicolon.

  • Rapid Customizing: Minimum Pain, Maximum Gain

    10

    Pull-down Menus – Release 2006 CUI

    You might think that there is no reason to add anything to the pull-down menu structure. It does seem pretty complete, after all. However, if you use the pull-down, you might find something missing, or, more likely, you might want to simplify or rearrange them. For this workshop, let’s just add one overlooked command to the File pull-down: the SAVE command.

    I know it looks like the SAVE command is already there. Well, it’s not the same SAVE command you get at the command line, it is actually the QSAVE command. But I like the command line version, because it does something I wish all windows software did – it let’s you save a file to a different location, or with a different name without changing the default path or filename.

    Here is where the CUI starts to look really good, since adding a command to the pull-down menus is almost exactly like adding a new tool button to a toolbar. First you create the new command then you drag it onto the File pull-down menu.

    Start by selecting the “New” button in the Command List Pane. Now move over to properties and change the name and description. Type the word “save” after the ^C^C in the macro window. Drag the new command up to the File Menu and drop it in place.

    Cursor menu – Release 2006 CUI

    Let’s modify the OSNAP cursor menu – that’s the one that 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 have ever wished it were shorter, or organized differently, here is your chance. The osnap menu is a shortcut menu in the 2006 cui.

    To add options, drag and drop them from the Command Pane. Note the presence of the QuickCalc command.

    To change the order, just drag the existing snaps around. Note that “Endpoint” is at the top.

    To eliminate some osnaps, right-click on them and select “Delete.” Could this be any easier?

  • Rapid Customizing: Minimum Pain, Maximum Gain

    11

    Grips Menu – Release 2006

    Here is a nice little change that you can make to the grips menu to do something that I do frequently. Hot grip an object to rotate and copy it at the same time. This requires three menu picks using standard grips. Let’s get it down to one.

    Once again, you must create a new command.

    Give it a name. Mine is “CopyRotate.”

    Add a description, if desired.

    Delete the ̂ C^C (we don’t want to cancel the grip mode, since we are trying to use it).

    Add the following line to the Macro window: _rotate;_copy;_base;

    You could eliminate the underscore. That just internationalizes the new command: it works even on non-English versions of AutoCAD. I don’t know why I do it, since I have never customized any non-English version of AutoCAD, but now you know. The semicolons must be there though.

    Now drag it onto the grips menu. It is the first option on mine. Now when you hot grip something, you can just pick a base point and rotate a copy into place.

    If you use grips a lot, notice where you make more than one menu pick, and consider creating a combination command for that action.

  • Rapid Customizing: Minimum Pain, Maximum Gain

    12

    Complex Linetypes – all releases

    Basic linetypes consist of dashes, dots and spaces, and are easy to write. I have created special dotted linetypes that can be used to create grid paper at four, five, eight or ten dots per inch. You can figure that out.

    There are two kinds of complex linetypes: those that include some text, like the “Hot Water” linetype, and those that include a shape, like the “Batting” linetype. I will cover two different techniques for creating linetypes: the first is modifying the ACAD.lin or the ACADISO.lin file; the second uses a couple of express tools. I like the first technique for complex linetypes containing text, and the second for complex linetypes using shapes (although there is one caution with the Express Tools – see below.)

    Modifying the ACAD.lin and ACADISO.lin

    If you are in a drawing with MEASUREMENT set to 0 (inches), the ACAD.lin file is used to load linetypes. If you are in a drawing with MEASUREMENT set to 1 (metric), 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 (backup the original, or work on a copy) in notepad. Again, you can do this quickly by typing the following in AutoCAD:

    (startapp “notepad” (findfile “acad.lin”))

    Scroll down to the “Complex Linetypes” section. The first group uses shapes from a file named “LTYPESHP.shx,” which is a compiled shape file. The second group uses text. The quick way to create a text-based linetype is to modify one that exists. Below is the Hot Water linetype that ships with AutoCAD, followed by a modified version of it for Cold Water. 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=.1,R=30,X=-0.1,Y=-.07],-.2

    Each linetype definition has a pair of lines. The first contains the name and the illustration used when you load a linetype to identify it. The second line contains the code that actually defines the linetype. The “A,” stands for "alignment" but has no options. Numbers represent segment and space lengths. Text is defined within [].

    .5 Length of first line segment

    -.2 Length of gap before text starts

    [“CW” Actual text to be placed in linetype, followed by text style used. The default is Standard, which is why your complex linetypes always look so bad. I change mine to a text style I create named “Romans.”

    S=.1… The next four attributes control text size (S), text angle (R), X coordinate start point offset (X), and Y coordinate start point offset (Y). I rotated the text 30 degrees, and dropped the start point .07 from line.

    -.2 Length of gap from end of first gap. This distance must be large enough for the text string you define.

  • Rapid Customizing: Minimum Pain, Maximum Gain

    13

    Using Express Tools to Create Complex Linetypes

    Creating complex linetypes based on shape files is much easier with the Express Tools “Make Shape” and “Make Linetype.” Simply draw a shape consisting of vectors, select “Make Shape” from the Express tools and follow the prompts. Use the SHAPE command to insert one instance of your new shape, then use the “Make Linetype” command and follow the prompts. To use text instead, create the text with the style you want, add any line segments you want to include, and use “Make Linetype” +again.

    Two examples are shown. The first includes the outline of an arrow with no additional lines, the second includes a short line segment and some text. When asked to select a file, browse to the support directory for AutoCAD and select “ACAD.lin” or create a new linetype file using a different name. When you select the save button, you will be asked to supply a linetype name. Make something up.

    When prompted for a description, you can enter anything that will help you remember what the linetype is. When asked to “Specify starting point for line definition:” and then “Specify ending point for line definition:” pick two points on either side of the text or the objects you want to include. Then you just select the objects and you have a new linetype that is appended to the ACAD.lin file and

    automatically loaded.

    Using the objects in the two examples would look like this:

    The definitions are loaded into the drawing. This is no problem with the linetypes based on text, as long as the text font you use is a standard AutoCAD font. However, for the shape-based linetypes there is a problem if you send the drawing file to someone else. They must have the shape file on their computer, in the AutoCAD path, or the shapes won’t show.

    I have used an arrow linetype before, but since it creates a drawing that may not be readable on someone else’s computer, you might want to make a block out of an arrow, and insert it along a splined PLINE using the “Block” option of the MEASURE command when a linetype of this type is needed.

    For complex linetypes, you might need to set PLINEGEN to 1 in order to have it look right when used with a PLINE that is spline-curved or fit-

  • Rapid Customizing: Minimum Pain, Maximum Gain

    14

    curved. If setting PLINEGEN to 1 affects other lines adversely, change the Linetype generation property of any single PLINE using Properties.

    Scripts

    A script automatically executes a series of commands contained in a text file with the extension “.scr.” Scripts can be used to do a number of things, including creating drawing objects, changing layer and variable settings for an existing drawing, automatically extracting block attributes, creating slides, running a slide show, starting AutoCAD with a particular drawing, or editing an unlimited number of drawing files while you do something else. A script file is a very simple, yet potentially very powerful, customizing tool.

    Creating and using a script file requires the following steps:

    1. Using a text editor, type a list of AutoCAD commands just as you would at the keyboard. You can place one command on each line or separate commands with spaces. You have to be careful not to have any extra spaces in the file. A space in a script has the same effect as pressing the ENTER key.

    2. Save the file with a filename and an extension of .SCR. This is critical. Without the .SCR extension, AutoCAD won’t recognize a text file as a script when you try to run it.

    3. Have AutoCAD run the script. This requires that you issue the SCRIPT command. You can do this from the keyboard by typing either SCRIPT or SCR, or by selecting from the Tools menu.

    Here is an example of a script that is used to reset defaults on a computer.

    ;Create new layers

    LAYER new obj,hid,cen,txt,dim color 1 hid color 3 cen color 4 txt color 5 dim

    L hidden hid l center cen s obj

    ;Create new text style

    STYLE romans romans 0 1 0 n n n

    ;Reset variable values

    APERTURE 5 ATTDIA 1 AUNITS 0 AUPREC 1 BLIPMODE 0 CECOLOR bylayer CELTSCALE 1

    CELTYPE bylayer CMDDIA 1 CMDECHO 1 CURSORSIZE 5 DRAGMODE A ELEVATION 0 EXPERT 0

    FACETRES 1 FILEDIA 1 FILLETRAD 0 GRIPCOLOR 5 GRIPHOT 1 GRIPS 1 GRIPSIZE 3

    HIGHLIGHT 1 LTSCALE 1 MBUTTONPAN 1 MIRRTEXT 0 OSMODE 4133 PELLIPSE 0PICKADD 1

    PICKAUTO 1 PICKBOX 3 PICKFIRST 1 PICKSTYLE 1 PLINEGEN 1 PSLTSCALE 1 SAVETIME 15

    SDI 0 SORTENTS 23 THICKNESS 0 UCSICON off UCS w UCSVP 1

    A script is often referred to as a very fast typist. It is fairly simple. However, you must be careful about a couple of things. Every space and every new line is interpreted in the same manner that an ENTER at the keyboard would be interpreted, so no extra spaces (check the ends of each line) and no blank lines unless you WANT to issue an ENTER. Try out the very simple script below in Notepad and save it with the extension “.scr” to see how it works.

    STYLE romans romans 0 1 0 n n n

    Note! Windows uses the .scr extension for screen savers. You cannot double-click on the file to open it. That tells windows to use it as a screen saver. After any period of inactivity, you will get a confusing error message about not being able to run the program.

  • Rapid Customizing: Minimum Pain, Maximum Gain

    15

    LAYER N one,two,three C 1 one C 2 two C 3 three

    To run the script file, use the SCRIPT command and open the file. Check to see if you have the new text style and layers.

    AutoLISP

    Ok, now this is where things begin to get fun. Like the ACAD.pgp file, AutoLISP files are ASCII text files and can be created in NotePAD, or WordPad, but I use AutoCAD’s Visual Lisp text editor. VLISP can be started from the command line by typing it, or it can be started from the “Tools” pull-down menu, under the AutoLISP heading. There are many features of this program that are useful, but for now let’s use just a few of them.

    For each of the tool buttons shown above, the one immediately to the right of the circled button does the same thing, but only for text in the file that is highlighted. When you do start a file in VLISP, you will notice immediately that a color code is being used. It is as follows:

    BLUE Color used for AutoLISP functions, like “defun” and “setq.”

    MAGENTA Color used for a string -- characters that could be typed with a standard keyboard.

    BLACK Color used to denote anything the operator creates, such as a variable name.

    GREEN Color used to denote a numerical value.

    Maroon/Gray Colors used to identify comments, always preceded by a semi-colon.

    Defining New AutoCAD Commands – "defun"

    Let’s start with a simple command.

    • Purpose: zoom to 95% of the current extents.

    • Procedure at keyboard:

    o type ZOOM and press Enter;

    o type "E" for EXTENTS and press Enter;

    o type "ZOOM" again;

    o type ".95X" and press Enter.

    This program will do all four steps when you type "ZX" at the keyboard. To create the program, use the following steps.

    • Start AutoCAD.

    • Start the Visual LISP environment by typing VLISP (or VLIDE, or from the pull-down).

  • Rapid Customizing: Minimum Pain, Maximum Gain

    16

    • Start a new file using the New option of the File pull-down menu.

    • Type the following on three lines, as shown:

    (defun C:ZX ()

    (command "zoom" "e" "zoom" ".95x")

    )

    • Pick the "Load Active Edit Window" button.

    • Switch back to AutoCAD and draw some objects.

    • Type ZX at the command line. Did the program work?

    That’s it. These three lines comprise an entire lisp program. It creates a new command named "ZX" that works just like any other AutoCAD command you can type or select. By duplicating its basic format, you could create hundreds of other new commands. Make sure you thoroughly review and understand the following explanations for each line.

    Line 1: (defun C:ZX ()

    This line begins with an opening parenthesis, indicating to AutoCAD that a LISP program will follow. You must enclose all elements in parentheses, and you must have a closing parenthesis for every opening parenthesis. Notice that this line has two opening, but only one closing, parenthesis. The second closing parenthesis appears at the end of the program on line three, all by itself.

    The LISP expression name must appear after an opening parenthesis. The word "defun" is a LISP expression, which stands for "define function." It will be blue when you type it in VLISP.

    The "C:ZX" means that the lisp function you are defining will operate as if it were an AutoCAD command. It will be black when typed in VLISP. The "C:" means "new AutoCAD command." It has nothing to do with the hard drive. "ZX" is the name of the new AutoCAD command you are creating, which can be typed at the keyboard. You can name your new commands nearly anything you want. ZX makes sense to me -- your command names should make sense to you.

    The two parentheses () at the end of the line are empty for this program, but they must be there. In other programs they are likely to contain either arguments or user-defined local variables.

    Line 2: (command "ZOOM" "E" "ZOOM" ".95x")

    Once again, we are starting with an open parenthesis, so the first thing to appear must be the LISP function. "Command" is a LISP function that allows you to use ANY native AutoCAD command within a new LISP program. Use a command here, NOT an alias. "ZOOM" will work, but "Z" will not.

    This line is the actual program that is executed when you type "ZX." It issues the AutoCAD ZOOM command, then its selected options. The entire line must be enclosed in parentheses. Anything you would normally type at the keyboard must be enclosed in quotes (anything is quotes is known as a string). Spaces between a closed quote and the next open quote are not necessary, but they make it easier to read your code.

  • Rapid Customizing: Minimum Pain, Maximum Gain

    17

    Line 3: )

    This line simply closes the very first parenthesis in the program. Placing it by itself at the end of a program makes it easier for you to see where each program ends, and to match it with the opening one. Formatting parentheses in this way is very helpful when debugging a program.

    Defining similar new commands

    A cardinal rule of programming is to reuse code (either yours, or someone else’s) whenever possible. With just these three lines, you now have the basic syntax to write dozens of new commands. ZA, and ZP require only a change in the options selected. Other commands can be substituted for ZOOM, with their own options. Once you understand the format for creating these commands, the sky is the limit.

    Try this small improvement in the way that a circle is created in AutoCAD. As all designers know, circles have diameters, not radiuses.

    (defun c:c() (command "circle" pause "d"))

    Notice that programs don't have to be formatted neatly to run. Even a very long program could be typed on a single line. AutoLISP will sort out the parentheses. Notice also that a lisp program will override a command alias with the same name – not a command name though. For that the command must first be undefined using the AutoCAD command UNDEFINE.

    The "pause" function" is new, and does pretty much what you would expect.

    Using variables with the “setq” function

    (defun C:CL(/ ss1 layname) (setq ss1 (ssget)) (setq layname (getstring "\nDestination layer: ")) (command "LAYER" "N" layname "" "CHPROP" ss1 "" "LA" layname "")

    )

    This command is a little more involved and introduces several new functions.

    “Setq” is a very important lisp function that is used to create variables so that actions taken by the operator can be saved and used later in the program.

    “Ssget” is a function that asks the operator to select objects.

    Note: when you place a command like "ZOOM" in quotes, it is the same as typing the command name in AutoCAD and then pressing the Enter key. If you want to include an additional Enter while in the command function, place an open and then a closed quotation mark with nothing between them (an empty string). You need this for commands like LAYER, CHPROP, and DONUT to exit the command when you are done with it.

    If need the equivalent of the ESC key, place the following line in your code: (command)

    Keep this in mind: computers are stupid and do only what they are told. You must be very specific about what you want a program to do. Before writing any new command, go through the process in AutoCAD at the keyboard to make sure you remember each step. Do you need the second "zoom" in this program? Yes you do, but you might overlook it if you don t go through the steps at the keyboard first.

  • Rapid Customizing: Minimum Pain, Maximum Gain

    18

    “Getstring” is a function that gets anything the operator types at the keyboard.

    There are two variables that were created by the programmer: ss1, and layname.

    The four lines perform the following functions:

    Line 1: defines a new function that will act as a command named CL with two local variables

    Line 2: sets variable “ss1” equal to whatever objects are selected by the operator

    Line 3: sets variable “layname” equal to whatever the operator types when asked “Destination layer:”

    Line 4: issues the LAYER command, creates a new layer with the name specified in variable “layname,” then

    issues the CHPROP command to change the layer of the objects specified by the variable “ss1” to that

    specified in the variable “layname.”

    IF, WHILE, and creating defaults The IF function can be used to determine a current condition, and react one way if the condition is true, and another if the condition is false. One use of the IF statement is to create a default value. (COND is a related function that allows you to create a list of conditions and have your program go through them until one condition is true.) The WHILE function allows you to write a program that repeats a series of actions. The following example will place numbers into a drawing in sequence beginning with the value the operator indicates as a starting point. If the operator presses the ENTER key when asked for the first number, the value “1” is used, because the program uses the IF function to create a default value Line 1 (defun c:number (/ num point st1 st2) Line 2 (setq num (getint "\nFirst number in sequence: ")) Line 3 (if (= num nil) Line 4 (setq num 1) Line 5 ) Line 6 (setq point (getpoint "Insertion point: ")) Line 7 (while point Line 8 (setq st1 (itoa num)) Line 9 (setq st2 (strcat "#" st1)) Line 10 (command "text" point ".12" "0" st2) Line 11 (setq point (getpoint "Select insertion point: ")) Line 12 (setq num (+ num 1)) Line 13 ) Line 14 )

    Line 1: defines a new command function named “number” with four local variables

    Line 2: sets variable “num” equal to the integer typed by operator in response to the prompt

    Line 3: if “num” is nil (operator pressed ENTER) execute line 4, otherwise skip line 4

    Line 4: set “num” equal to 1

    Line 5: close “if” function

    Line 6: set variable “point” equal to the X,Y,Z value of the point provided by operator

    Line 7: “while” function repeats until variable “point” has no value (operator presses ESC)

    Line 8: set variable “st1” equal to value created by converting “num” from an integer to a string

    Line 9: set variable “st2” equal to the string “#” added to the string “st1”

  • Rapid Customizing: Minimum Pain, Maximum Gain

    19

    Line 10: insert text represented by “st2” (#1) at “point” with a height of .12, rotation angle of zero

    Line 11: set variable “point” equal to the X,Y,Z value of the next point provided by operator

    Line 12: set variable “num” equal to current value of “num” plus 1

    Line 13: close “while” function

    Line 14: close “defun” function

    Using calculations Programs often require some mathematical calculations. This is a good time to point out the syntax of all AutoLISP functions. The function always comes immediately after the opening parenthesis in lisp. The function is followed by arguments to the function. To add two numbers, you must start with the addition function (+) and follow it (don’t forget the spaces) with the values to add. (+ 1 1) ;returns the integer 2 and is read, “add 1 to 1” (- 3 1) ;returns the integer 2 and is read, “subtract from 3, 1” (/ 3 2) ;returns the integer 1, since both arguments are integers (/ 3.0 2) ;returns the real number 1.5, since one of the arguments is a real number (* .5 2) ;returns an error “error: misplaced dot on input, since leading zeros are required (* 0.5 2) ;returns the real number 1.0 The following program functions will convert from inches to millimeters.

    (defun c:i2m () (setq in (getdist "\nGive value in inches: ")) (setq mm (* in 25.4)) (setq st1 (rtos in 2 3)) (setq st2 (rtos mm 2 2)) (alert (strcat "Value of " st1 " inches is " st2 " mm")) )

    These examples are presented to get you started and help you understand the basic structure of AutoLISP programs. Now that you have a sense of how easy it is to create simple programs, I hope you will find more and more opportunities to write others. The following material is presented for your reference. I would also recommend that you do some searching on the Internet for sites that provide AutoLISP tutorials. The tutorial that ships with AutoCAD is probably NOT a good place to start.

  • Rapid Customizing: Minimum Pain, Maximum Gain

    20

    Ten Basic Rules for Lisp Programming 1. TEXT Files. Lisp programs must be saved as ASCII (DOS) text files. VLISP is the editor of choice. The more you learn about its functions, the easier it is to write code. If nothing else, use the color scheme. 2. BALANCE. There must be an equal number of opening and closing parentheses; and an equal number of opening and closing quotation marks. It is easier to do this if the routines are set up with lines and indents. Use the VLISP format button to do this automatically. 3. DEFUN. The term DEFUN means "define function." The value that follows is the name of the function. If the name includes the C: you have a function that can be used as a new AutoCAD command. If it does not, the function can be used in the form (DTR 180) either in another lisp routine, or at the command line. 4. ENTER and CANCEL. Empty double quotation marks represent the enter key. If you want to accept the default in a command, "" will do it. However, be careful that it is not a command in which the defaults can change. If in doubt, give an actual value instead of using the double quotes. Calling the COMMAND function alone (command) will cancel a command as though you pressed the Esc key. 5. BACKSLASH. Within a LISP program, a backslash (\), used to separate sub-directories, must be represented with a front slash (/) or a double backslash (\\). If you want to insert a drawing using LISP, the program line might look like this: (command "insert" "c:\\dwg\\dsize" "0,0" "1" "1" "0"). If you need a quotation mark within a string, you must use the control character \”. 6. ARGUMENTS and VARIABLES. An empty pair of parentheses after the DEFUN expression means that this particular function has no arguments and no local variables are defined. Most lisp routines contain specific variables or arguments within these parentheses. Place variables here once you know your program works so they become “local” variables, not global. There is ALWAYS a space after the front slash. 7. NEWLINE. To get a new line for a prompt to the user, always place the characters \n (lower case) after the opening quote and before the text of the prompt in functions like GETSTRING. You can also use the new line code in an alert box. (alert “Notice\nShut down computer when done.”) will display as shown at the right. 8. ANNOTATE. Use one or more semi-colons (;) before a comment that is not part of the LISP program itself. You might want to annotate your programs as I have in this section so you don’t forget what you did. VLISP can automatically “comment out” a section. 9. LOGICAL STRUCTURE. When designing a program, try to get all the information needed from the user or the drawing at the beginning, by using "setq" to create local variables. If you make any changes to existing AutoCAD variables at the beginning of the program, change them back at the end to what they were at the beginning. 10. PERSIST. Don't get discouraged if a new program doesn't work the first time. The only way to test a LISP program is to run it. It is easy to make a typing error, particularly one involving parentheses or quotation marks, which causes your program to crash. Start simple. Add new programs to your ACADDOC.lsp file one at a time, and test them each time. And don’t overlook the HELP system in VLISP. It is very good. If you want to find out how to apply a function, check there first. Two other good sources for help: www.augi.com and the discussion group for AutoLISP accessible through www.autodesk.com at http://discussion.autodesk.com/forum.jspa?forumID=130.

  • Rapid Customizing: Minimum Pain, Maximum Gain

    21

    Selected Lisp Functions Below is a list of LISP functions that I find useful for intermediate level program writing. If you want to expand your knowledge from here, use the VLISP Help system. ; place a semi-colon at the beginning of any line that NOT part of your program !v1 type at the command prompt to get the value of variable “v1.” alert produces an AutoCAD message box with any string. atof converts a string into a real number. atoi converts a string into an integer. cond allows testing of multiple conditions, similar to IF statement. defun defines a new function in lisp. defun c:xxx defines a new function that behaves as an AutoCAD command with the name “xxx.” entsel asks the user to select one entity that can be set equal to a variable name. getangle gets an angle from operator and converts it into radians. getcorner drags a rubber-band window when picking second corner point. getdist gets a distance from user as typed value, or distance between two points. getint gets an integer from operator. Must be a whole number to be valid. getpoint gets a point from operator as typed value or picked point. getreal gets a real number from operator [as opposed to an integer]. getstring gets a character string from operator [any keyboard characters typed]. getvar gets the value of a specific setvar (getvar "osmode"). if If what follows is true go on to next step, if false, skip next step. itoa converts an integer into a string. list returns a list from a variable that contains a list [(list p1) returns x, y, z of p1)]. load used to load a LISP routine in AutoCAD (load"ACADDOC"). nth 0 returns first item in list. Useful for getting the X coordinate of a point. nth 1 returns second item in a list (and so on). Useful for Y coordinate of a point. pause pauses function for operator input, than continues. polar enters a distance at an angle in radians from a point (polar pt ang dist). prompt prompts operator (prompt "select entity"). repeat repeats a series of steps within a function a specified number of times. rtos converts a real number into a string. Arguments can determine form and precision. setq sets a variable equal to whatever follows. [(setq a (4)) sets a=4]. setvar sets an AutoCAD variable [(setvar "PDMODE" 3)]. ssget gets a selection set by prompting the user to select objects. strcase "string case" sees both lower case and upper case letters as upper case. strcat "string concatenate" combines whatever follows into a single string. while repeats following actions on group of objects until there is nothing left to do \n starts prompt on new line [("\nSelect first corner")] must be lower case "n." * multiply the next value by the one that follows. / divide the next value by the one that follows. + add all values that follow - subtract from the next value, the sum of all that follow = equal to /= not equal to > greater than < less than >= greater than or equal to

  • Rapid Customizing: Minimum Pain, Maximum Gain

    22

    Suggestions for Program Structure 1. Add error trapping to any program you write that changes any existing AutoCAD variables or creates objects within the drawing. The error trapping illustrated below will work in most cases, and can be added to the ACADDOC.lsp file once and referenced in all programs. If you do reference error trapping within a program, YOU MUST PLACE THE LINE (command “.undo” “m”) AT THE BEGINNING. If you don’t, the error trapping can undo work the user has done prior to issuing the command. In other words, it can do more harm than good. 2. Gather information from the user or the computer at the beginning of the program and save the results as variables using the "setq" function. Make sure you save the values of any AutoCAD variables you will be changing (such as "OSMODE" or "EXPERT"). For example: (setq ap (getvar "aperture")) ;saves current aperture value to variable “ap” (setq os (getvar "osmode")) ;saves current osmode value to variable “os” 3. Set AutoCAD variables to the new value necessary for the program to run. (setvar "aperture" 3) ;smaller aperture to reduce error when selecting (setvar "osmode" 512) ;sets osnap to “nearest” for flexible placement 4. Use the values from the user to calculate new values, if necessary, and save them with new variable names using the "setq" function. 5. Use the information to do what the program is intended to do. 6. Return any changed AutoCAD variables to their original settings, including error trapping. 7. Add a (PRINC) to avoid the return nil being displayed at the command line. Two Error Trapping Function Examples ;;; Error Trapping function one -- global (defun globalerror (msg) ;defines an error function named “globalerror” (command) ;cancels an active command if an error occurs (command ".undo" "b") ;reverts to a mark using the UNDO command (setq *error* old_error) ;restores any existing *error* function, if any (print "Resetting to original status: ") ;a message to user if there is an error ) ;closes the opening parenthesis ;;; Error Trapping function two -- local (defun localerror (msg) ;defines an error function named “danerror” (command) ;cancels an active command if an error occurs (setvar “osmode” os) ;resets the osnap mode to what was active (setvar “expert” ex) ;resets “expert” variable to what was active (setq *error* old_error) ;restores any existing *error* function, if any (print "Resetting to original status: ") ;a message to user if there is an error ) ;closes the opening parenthesis

  • Rapid Customizing: Minimum Pain, Maximum Gain

    23

    Appendix -- RELEASE 2000 through 2005 Materials

    Toolbars and Tool Buttons – Release 2000 through Release 2005

    Many people keep multiple toolbars open just to have access to one or two buttons on each one. Once simple way to reduce the number of toolbars and increase your efficiency is to consolidate the buttons you normally use onto one or two tool bars. This is particularly helpful if you use flyout tool buttons. The process is very straightforward. Again, you will be using the CUSTOMIZE command to bring up the Customize dialog box. To create a new toolbar, just open the Toolbars tab and select NEW. Give your new toolbar a name and you will have a new, empty, toolbar. It will appear as a very short bar near the top of the screen.

    To add a tool button, switch to the Commands tab and drag and drop any of the commands to the tool bar. In this example, I have selected a flyout tool button (draw) and dragged it to my new toolbar. By selecting the All Commands item under “Categories,” you can select any individual tool button and add it to your custom tool bar.

    You can also select “User defined,” which will give you access to two different kinds of user defined buttons: single and fly-out. If you choose the fly-out user-defined button, you must associate it with a toolbar. Not all of the existing toolbars can be selected as a flyout (dimension, for example), but any new custom toolbar you create can be. If you want a dimension flyout from a tool button, just start by creating a new dimension toolbar named “DIMS” for example, and it will become a flyout tool button on your new toolbar.

    To create a brand new tool button, you should drag a single button to the new toolbar and add your own menu macro. This can be anything you want the tool button to do, including a single command, a command with options selected, a series of steps, or even AutoLISP code. We will do a simple button to create a text style and add a line of text at a height specified in the tool button.

    Once the blank button is placed, select it, or right-click and select “Properties” and you will open the window that allows you to modify the menu macro. It starts out mostly empty, as shown on below. You can name it, describe it, define it and create a button icon from here.

  • Rapid Customizing: Minimum Pain, Maximum Gain

    24

    Potential Problems.

    1. If the “ACAD.mns” file is open at the same time you are modifying tool buttons, you will be modifying the same file in two different ways. Each time you save the file, you are replacing the file with a new one that will NOT have your toolbars. Close the “ACAD.mns” file before adding any toolbars.

    2. You may find that your tool button icons are not showing up on your toolbar. That is because AutoCAD can’t find them. Make sure you save the .bmp files you create for buttons in a location that is part of AutoCAD’s path. If that doesn’t seem to work, you will have to open the ACAD.mns file and modify the reference to your new toolbar. In the example, the menu code looks like this:

    **AU2004 ID_AU2004_0 [_Toolbar("AU2004", _Floating, _Show, 404, 231, 1)] ID_TbDraw_2 [_Flyout("Draw", RCDATA_16_LINE, RCDATA_16_LINE, _OtherIcon, ACAD.TB_DRAW)] ID_UserFlyout_0 [_Flyout("User Defined Flyout", RCDATA_16_BLANK, RCDATA_16_BLANK, _OtherIcon, ACAD.DIMS)] [--] ID_UserButton_0 [_Button("User Defined Button", "RCDA.bmp", "RCDATA_16_BLANK")]^C^C-style;romans;romans;0;1;0;;;;dtext;\;.125;0; The last entry (which would actually display as a single line in a text editor) defines a user-defined button. The reference to “RCDA.bmp” can be replaced with the image you saved. In my case “eighth.BMP.” As long as the images are in the path, the image should be displayed.

    In this case the macro starts with ̂ c^c, which in menu language means, ESC, ESC. That way, you cancel any existing command when you select the button.

    The whole line reads as follows: ^C^C-style;romans;romans;0;1;0;;;;dtext;\0.125;0;

    Each of the semi-colons represents an Enter. The back-slash pauses the macro to allow the user to select a starting point for the text. The dash in front of the STYLE command causes it to be run in the command-line form.

    1. Cancel any existing command.

    2. Create a text style named “Romans” based on the font named “Romans.shx” with a variable height, width factor of 1, an oblique angle of 0, and NOT backwards, upside down or vertical.

    3. Place text at the location selected by user with a height of .125, and a rotation angle of zero.

    [For a more complete description of a similar tool button, see Release 2006 Toolbars and Tool Buttons section above.]

    Note that this process causes AutoCAD to rewrite a file named ACAD.mns, which is the AutoCAD default menu file. As a result, there are some potential problems to be concerned about.

  • Rapid Customizing: Minimum Pain, Maximum Gain

    25

    Accelerator keys and menus – Release 2005

    The default menus are all named ACAD and are located in the \support directory of your profile. Each file in this group has a different purpose. There are two ASCII files that you can edit, ACAD.mnu and ACAD.mns. If you change the ACAD.mnu file, it will automatically rewrite your ACAD.mns file. Changing the ACAD.mns file does NOT change the ACAD.mnu file. ACAD.mnu This is the template menu, written in ASCII text. It is actually the template for the

    source menu that has an .mns extension. I suggest that you NOT edit this file. ACAD.mns This is the source menu, and the one I recommend that you edit when modifying

    your menu structure. It can be edited using EDIT, WordPad or NOTEPAD. Caution: do not use a standard word processor to edit this file or word wrapping with corrupt the file.

    ACAD.mnc This is the compiled version of the source menu. It cannot be edited, since it

    consists of machine language. ACAD.mnl This is not actually a menu file. It is a lisp file, much like the ACAD.lsp. If a file has

    the same name as a menu file with the extension .mnl, the lisp programs defined in it will load whenever the menu is loaded. Many commands in AutoCAD are actually lisp programs defined in this file.

    ACAD.mnr This file contains the bit-mapped images used by the menu file for existing tool

    button icons. Your own bit-mapped images will NOT be added. ACAD.dcl This file contains the definitions of all of the dialog boxes used by AutoCAD for

    interacting within commands. DO NOT CHANGE THIS FILE! Unless you really understand dialog control language, you can do a lot of damage.

    Let’s start with a simple change to the pull-down menu. We will be opening the ACAD.mns file and editing it. First, copy it from its current location to a working folder. If you double-click on it, it will probably open in Notepad, but if you prefer WordPad, you can open it from there. The menu has a number of major sections, each of which starts with a heading preceded by three asterisks. The beginning of this very long file looks like this:

    The double front-slash marks act as an indication to AutoCAD to ignore anything on those lines. It is similar to the REM function in batch files. The MENUGROUP function identifies the name of the group of files that this one is related to. If you changed the name of this file, you would have to make sure that all six menu files are also renamed, and that the MENUGROUP is given a new name here. We will leave this as ACAD.

  • Rapid Customizing: Minimum Pain, Maximum Gain

    26

    POP0 Find the heading ***POP0, which is shown in the illustration. On the right is the POP menu that it defines, the OSNAP cursor menu. The “Point Filters” options are in a cascading menu, and aren’t shown unless you select the small arrowhead to the right. A cascading menu starts with the characters -> and ends with

  • Rapid Customizing: Minimum Pain, Maximum Gain

    27

    ***ACCELERATORS ["F1"]^C^C ["F12"]'cal;(nea+nea)/2; [CONTROL+"LEFT"]@x^h [CONTROL+"DOWN"]