P. 1
Tailoring AutoCAD 2004

Tailoring AutoCAD 2004

|Views: 863|Likes:
How to customize AutoCAD linetypes, hatch patterns, user interface, LISP, and much more. Step by step tutorials; dozens of tips.
How to customize AutoCAD linetypes, hatch patterns, user interface, LISP, and much more. Step by step tutorials; dozens of tips.

More info:

Published by: upFront.eZine Publishing, Ltd. on Feb 23, 2010
Copyright:Attribution Non-commercial
List Price: $18.60 Buy Now

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
See more
See less

02/01/2013

$18.60

USD

pdf

w o r l d w i d e.

t a i l o r i n g
b y r a l p h g r a b o w s k i

r e s e r v e d

A u t o C A D
2 0 0

4

u p F r o n t . e Z i n e

P u b l i s h i n g ,

L t d .

A l l

r i g h t s

e n t i l

d

C o p y r i g h t

z e , . g t n i n h o s r i f l p b u u p

2 0 0 3

b y

tailoring AutoCAD 2004

table

of

contents

i

Copyright & Payment Information
This book is covered by copyright. As the owner of the copyright, upFront.eZine Publishing, Ltd. does not give you permission to make electronic or print copies. You may not claim authorship or ownership of the text or figures herein. To support the work of the author, make a payment of: By email in PkZIP/Acrobat PDF format: US$18.60. Allow for a multi-megabyte download. On CD in Acrobat PDF format: US$23.60 (incl. shipping). Allow 2-3 weeks to arrive. The CD is delivered by mail, with shipping cost included. Delivery by FedEx: add US$25. Check or Money Order • US funds drawn on a bank with its address in the USA. • Canadian funds drawn on a bank with a Canadian address (includes GST). • British funds drawn on a bank located in Great Britain. • Euro funds drawn on a bank located in the EU. Make cheque payable to ‘upFront.eZine Publishing, Ltd.’ Please mail your payment to: "Tailoring AutoCAD 2004" upFront.eZine Publishing, Ltd. 34486 Donlyn Avenue Abbotsford BC V2S 4W7 Canada

PayPal

• To the account of editor@upfrontezine.com at www.paypal.com.
You can copy and paste the following URL into your browser: https://www.paypal.com/affil/pal=ralphg%40xyzpress.com. PayPal accepts funds in US, Euro, Yen, Canadian, and many other currencies. Copyright © 2004 by upFront.eZine Publishing, Ltd. All rights reserved worldwide. Visit the Tailoring AutoCAD 2004 1 Web site at www.upfrontezine.com/tailor2004

Also Available as e-Books in PDF Format Tailoring Visio 2002 Inside Visio 2002 Tailoring AutoCAD What’s Inside? AutoCAD Tailoring AutoCAD LT Tailoring IntelliCAD Inside IntelliCAD Inside General CADD Pro 1 Inside Generic CADD 6

For more information, visit eBooks.onLine at www.upfrontezine.com/ebooks

Stay up-to-date with CAD news every week by subscribing to the free upFront.eZine e-newsletter. Send message ‘subscribe upfront’ to subscribe@upfrontezine.com
○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○

i i

v2.1

11 nov 2003

table of contents
tailoring

autocad 2004

chapter 1 – introduction to customizing
The Many Ways of Customization ~ 14 Which Customization? ~ 15 Shortcut Tips ~ 15
Tip #1: Placing Arcs ~ 15 Tip #2: Placing Text ~ 15 Tip #3: Replacing Text ~ 15 Tip #4: Using PostScript Fonts ~ 16 Tip #5: Template Drawings ~ 16 Tip #6: Fast Custom Drawing Sheets ~ 17 Tip #7: Collapsing Multilines ~ 17 Tip #8: Changing Layers ~ 17 Tip #9: Quick Trim ~ 17 Tip #10: Get the Big Picture 2004 ~ 17 Tip #11: Install Express Tools 2004 ~ 18

~ 13

tailoring AutoCAD 2004

table of contents

iii

chapter 2 – customizing the environment
Starting AutoCAD ~ 22
Tutorial: Using Command-line Switches ~ 22
/b Switch ~ 24 /c Switch ~ 24 /nologo Switch ~ 24 /p Switch ~ 24 /r Switch ~ 24 /s Switch ~ 25 /t Switch ~ 25 /v Switch ~ 25

~ 21

Changing Window and Layout Elements ~ 25
Tutorial: Changing Screen Colors ~ 26
UCS Icon ~ 27

Command Line Font ~ 28 Command Line Transparency ~ 28 Keyboard Shortcuts ~ 29 Toolbars and Command Line ~ 29 Menus and Tablet ~ 29

Tutorial: Setting and Restoring Profiles ~ 30 Tutorial: Support File Paths ~ 31
Support File Paths in AutoCAD ~ 32 Search Path Options ~ 34
Support File & Working Support File Search Paths ~ 34 Device Driver File Search Path ~ 34 Project Files Search Path ~ 35 Menu, Help, and Miscellaneous File Names ~ 35 Text Editor, Dictionary, and Font File Names ~ 35 Print File, Spooler, and Prolog Section Names ~ 35 Printer and Plot Support Files ~ 36 Automatic Save File Location ~ 36 Color Book Locations ~ 36 Data Sources Location ~ 36 Drawing Template Settings ~ 36 Tool Palettes File Location ~ 36 Log File Location ~ 36 Temporary Drawing File Location ~ 36

iv

v2.1

11 nov 2003

Temporary External Reference File Location ~ 37 Texture Maps Search Path ~ 37 i-drop Associated File Location ~ 37

Setting Templates for New Drawings 2004 ~ 37
Tutorial: Specifying the Template File ~ 37 Tutorial: Creating Your Own Template File ~ 40 Tutorial: Importing Layers 2004 ~ 41

Drafting and Selection Preferences ~ 43
AutoSnap Settings ~ 43 Grips Settings ~ 43

chapter 3 – command aliases
Shortcut Keys ~ 46
Shortcuts New to AutoCAD 2004 ~ 46 AutoCAD’s Default Accelerator Keys ~ 47 Tutorial: Defining Shortcut Keys ~ 48

~ 45

The .pgp File — Aliases ~ 49
Alias Format ~ 49 Alias Rules ~ 49
Aliases Defined by Autodesk ~ 50

Creating New Aliases ~ 52
Tutorial: Alias Creation by Dialog Box 2004 ~ 52 Tutorial: Alias Creation by Hand ~ 53

chapter 4 – toolbar macros
Toolbar Macros Are No Panacea ~ 55

~ 55

Customizing Toolbars ~ 56
Rearranging Toolbars ~ 56
Tutorial: Dragging Toolbars ~ 56 Tutorial: Toggling Toolbars ~ 59

Tutorial: Changing Toolbar Buttons ~ 60
Tutorial: Changing Button Size ~ 62 Tutorial: Drawing Icons ~ 63

Tutorial: Writing Toolbar Macros ~ 65
Simple Macros ~ 66 Advanced Macros ~ 67

tailoring AutoCAD 2004

table of contents

v

chapter 5 – menu macros
Loading (and Unloading) Menu Files ~ 70
Loading Menu Groups ~ 70 Loading Menu Bar Items ~ 71
Menu File Types ~ 71

~ 69

Your First Menu ~ 72
Tutorial: A Single-Command Menu ~ 72 Section Labels ~ 76 Menu Metacharacters ~ 78 Shortcut Menu Aliases ~ 79

Your Second Menu ~ 79
Tutorial: Loading .mnu a Second Time ~ 80 Adding Menu Macros ~ 80 Adding Options to Commands ~ 81
Using Coordinates in Macros ~ 81

Making Macros “Official” ~ 82
Cancelling a Previous Command: ^C ~ 82 Adding Keyboard Shortcuts: & ~ 82 Separating Macros Visually: -- ~ 83 Adding Submenus: -> ~ 84 Right-Justified Text: \t ~ 84

Grayed-out Items: ~ ~ 84
Adding Checkmarks: !. ~ 85

Waiting for User Input: \ ~ 85
Providing Input to the User: ^H ~ 86

Writing Really Long Macros: + ~ 86
Repeating Commands: * ~ 86

Toolbars, Accelerator Keys, Image Tiles, Tablet Overlays, and the Screen Menu ~ 87
Toolbar Customization ~ 87 Custom Shortcut Keys ~ 87 Image Tiles ~ 87 Tablet Menus ~ 87 Screen Menu ~ 88

vi

v2.1

11 nov 2003

chapter 6 – linetypes

~ 89

Commands Affecting Linetypes ~ 89
System Variables Affecting Linetypes ~ 90
The Special Case of Polylines ~ 90

Customizing Linetypes ~ 90
Tutorial: Making Linetypes with -Linetype Command ~ 91
Tutorial: Testing New Linetypes ~ 93

Tutorial: Making Linetypes with MkLType 2004 ~ 93 Tutorial: Making Linetypes with a Text Editor ~ 94

Simple (1D) Linetype Format ~ 95
Line1 – Header ~ 95 Line 2: Data ~ 96

Complex (2D) Linetype Format ~ 96
Text ~ 96 Text Style ~ 97 Text Scale Factor ~ 97 Text Rotation Angle ~ 97 Text Orientation ~ 97 Text Offset Distance ~ 97 Embedding Shapes ~ 98 3D Linetypes ~ 98 Tutorial: Attempting a Parallel Linetype ~ 98

chapter 7 – hatch patterns

~ 101

Where Do Hatch Patterns Come From? ~ 102
Commands and System Variables ~ 102
Associative and Non-associative Patterns ~ 103

Hatch Patterns and Gradient Fills ~ 103

Creating Custom Hatch Patterns ~ 104
Tutorial: Creating Patterns with Hatch ~ 104 Tutorial: Creating Patterns with BHatch ~ 105 Tutorial: Creating Patterns with SuperHatch 2004 ~ 105

Understanding the acad.pat File ~ 108
Comment and Header Lines ~ 108 The Hatch Data ~ 109 Tips on Creating Pattern Codes ~ 110

tailoring AutoCAD 2004

table of contents

vii

Adding Custom Patterns to the Dialog Box ~ 111

chapter 8 – shapes & fonts
About Shape Files ~ 114
Tutorial: Creating Shapes 2004 ~ 114

~ 113

The Shape File Format ~ 116
Header Fields ~ 116 Definition Lines ~ 117 Vector Codes ~ 117 Instruction Codes ~ 118
0/000: End of Shape ~ 118 1/001: Draw Mode ~ 118 2/002: Move Mode ~ 118 3/003: Reduced Scale ~ 118 4/004: Enlarged Scale ~ 119 5/005: Save (Push) ~ 119 6/006: Recall (Pop) ~ 119 7/007: Subshape ~ 119 8/008: X,y Distance ~ 119 9/009: X,y Distances ~ 120 10/00A: Octant Arc ~ 120 11/ 00B: Fractional Arc ~ 121 12/00C: Bulge Arc ~ 121 13/00D: Polyarc ~ 122 14/00E: Flag Vertical Text Flag ~ 122

chapter 9 – script files ~ 123
What are Scripts? ~ 123
Script Files ~ 123 Drawbacks to Scripts ~ 124 Strictly Command-Line Oriented ~ 124

Script Commands and Modifiers ~ 125
Script ~ 125 RScript ~ 125 Resume ~ 125 Delay ~ 125

viii

v2.1

11 nov 2003

Special Characters ~ 126
(space) ~ 126 ; (semicolon) ~ 126 ' (apostrophe) ~ 126 * (asterisk) ~ 127 Backspace ~ 127 Esc ~ 127

chapter 10 – diesel expressions ~ 129
The History of Diesel ~ 130
What Diesel Does ~ 130 Brief Listing of Diesel Functions ~ 131
Math Functions ~ 131 Logical Functions ~ 131 Conversion Functions ~ 131 String Functions ~ 131 System Functions ~ 131

Jumping Into Diesel ~ 132
Diesel Error Messages ~ 132
$? ~ 132 $(func)?? ~ 132 $(func,??) ~ 132 $(++) ~ 132

Debugging Diesel ~ 133

Diesel Programming Tips ~ 133 Diesel in Menus ~ 134
[ ~ 134 $(if, ~ 134 $(getvar,dimaso) ~ 134 ,!. ~ 134 ) ~ 135 /vAssociative Dimensions ~ 135 ] ~ 135 '_dimaso ~ 135 $M= ~ 135 $(-,1, ~ 135 $(getvar,dimaso) ~ 135 ) ~ 136

Reusing Toggle Code ~ 136

tailoring AutoCAD 2004

table of contents

ix

Diesel in AutoLISP ~ 136
Via the setvar Function ~ 136 Concatenate Two Diesel Strings ~ 137 Via the MenuCmd Function ~ 137

chapter 11 – autolisp programming ~ 139
The History of AutoLISP ~ 140

The AutoLISP Programming Language ~ 140
Simple AutoLISP: Adding Two Numbers ~ 141

AutoLISP in Commands ~ 142
Remembering the Result: SetQ ~ 143

AutoLISP Functions ~ 144
Math Functions ~ 144 Geometric Functions ~ 145 Conditional Functions ~ 145 String and Conversion Functions ~ 146 External Command Functions ~ 147
Accessing System Variables ~ 148

GetXXX Functions ~ 149 Selection Set Functions ~ 150 Object Manipulation Functions ~ 150 Advanced AutoLISP Functions ~ 150

Writing a Simple AutoLISP Program ~ 151
Why Write a Program? ~ 151
The Id Command ~ 151

The Plan of Attack ~ 151
Obtaining the Coordinates ~ 151

Placing the Text ~ 153 Putting Them Together ~ 154

An Alternative to LISP Programming ~ 154 Writing a Simple AutoLISP Program, Cont’d ~ 154
Sprucing Up the Code ~ 155 Conquering Feature Bloat ~ 155
Wishlist Item #1: Naming the Program ~ 156 Wishlist Item #2: Saving the Program ~ 157 Wishlist Item #3: Automatically Loading the Program ~ 157 Wishlist #4: Using Car and Cdr ~ 157
○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○

x

v2.1

11 nov 2003

Saving Data to a File ~ 160
The Three Steps ~ 161
Step 1: Open the File ~ 161 Step 2: Write Data to the File ~ 161 Step 3: Close the File ~ 162

Putting It Together ~ 162
Wishlist #5: Layers ~ 163 Wishlist #6: Text Style ~ 163

Tips in Using AutoLISP ~ 163
Use an ASCII Text Editor ~ 164 Loading LSP Code into AutoCAD ~ 164 Toggling System Variables ~ 164 Be Neat and Tidy. ~ 165 Suppress That nil ~ 165 Read-Write-Append File ~ 165 Quotation Marks as Quotation Marks ~ 165 Keep Variables to Six Characters ~ 166 Tabs and Quotation Marks ~ 166

chapter 12 – cad management ~ 167
CAD Standards ~ 168
Tutorial: Create the Standards Drawing ~ 168
Linetype Standards ~ 168 Layer Standards ~ 169 Dimension Style Standards ~ 170 Text Style Standards ~ 170

Tutorial: Save Standards Drawings ~ 171 Tutorial: Apply the Standards ~ 171 Tutorial: Checking Standards ~ 172

Employing DesignCenter and Tool Palettes ~ 173
DesignCenter ~ 173 Tool Palettes ~ 175
Tab Customization ~ 176 Icon Customization ~ 177 Palette Customization ~ 178 Titlebar Customization ~ 179

tailoring AutoCAD 2004

table of contents

xi

XTP File Format ~ 180
XML Metacharacters ~ 180 Tool Palettes XTP ~ 181
XTP Section 1: Header ~ 181 XTP Section 2: Tool Data ~ 182 XTP Section 3: Palette Data ~ 184

xii

v2.1

11 nov 2003

one

introduction to customizing
tailoring

autocad 2004

i

f, like me, you’re a messy sketcher, then you appreciate how computer software makes your work neater. For too many drafters, that’s all AutoCAD amounts to: a neater drafting machine. The real power behind CAD (computer-aided design), however, is its ability to be customized to the way you work. Customize is jargon for letting CAD do some of the drafting for you. This ranges from placing a linetype specific to your discipline, to generating a 3D staircase to fit between two floors, and more. The benefit? You get your work done is less time, or, if you are a free-lancer, you get more work done in the same time. The drawback? Customizing takes a bit of time. First, you need to take time to learn how to customize AutoCAD — that’s what this book is all about. Then, you need more time to create the customization. Time isn’t something most professionals have a lot of. I sometimes find myself doing a repetitive editing function under the false belief that it takes longer to write (and debug) a macro than it would automating the task. So, I have this rule-of-thumb: Write a macro when the same action is repeated more than three times. There lies the responsibility of Autodesk to make automation easier for the end-user. Still, the time you invest in automation makes you a more productive AutoCAD user, even in the short run. Note: Features new to AutoCAD 2004 are marked with the 2004 logo.

tailoring AutoCAD 2004

chapter 1 introduction to customization

• 13

The Many Ways of Customization
By my count, there are more than two dozen ways to customize AutoCAD (some of these depend on the version of AutoCAD you are working with):
ADI Autodesk Device Interface and plotting formats (replaced by HDI in AutoCAD 2000). ADS AutoCAD Development System (no longer available as of AutoCAD 2000). ARX AutoCAD Runtime Extension (also known as ObjectARx) for C++ programming. ASI AutoCAD SQL (structured query language) Interface for database programming. DCL Dialog Control Language for customizable dialog boxes. DDE Dynamic Data Exchange for linking with other software. DIESEL Direct Interpretively Evaluated String Expression Language (see Chapter 10). DWG DraWinG; create custom symbols and user-defined objects. DWT DraWing Template; preset drawing elements (see Chapter 2). DXB Drawing Interchange Binary. DXF Drawing Interchange Format. DXFIX Drawing translation (no longer available as of AutoCAD 2000). HLP, AHP Customizable help (no longer available as of AutoCAD 2000). INI Toolbar macros and INItialization files (no longer available as of AutoCAD 2000). LIN Customizable LINetypes (see Chapter 6). LSP AutoLISP (see Chapter 11). MNU Customizable menu and tablet, popdown, cursor, and icon menus (see Chapter 5). OLE Object linking and embedding with other software. PAT Customizable hatch PATterns (see Chapter 7). PGP ProGram Parameter files. RPF Raster Pattern Files. SCR Script files (see Chapter 9). SHP,SHX SHaPes and customizable text fonts (see Chapter 8). SLD, SLB SLiDes and Slide LiBraries. VBA Visual Basic for Applications. VLISP Visual LISP. DCC dialog color configuration (no longer available as of AutoCAD R14). DFS MvSetup command’s DeFaultS. FMP Font MaPping. MNL MeNu utiLities. MSG message (no longer available as of AutoCAD R14). MLN MultiLiNe style. UNT UNiT conversion factors.

... and more. You find many of these files in AutoCAD’s \support folder. Some customizations are designed for end-users, such as toolbar macros, menus, and AutoLISP routines, all of which we look at in this book. Others are meant for professional programmers, like ASI and ObjectARx, which we ignore. In between the two levels, there are other customization possibilities, such as hatch patterns and DIESEL programming, that some enthusiastic users enjoy tinkering with. We look at these as well.
○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○

14

v2.0

11 nov 2003

Which Customization?
That said, you need to make two decisions along the way. As you work with AutoCAD, make mental or written records of your work. In particular, chronicle repetitive drafting tasks because these are prime candidates for customization. As one of Autodesk’s founders emphasized, “You should never have to draw the same line twice.” The second decision is to pick which of AutoCAD’s many customization possibilities to apply to the repetitive task. Some solutions are obvious, such as writing a .pat file for a custom hatch pattern. Others are less obvious: to draw that 3D staircase, do you use a script file (perhaps not), a DIESEL macro (no), an AutoLISP routine (yes), an ObjectARx application (nope, at least not in this context), or a menu macro (maybe)? For this reason, you need to become familiar with most of AutoCAD’s customization possibilities — even if you never use some of them. That way you craft the solution with the best tool. You also know when to hand over the job to a professional programmer, yet have intelligent oversight of their work. A third solution is to find out about the thousands of third-party solutions available from the Autodesk Web site, other locations on the Internet, and CDs. The bulk of these are AutoLISP routines written by amateur programmers solving their own problems with AutoCAD. By knowing AutoLISP, you can modify the routine to your needs, which is a lot easier than writing it from scratch.

Shortcut Tips
Sometimes working more efficiently doesn’t involve customizing, but having a greater understanding of AutoCAD’s details. To get you started on the road to greater productivity, here are some timesaving tips that don’t involve customizing: Tip #1: Placing Arcs AutoCAD provides you with eleven different ways to draw arcs. Sometimes, placing an arc becomes an exercise in frustration, particularly when angles are involved. The easier alternative is to draw a circle, then use the Trim or Break commands to convert the circle to an arc. Tip #2: Placing Text When you need to place lines of text all over the drawing, use the Text command. This versatile command sets text in the drawing wherever you place the cursor. Caution: When you are finished placing text, do not press ESC, because you will loose all entered text. Instead, press ENTER twice to terminate the Text command. Tip #3: Replacing Text When you need to add similar text in a number of drawings, it is easier to place the same block of text in each drawing. Then use the DdEdit command to change wording of the text (or double-click it). Editing text is easier than placing new text, because all parameters have already been set, such as text style, heights, justification, and so on.

tailoring AutoCAD 2004

chapter 1 introduction to customization

• 15

Tip #4: Using PostScript Fonts Although Autodesk promotes the use of TrueType fonts in drawings, you can still use PostScript fonts through an undocumented work-around: Use the Convert command to convert PostScript .psf font files to AutoCAD’s .shx font format. Although the font is not longer in .psf format, you can take advantage of the variety of PostScript fonts available. Tip #5: Template Drawings To help you get started faster on new drawings, AutoCAD includes template drawings with system variables preset for the related standard. Some of the .dwt template drawings found in AutoCAD’s \template folder are:
Template File
acad.dwt ANSI E -Named Plot Styles.dwt Architectural Title Block.dwt Generic 24in x 36in Title Block.dwt ISO A0 -Named Plot Styles.dwt Gb_a0 -Named Plot Styles.dwt JIS A0 -Named Plot Styles.dwt DIN A0 -Named Plot Styles.dwt

Meaning
Default template drawing. ANSI (American) drawing standards. US architectural D-size. Generic D-size drawing with title block. ISO (International metric) drawing standards. Gb (Chinese) drawing standards. JIS (Japan) drawing standards. DIN (German) drawing standards.

2004

In AutoCAD 2004, the new QNew command does one of two actions:

• By default, it displays the Use a Template dialog box. • If you specify the name of a .dwt file in the Options | Files dialog box, QNew starts a new drawing using that template file.

16

v2.0

11 nov 2003

Tip #6: Fast Custom Drawing Sheets The MvSetup command helps you create customized drawing boarders, title blocks, and multiview setups. You can use the Setup Wizard to start new drawings, but the MvSetup command remains the more powerful tool. Tip #7: Collapsing Multilines To speed up the display of drawings containing multilines, set the CMlScale system variable to 0. That collapses the multiline to a single line, which displays faster. Before plotting, set CMlStyle back to 1. Tip #8: Changing Layers Quicker than the Layer command, simply click on the down arrow next to the layer name on the toolbar. That action displays a list box of layer names in the drawing. Click on the name of the layer you want to switch to. For keyboard-ists, use the CLayer command, which bypasses the Layer command’s dialog box, and the -Layer command’s options. Tip #9: Quick Trim To precisely trim back a pair of intersecting lines, use the Fillet command with radius set to zero. Tip #10: Get the Big Picture
2004

The CleanScreenOn command maximizes AutoCAD’s drawing area by turning off the title bar, toolbars, and window edges.

tailoring AutoCAD 2004

chapter 1 introduction to customization

• 17

To further increase the drawing area, you can turn off the scroll bars and layout tabs (via the Options | Display dialog box) and make the command prompt area transparent (see Chapter 2). If you want to see the toolbars as well, use the FullScreen command (available only after installing Express Tools). To return to the normal screen, use the CleanScreeenOff command. As an alternative, you can press CTRL+0 (zero) to toggle between the two views. Tip #11: Install Express Tools
2004

AutoCAD 2004 includes a package called Express Tools that provides a large number of additional commands not supported by Autodesk. Express Tools, however, is not installed along with AutoCAD, so you need to run the setup.exe program and select “AutoCAD Express Tools Volumes 1-9.” The following commands are included with the Express Tools package:
Command
AliasEdit AlignSpace ArcText AttIn AttOut BExtend BlockReplace BlockToXref BreakLine BScale BTrim Burst ChSpace ChUrls ClipIt CopyM CopyToLayer DimEx DimIm EtBug ExOffset ExPlan FS FullScreen GetSel ImageApp ImageEdit
○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○

Description
Edits the aliases stored in acad.pgp. Aligns model space objects in different viewports or with objects in paper space. Places text along an arc. Imports attribute data. Quickly extracts attributes in tab-delimited format. Extends open objects to objects in blocks and xrefs. Replaces all inserts of one block with another. Convert blocks to xrefs. Creates the break-line symbol. Scales blocks from their insertion points. Trims to objects nested in blocks and external references. Explodes blocks, converts attributes to text. Moves objects between model and paper space. DdEdit-like editor for hyperlinks (URL addresses). Adds arcs, circles, and polylines to the XClip command. Copy command with repeat, divide, measure, and array options. Copies objects to other layers. Exports dimension styles to an ASCII file. Imports dimension style files created with DimEx. Sends bug reports to Autodesk. Adds options to the Offset command. Adds options to the Plan command. Selects objects that touch the selected object. Toggles between full-screen and regular windows. Selects objects based on layer and type. Specifies the external image editor. Launches the image editor to edit selected images.
○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○

18

v2.0

11 nov 2003

LayCur LayDel LayFrz LayIso LayLck LayMch LayMrg LayOff LayOn LayoutMerge LayThw LayUlk LayVpi LayWalk LMan Lsp LspSurf MkLtype MkShape MoCoRo MoveBak MStretch NCopy Plt2Dwg Propulate PsBScale PsTScale QlAttach QlAttachSet QlDetachSet QQuit ReDir RepUrls Revert RText RtUcs SaveAll ShowUrls Shp2blk SuperHatch SysvDlg TCase TCircle TCount TextFit TextMask TextUnmask TFrames TJust
○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○

Changes the layer of selected objects to the current layer. Deletes layers from drawings — permanently. Freezes the layers of selected objects. Isolates layers of selected objects (all other layers are frozen). Locks the layers of selected objects. Changes the layer of selected objects to that of a selected object. Merges two layers; removes the first layer from the drawing. Turns off layers of selected objects. Turns on all layers. Places objects from layouts onto one layout. Thaws all layers. Unlocks layer of selected object. Isolates object’s layer in viewport. Isolates each layer in sequential order. Saves and restores layer settings. AutoLISP function searching utility. LISP file viewer. Creates linetypes from selected objects. Creates shapes from selected objects. Moves, copies, rotates, and scales objects. Moves .bak files to specified folders. Stretches with multiple selection windows. Copies objects nested inside blocks and xrefs. Imports HPGL files into the drawings. Updates, lists, and clears drawing properties. Sets and updates the scale of blocks relative to paper space. Sets text height relative to paper space. Associate leaders to annotation objects. Associates leaders with annotations. Dissassociates leaders from annotations. Closes all drawings, and then exits AutoCAD. Changes paths for xrefs, images, shapes, and fonts. Replaces hyperlinks. Closes the drawing, and re-opens the original. Inserts and edits remote text objects. Changes UCSs in real time. Saves all drawings. Lists URLs in a dialog box. Converts from a shape definition to a block definition. Uses images, blocks, external references, or wipeouts as hatch patterns. Launches an editor for system variables. Changes text between Sentence, lower, UPPER, Title, and tOGGLE cASE. Surrounds text and multiline text with circles, slots, and rectangles. Prefixes text with sequential numbers. Fits text between points. Places masks behind selected text. Removes masks from behind text. Toggles the frames surrounding images and wipeouts. Justifies text created with the MText and AttDef commands.
○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○

tailoring AutoCAD 2004

chapter 1 introduction to customization

• 19

TOrient TScale TSpaceInvaders Txt2Mtxt TxtExp VpScale VpSynch XData XdList XList

Re-orients text, multiline text, and block attributes. Scales text, multiline text, attributes, and attribute definitions. Finds and selects text with overlapping objects. Converts single-line to multiline text. Explodes selected text into polylines. Lists the scale of selected viewports. Synchronizes viewports with a master viewport. Attaches xdata to objects. Lists xdata attached to objects. Displays properties of objects nested in blocks and xrefs.

Copyright Information
This book is covered by copyright. As the owner of the copyright, upFront.eZine Publishing, Ltd. does not give you permission to make electronic or print copies. You may not claim authorship or ownership of the text or figures herein. Contact editor@upfrontezine.com to purchase additional copies. Copyright © 2004 by upFront.eZine Publishing, Ltd. All rights reserved worldwide.

Feedback
I welcome your feedback for correcting and improving the text. Send your email to editor@upfrontezine.com. Visit the Tailoring AutoCAD 2004 e-book Web site at www.upfrontezine.com/tailor2004. For more of our technical e-books, visit the eBooks.onLine Web site at www.upfrontezine.com/ebooks.

20

v2.0

11 nov 2003

You can customize AutoCAD’s look in many ways: • Starting AutoCAD. • Selecting and creating templates for starting new drawings.two customizing the environment tailoring autocad 2004 a utoCAD allows you to change the way it looks and works. • Taking your preferences with you. The first few of these chapters concentrate on changing the look of AutoCAD. • Specifying the locations of support files. tailoring AutoCAD 2004 chapter 2 customizing the environment • 21 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . • Changing the user interface. • Deciding how to select and work with objects. later chapters on changing the way it works.

command-line switches are no longer in common use. TIP These command-line switches override settings in the Options dialog box.cfg hardware configuration file. It was common knowledge in the days of the DOS operating system that there were additional options for starting AutoCAD.arg user profile file.dwt template file.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . Notice the shortcut menu. Tutorial: Using Command-line Switches To use command-line switches. On the desktop. See Chapter 9. Specifies the . as well as the values set by environment variables.scr script file. and then selecting Programs | AutoCAD | AutoCAD. Here’s how: 1. Notice the Properties dialog box. The switches tell AutoCAD what to do when it starts: Switch /b /c /nologo /p /r /s /t /v Comment Runs a .cfg configuration file to default values. you can do it in several ways: • Double-clicking the icon you found on your computer’s desktop. Resets the .dwg file name in the Explorer (or File Manager). Specifies the path to a folder for support files. From the shortcut menu. right-click the AutoCAD icon. Specifies the . Commandline switches are useful for changing the way AutoCAD operates. select Properties. • Double-clicking a . 2.Starting AutoCAD When you start AutoCAD. Specifies the . you edit AutoCAD’s command line. • Clicking the Start button on the taskbar. With Windows hiding much of what goes on behind its graphical user interface. Suppresses display of the startup logo. 22 • v2. Specifies the named view to display.

If it doesn’t work correctly. right-click and select Rename. Here is another example: the following command-line starts AutoCAD with a script file called script. the most likely reason is that you made a spelling mistake.exe /b c:\autocad 2002\support\script. Double-click the icon. each with a different set of command-line parameters. When done editing the target. Repeat the steps listed above until it does work correctly. notice that the command-line text reads something like the following: Target: "C:\AutoCAD 2004\acad. 4.exe" The path (C:\AutoCAD 2004\) may be different for your system.exe /s c:\support. TIP You can have several shortcut icons on your computer’s desktop. drag an icon while holding down the Ctrl key. In the Properties dialog box. tailoring AutoCAD 2004 chapter 2 customizing the environment • 23 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ .3. Anytime you complete a customization.c:\dwgs" Notice that a space is required after the switch (/s). to change the path to the \support and \dwgs folders. click OK to close the dialog box. you must test that it works. Edit the text in the Target box. The quotation marks are necessary when the command line contains spaces. and AutoCAD should start as you instructed with the switch. you would enter the following (I’ve shown the changes in boldface. and the switch in cyan): Target: "c:\autocad 2004\acad. 6. and that a semicolon ( . ) is needed when the switch specifies more than one path. select the Shortcut tab. In the Target text box. To make copies of icons.scr: Target: "c:\autocad 2004\acad. For example.scr" 5. To rename the icon.

If a folder. it uses the AcadCfgW and AcadCfg environment variables to search for a . and are discussed later in this chapter. www.exe /nologo" Some people find the logo (also called the “splash screen”) irritating because it covers up other windows for a few seconds.bak. Profiles are created with the Options | Profiles dialog box. See Chapter 9 to learn how to write script files. the splash screen looks like this. See /r switch. Zublena et Regembal. instead.scr" /c Switch The /c switch specifies the path to a . In AutoCAD 2004.cfg hardware configuration file.scr script file to run immediately after AutoCAD starts. then the file name in the folder must be acad2004. Shown on the splash screen is the Stade de France stadium designed by Macary. The existing configuration file is renamed acad2004. If these variables are not set.exe /b c:\autocad 2004\script.cfg file does not exist.cfm /p Switch The /p switch specifies the named profile to use with AutoCAD. Costantini .exe /c c:\autocad 2004\support\myconfig.cfg file or to a folder. Example usage: Target: "c:\autocad 2004\acad.scr" Usually. This means you can point the new AutoCAD to old support files. The switch can point to a specific .exe /r" 24 • v2.cfg file. Paris. Example usage: Target: "c:\autocad 2004\acad.stadefrance. TIP AutoCAD 2004 allows parallel installation with a previous release of AutoCAD.exe is located. /nologo Switch The /nologo switch starts AutoCAD without its logo.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ .exe" /p "my profile" /r Switch The /r switch restores the acad2004. Example usage: Target: "c:\autocad 2004\acad.cfg configuration file to its default values./b Switch The /b switch specifies the name of a .cfg (for AutoCAD 2004).Architectes.com/presentation/vv. AutoCAD is started without the /c switch. Example usage: Target: "c:\cad\autocad 2004\acad. If the acad2004. Example usage: Target: "c:\autocad 2004\acad. AutoCAD creates one using default values. This switch is useful when AutoCAD’s hardware configuration gets mucked up. AutoCAD searches the folder in which acad.

/s Switch The /s switch points to the folder(s) holding support files. Changing Window and Layout Elements AutoCAD’s default colors and fonts are. ).c:\alisp" When AutoCAD starts without the /s switch. AutoCAD uses the acad. The Appearance tab handles fonts and colors. font.bat file. other aspects are controlled by the Windows operating system. for the most part. and linetype files.exe /t c:\autocad 2004\template\Architectural Title Block. Example usage: Target: "c:\autocad 2004\acad. Nevertheless. Example usage: Target: "c:\autocad 2004\acad. and select Properties.dwg" When a template is not specified. while Settings | Advanced | General | Display controls the overall size of fonts and user interface elements. AutoCAD opens the drawing with the view last saved.exe /s c:\autocad 2004\support\. AutoCAD also consults the path specified by the Path environmental variables in the autoexec. Example usage: Target: "c:\autocad 2004\acad. You can specify as many as 15 support folders. pretty good. /t Switch The /t switch specifies the drawing file to use as a template on which to base new drawings. tailoring AutoCAD 2004 chapter 2 customizing the environment • 25 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . /v Switch The /v switch specifies the named view to display when AutoCAD opens. TIP The /s and /t switches are useful for customizing AutoCAD to the needs of different clients.exe /v titleblock" When /v is not specified. right-click the desktop.dwg file as its template. such as menu. To have Windows change colors and fonts. the software allows you to change aspects of its user interface. it reads the folder(s) specified by the Options | Files dialog box. Separate each folder name with a semicolon ( .

2. • AutoTracking Vector Color sets the color of tracking vectors. 3. • Layout Tabs Pointer sets the color of the crosshair cursor (but not the pointer cursor) in model space. 26 • v2. • Model Tab Pointer sets the color of the crosshair cursor (pointer) in model space. the temporary construction lines that appear while drawing. In the Options dialog box. • Layout Tabs Background (Paper) sets the background color of the drawing area in all layouts. In the Display tab. showing geometric relationships. Notice the Options dialog box. • Command Line Text sets the color of text in the ‘Command:’ prompt area. select the Display tab.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . click the Colors button. some users continue to prefer black because colors look more vibrant against it.Here is how to make changes in AutoCAD itself: Tutorial: Changing Screen Colors A change in AutoCAD you may want to make right away is the background color of the drawing area: from black to white. To change the colors of the AutoCAD window. select Options. Black was the traditional color in the days when CAD ran on the DOS operating systems. You can change the color of these user interface elements: • Model Tab Background sets the background color of the drawing area in model space. From the Tools menu. and on the right for all layout tabs. • Command Line Background sets the background color of the ‘Command:’ prompt area. Notice that the Color Options dialog box has two parts: on the left for the model tab. follow these steps: 1.

as follows: Command: ucsicon Enter an option [ON/OFF/All/Noorigin/ORigin/Properties] <ON>: p tailoring AutoCAD 2004 chapter 2 customizing the environment • 27 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . or enter the command at the prompt.UCS Icon The color and size of the UCS (user-defined coordinate system) icon is changed with the UCSicon command’s Properties option. From the View menu. select Display | UCS Icon | Properties.

select Options.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ 28 . separately for model and layout (paper space) modes. style. 3. 4. TIP The UCS icon is meant to aid your view orientation during 3D design. and size. If your drafting is primarily 2D. but makes the command line harder to read. To change the size and type of font: 1. Command Line Font AutoCAD normally uses the Courier font for text in the command prompt area. From the Tools menu. Turn it off with the UCSicon command’s OFF option. • Line thickness. Chose the Display tab. Notice the font preview window. Command Line Transparency 2004 When the command-line area is dragged away from the edge of the AutoCAD window. Select a font. and then click Fonts.Some of the changes you can make to the UCS icon are illustrated by the figure: • Color. there is no need to display the icon. The result may or may not be to your liking: transparency allows you to see the drawing through the command-line window. • 2D or 3D style. • v2. • Arrowhead type. it can be made partially transparent. Click Apply & Close. 2.

Additionally. • Transparency Level varies the transparency of the window. as well as the command(s) executed when a button is selected. See Chapter 4 for details. 2. 3. See Chapter 3 for details. • Turn off window transparency makes the window opaque. Right-click the title bar. Keyboard Shortcuts You can create keyboard shortcuts for executing commands.1. See Chapter 5 for details. you can assign commands to function keys. you can change the icons on toolbar buttons. For example. and then select Transparency. as well as the rarely used screen and tablet menus. Toolbars and Command Line You can change the position and number of toolbars. tailoring AutoCAD 2004 chapter 2 customizing the environment • 29 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . Menus and Tablet You can change the content of drop-down menus. ranging from Less (no transparency) to More (almost completely transparent). Click OK. Make changes in the dialog box.

2.arg file. Click Add to List. 30 • v2. Click Set Current.Tutorial: Setting and Restoring Profiles After making changes to the Options dialog box. By carrying around this file with you (perhaps on a USB memory stick). In the Options dialog box. select Options. 4. To use a profile: 1. 3. Here’s how to save and restore the settings: 1. you can save the settings to an . 2. Select the profile name from under the list of Available profiles. In the Add Profile dialog box. you can instantly customize AutoCAD on other computers to your preferred settings. select the Profiles tab. Click Apply & Close. name the profile. 2.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . From the Tools menu. and the provide a description: Profile name: Description: My Profile This is how I like AutoCAD to run.

In the Options dialog box. select Options. which lets you select a drive and folder. Provide a file name. such as Support File Search Path. • You are a third-party developer. and need to have paths pointing to different files. The default settings for AutoCAD 2004 are shown on the next two pages. select the Files tab. 3. such as fonts. From the Tools menu. Notice the buttons that become available: Browse displays the Browse for Folder dialog box.To export a profile: 1. Select a path heading. To import the profile: 1. 2. Here is how to change file paths: 1. You may want to change the file paths for several reasons: • Your firms has clients with different standards for fonts. Select a path. Add adds a new path to the group. such as \AutoCAD 2004\fonts. Tutorial: Support File Paths After it is freshly installed on your computer. 2. Click Import. including those on the network. and hatch patterns. on-line help. AutoCAD uses a number of folders in which to store support files. tailoring AutoCAD 2004 chapter 2 customizing the environment • 31 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . 2. Select Export. layer sets. and then click Save. and so on. Select a file name. click the + icon.. and then click Open. To open it.

Move Down moves the selected path down the list.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . Set Current sets the selected item as the current (working) one. Move Up moves the selected path up in the list. AutoCAD searches for support files first in the topmost path. TIP Use the Profiles feature to save and switch between different AutoCAD settings.Remove removes — without warning — the selected path from the group. Support File Paths in AutoCAD 32 • v2.

tailoring AutoCAD 2004 chapter 2 customizing the environment • 33 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ .

2004 AutoCAD also searches the path(s) defined by the Path environment variable in the autoexec.chm help files. • Help specifies the location of . and general to AutoCAD. • Support specifies the location of support files specific to the user’s logon name.bat file executed when Windows starts up. • Fonts specifies the location of .Search Path Options Here is an overview of the many paths that AutoCAD searches for setting options: Support File & Working Support File Search Paths Specifies the path to the folders in which AutoCAD searches for support files. digitizing tablet.shx font files. • Express specifies the location of the Express Viewer application for viewing and plotting .1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ .dwf files. mouse. 2004 • Color specifies the location of . Device Driver File Search Path Specifies the path to folders in which AutoCAD searches for device drivers. including the graphics board. plotters. and printers. Device drivers are programs that interface between AutoCAD and hardware.acb color book files. 34 • v2.

mnu file.chm file. the list of client license servers is as stored in system variable AcadServer. • Menu File specifies the path and file name of the default . a.AutoCAD displays the internal Multiline Text Editor. • Default Internet Location specifies the default URL (Web address) used by the Browse command. The path to the . The list of languages varies. • Alternate Font File specifies the name of the replacement font. also stored in system variable ProjectName. • Main Dictionary selects the language to use for the Spell command (stored in system variable DctMain). • .AutoCAD uses that editor. Spooler. • Help File specifies the path and file name of the default .cfg configuration file stores information about the hardware used with AutoCAD.cfg file (read-only). • :lisped . Similarly. • Print Spool Executable specifies the name of the application to use for external plot spooling in this format: spooler. “Read-only” means you cannot change the path in the Options dialog box.fmp font mapping file.” if not using network licence of AutoCAD (read-only). • Configuration File specifies the path to the default .plt temporary plot files used with R14 (or earlier) plotting scripts. depending on the version of AutoCAD installed. • License Server Path is “None. and Prolog Section Names • Plot file name for legacy plotting scripts specifies the name of . and (2) an alternate font was not specified in the acad. Print File. and Miscellaneous File Names Specifies the names and paths for menu and help files.Project Files Search Path Specifies project names. Dictionary.a.AutoCAD uses a simpler text editor. Menu. Text Editor. (period) .bat %s ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ tailoring AutoCAD 2004 chapter 2 customizing the environment • 35 .AutoCAD displays the internal Multiline Text Editor • Path and name of a text editor .fmp font mapping file (stored in system variable FontMap) and used when: (1) AutoCAD can’t locate the needed fonts. • Custom Dictionary File specifies the path to the . Web address).cus dictionary file (stored in system variable DctCust). its path can only be changed by the /c command-line switch. which contain search paths for externally-reference drawings. TIP MTextEd understands the following values: • internal . • Font Mapping File specifies the path to the . and Font File Names • Text Editor Application specifies the text editor to use with the MText command (stored in system variable MTextEd).k. Help. as well as the default URL (uniform resource locator.

atc tool palette catalog files.ctb named and color-dependent plot style tables. If AutoCAD crashes. • Printer Description File Search Path specifies the folder in which . • Plot Style Table Search Path specifies the folder in which the .• PostScript Prolog Section Name specifies the path to the .1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ .dwt template drawings. 36 • v2.acb color book files. print spool files. Default Template File Name for QNEW specifies the name of the .pmp printer description files. 2004 Tool Palettes File Location Specifies the path to the .dwt file opened by the QNew command.ps PostScript prolog file. 2004 Log File Location Specifies the path to the . Printer and Plot Support Files Specifies the path for printer support files. and . .pc3 printer configuration files. Automatic Save File Location Specifies the path for storing automatic backup files (stored in system variable SaveFilePath). Caution: The change you make to this setting takes effect only after you close and restart AutoCAD. Color Book Locations Specifies location of . • Printer Configuration Search Path specifies the folder in which . 2004 Data Sources Location Specifies the path to .pmp plotter descriptions are stored. Drawing Template Settings Drawing Template File Location specifies the path to the .log log file created by the LogfileOn command (stored in system variable LogfilePath).$ac temporary files are often left behind. and .pc3 plotter configuration files are stored. which are deleted when AutoCAD is exited properly (stored in system variable TempPrefix). if “None” QNew opens the Select a Template dialog box.stb and .udl database source files. and can be safely erased. Temporary Drawing File Location Specifies the path to the folder in which AutoCAD stores its temporary files. these .ctb plot style files are stored.stb and . • Printer Spooler File Location specifies the folder in which spooler files are stored. used by the database-related commands in AutoCAD.

In the Files tab. In the Options dialog box. By default. if you specify the name of a . i-drop Associated File Location Specifies the associated data files that are transferred with i-drop content inserted in the drawing. select Options. 3. Texture Maps Search Path Specifies the path in which texture maps are stored for rendering. it displays the Use a Template dialog box: But. click the Files tab.Temporary External Reference File Location Specifies the path for temporally storing externally-referenced files (stored in system variable XLoadPath). 2004 Note: The Search Path for ObjectARX Applications option was removed with AutoCAD 2004. scroll down the list until you get to Drawing Template Settings.dwt file in the Options | Files dialog box. Tutorial: Specifying the Template File Here’s how to specify template files: 1. 2. Setting Templates for New Drawings 2004 New to AutoCAD 2004 is the QNew command. QNew starts a new drawing using that template file. From the Tools menu. tailoring AutoCAD 2004 chapter 2 customizing the environment • 37 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ .

1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ .” and then click the Browse button. as shown earlier. Notice that the Options dialog box now lists the . Notice that AutoCAD starts the new drawing using the template you selected.4. 6.” This causes the QNew command to display the Use a Template dialog box. English units -Color Dependent Plot Styles Architectural. Templates Included with AutoCAD 2004 Generic Template Files acad -Named Plot Styles acad acadISO -Named Plot Styles acadiso Architectural Title Block. Click the + marker next to Default Template File Name for QNEW. English units -Named Plot Styles Generic 24in x 32in Title Block -Color Dependent Plot Styles Generic 24in x 32in Title Block -Named Plot Styles Metric Layout templates ANSI (American) Template Files ANSI A (portrait) -Color Dependent Plot Styles ANSI A (portrait) -Named Plot Styles ANSI A -Color Dependent Plot Styles ANSI A -Named Plot Styles ANSI B -Color Dependent Plot Styles ANSI B -Named Plot Styles ANSI C -Color Dependent Plot Styles ANSI C -Named Plot Styles ANSI D -Color Dependent Plot Styles ANSI D -Named Plot Styles ANSI E -Color Dependent Plot Styles ANSI E -Named Plot Styles ANSI Layout templates 38 • v2.dwt file you selected. 7. Notice that the setting is “None. Notice that the Select a file dialog box lists all the . 8. 5. Click OK to close the Options dialog box.dwt template files provided with AutoCAD. Select a template file. and then click Open.dwg Architectural. Click on “None. Execute the QNew command.

DIN (German) Template Files DIN A0 -Color Dependent Plot Styles DIN A0 -Named Plot Styles DIN A1 -Color Dependent Plot Styles DIN A1 -Named Plot Styles DIN A2 -Color Dependent Plot Styles DIN A2 -Named Plot Styles DIN A3 -Color Dependent Plot Styles DIN A3 -Named Plot Styles DIN A4 -Color Dependent Plot Styles DIN A4 -Named Plot Stylesg Gb (Chinese) Template Files Gb -Color Dependent Plot Styles Gb -Named Plot Styles Gb_a0 -Color Dependent Plot Styles Gb_a0 -Named Plot Styles Gb_a1 -Color Dependent Plot Styles Gb_a1 -Named Plot Styles Gb_a2 -Color Dependent Plot Styles Gb_a2 -Named Plot Styles Gb_a3 -Color Dependent Plot Styles Gb_a3 -Named Plot Styles Gb_a4 -Color Dependent Plot Styles Gb_a4 -Named Plot Styles ISO ISO ISO ISO ISO ISO ISO ISO ISO ISO ISO (International) Template Files A0 -Color Dependent Plot Styles A0 -Named Plot Styles A1 -Color Dependent Plot Styles A1 -Named Plot Styles A2 -Color Dependent Plot Styles A2 -Named Plot Styles A3 -Color Dependent Plot Styles A3 -Named Plot Styles A4 -Color Dependent Plot Styles A4 -Named Plot Styles JIS (Japanese) Template Files JIS A0 -Color Dependent Plot Styles JIS A0 -Named Plot Styles JIS A1 -Color Dependent Plot Styles JIS A1 -Named Plot Styles JIS A2 -Color Dependent Plot Styles JIS A2 -Named Plot Styles JIS A3 -Color Dependent Plot Styles JIS A3 -Named Plot Styles JIS A4 (landscape) -Color Dependent Plot Styles JIS A4 (landscape) -Named Plot Styles JIS A4 (portrait) -Color Dependent Plot Styles JIS A4 (portrait) -Named Plot Styles tailoring AutoCAD 2004 chapter 2 customizing the environment • 39 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ .

2004 The Propulate command (available after Express Tools are installed) creates a template for the Drawing Properties dialog box (DwgProps command). executes the QNew command. • Lineweight scale. • Changes to system variables.dwt). 3. • Customized DesignCenter and Tool Palettes. • Linetypes. however. give your custom template a name. • Customized menus and toolbars. They are a good starting point. Many of these options are found in the Format and Tools menus. • Multiline and point styles. In the Files of type droplist. • Layer names (more later). • Automatically loaded AutoLISP and ObjectARX routines. none might suit your needs. 5. The list of possibilities includes: • Snap and grid settings. 2. use the File | Save As command. but lack many settings you would expect in a template. • Text and dimension styles. and pre-load linetypes.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . For example. The problem is that AutoCAD’s templates only include the drawing border and title block. select it in the Options | Files dialog box. • Units and CAD standards. If you wish. Start AutoCAD with a new drawing. Click Save to save the file. albeit drawn to international standards. and then click Remove.” Notice that the dialog box switches to the \templates folder.dwt file. To remove the assigned . 1. select “AutoCAD Drawing Template (*. start with one of the many template drawings provided by Autodesk. include all the layers your firm or clients expect. Tutorial: Creating Your Own Template File While AutoCAD includes a large number of templates for starting new drawings. Prepare the drawing with all the settings and variables you think you will need. In the File name text box. 40 • v2. you may want to preset the snap and grid.TIPS The File | New and CTRL+N commands execute the New command. Once you create a drawing that holds all the settings you need. 2004 The New drawing icon. 4.

(LMan is available only after Express Tools have been installed with AutoCAD 2004. or a Web site. and surrounded by quote marks. the LMan command allows you to import layers from a text file. You might get the names from a text file.) Here is how to do import layers into your template drawing: 1. Ensure that each layer name is on a line by itself. To use the template with the QNew command. Tutorial: Importing Layers 2004 AutoCAD has never been particularly supportive of layer standards. either homegrown or based on an industry standard. Place the layer names in a text editor. such as Notepad. most corporations have adopted a layer standard. In addition. fail to include the related layer standards.6. To share layer standards. as shown below: tailoring AutoCAD 2004 chapter 2 customizing the environment • 41 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . The many template drawings. based on international standards. Numerous standards bodies have created layer standards for disciplines. such as architecture and construction. follow the instructions in the previous tutorial.

lay. 4. select Layers | Layer Manager. Check that the layers were indeed imported by click on the layers list: 6. 42 • v2. using the extension of . 3.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ .2. or simply enter lman at the ‘Command:’ prompt. In the Import File Bame dialog box. select the . In AutoCAD. Save the drawing as a . 5.lay file.dwt template file. Save the file. start the Layer Manager: from the Express menu. AutoCAD imports the layers. and then click Open. Notice the Layer Manager dialog box. Click Import.

and aperture box. tailoring AutoCAD 2004 chapter 2 customizing the environment • 43 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . AutoSnap Settings For AutoSnap. and of the aperture box. which works only with custom objects. 2004 New to AutoCAD 2004 is a third grip color: Hover grip color. Also new is the Enable grips tips. Grips Settings For grips. you have the option of changing: • Size of the pickbox and the grip size. tooltip. • Color of the marker. • Color of unselected and selected grips. The grip changes to this color when the cursor pauses over a grip.Drafting and Selection Preferences The Drafting and Selection tabs of the Options dialog box allows you to customize the look of autosnaps and grips. magnet. you have the option of changing: • Toggle (turn on and off) the display of the marker. • Size of the AutoSnap marker.

For more of our technical e-books.com to purchase additional copies. As the owner of the copyright.upfrontezine. Copyright © 2004 by upFront. Ltd.com/tailor2004.com.com/ebooks.upfrontezine. does not give you permission to make electronic or print copies.onLine Web site at www. All rights reserved worldwide. Contact editor@upfrontezine. Feedback I welcome your feedback for correcting and improving the text.Copyright Information This book is covered by copyright. Visit the Tailoring AutoCAD 2004 e-book Web site at www. 44 • v2. upFront.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . Ltd. You may not claim authorship or ownership of the text or figures herein.eZine Publishing. Send your email to editor@upfrontezine.eZine Publishing. visit the eBooks.

AutoCAD has two facilities for creating your own shortcut keystrokes: • The Options dialog box’s Keyboard tab assigns function keys and combinations to any command. and then paste — let you work at top speed. tailoring AutoCAD 2004 chapter 3 command aliases • 45 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . and AA for the Area command. This chapter includes tutorials for employing both facilities in your drafting work. which are one. CTRL/SHIFT/ALT-key t • The acad. such as L for the Line command. ALT-TAB.pgp file lets you define aliases. shortcuts — such as CTRL+C. switch to another application. But power users know that the fastest method for entering commands is the keyboard.three command aliases tailoring autocad 2004 he best-known way to specify commands in Windows programs is from menus and toolbars. Once you memorize them.and two-letter command mnemonics. CTRL+V that copy to the Clipboard.

• Control + Alternate keys operate by holding down both the CTRL and ALT keys. This executes the ToolPalette command. CTRL+0 (zero) toggles “clean screen” mode. Out-of-the-box. not macros (multiple commands). and then pressing a number or alphabet key. ALT+F4 Exits AutoCAD. such as CTRL+F2 and CTRL+B. previously toggled the log file recording. number. number. TIP You should not redefine F1 CTRL+Esc SHIFT+Tab CTRL+F6 CTRL+F4 these keys. For example. AutoCAD permits you to assign shortcut keys to: • Function keys are those keys marked with the F prefix. of course. Closes the current window. and then pressing a function key. and command prompt area. toolbar. but not the Zoom Window command-and-option. add and change definitions. where AutoCAD maximizes its drawing area by displaying only the menu. (Don’t worry. Other shortcut keys used by Windows include: ALT Accesses the menu bar.) CTRL+3 toggles the display of the Tool Palettes window. and then pressing a function. and then pressing a number or alphabet key. Shortcuts New to AutoCAD 2004 F10 toggles polar mode. ultimately assigning commands to as many as 188 key combinations.Shortcut Keys AutoCAD predefines a number of shortcut keys. such as F1 and F2. you can assign the Zoom command. tabs. Changes focus to the next window. and then pressing a function. nor the options of commands. ALT+Tab Switches to the next running program. as listed on the next page. • Control + Alternate + Shift keys operate by holding down the CTRL and ALT and SHIFT keys. it quits AutoCAD. Opens the Windows Start menu. • Control + Shift keys operate by holding down both the CTRL and SHIFT keys. because they are used by Windows: Displays help. You can. This executes the CleanScreenOn and CleanScreenOff commands. this is faster than selecting the command from the menu. or alphabet key.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . in AutoCAD 2004. you won’t run out of commands to assign: AutoCAD has over 300 commands!) Only commands can be assigned. AutoCAD defines a large number of shortcut keys. • Shifted function keys operate by holding down the SHIFT key. This is CTRL+Q 46 • v2. Changes focus to the next window. • Control keys operate by holding down the CTRL key. or alphabet key. For some users. or typing it whole at the keyboard. scroll bars. Shortcut keys let you carry out a command by simply pressing the assigned key on the keyboard.

CTRL+SHIFT+S CTRL+SHIFT+C runs the SaveAs command. executes the PasteBlock command. AutoCAD’s Default Accelerator Keys The following table lists the keystroke shortcuts defined by default in AutoCAD 2004: CTRL+SHIFT+V tailoring AutoCAD 2004 chapter 3 command aliases • 47 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ .not a useful change. which pastes objects from the Clipboard after you specify an insertion point. which copies objects to the Clipboard after you specify a base point. since the alt+F4 shortcut also exits AutoCAD. Make sure you use CTRL+SHIFT+V immediately after CTRL+SHIFT+C. Caution: This command pastes anything in the Clipboard. executes the CopyBase command. and may create in unexpected results.

3. such as File Menu. and then press the key combination: CTRL+SHIFT+F. such as Draw Toolbar. select Find. • Sorted by menu order: from the Category list. In this tutorial.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . Notice that the Customize dialog box displays the Keyboard tab. select AutoCAD Commands. From the Tools menu. • Sorted by toolbar order: from the Category list. select the Edit Menu command category. select Customize | Keyboard. 4. 6. 2. From the Commands list. select a toolbar name. you assign the Find command to CTRL+shift+F: 1. 48 • v2. i All of AutoCAD’s commands are categorized in three ways. Click Assign. Press new shortcut key: CTRL+SHIFT+F f. 5. From the Categories list. Click in the Press new shortcut key box. Click Close to dismiss the dialog box. the command you wish to assign to a keystroke. • All commands in alphabetical order: from the Category list. select a menu name.Tutorial: Defining Shortcut Keys Here are the steps to define shortcut keys. Notice that CTRL+SHIFT+F appears in Current Keys list.

assign the first two characters. C is assigned to the Circle command.7. so CO is assigned to the Copy command. a space. • Commands with a control key equivalent. *fullCommandName Notice that the alias is followed by a comma. Like keyboard shortcuts. an asterisk. H is assigned to the Hatch command. they cannot include options. and OS for OSnap (object snap). called aliases. -LA for the - tailoring AutoCAD 2004 chapter 3 command aliases • 49 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . An alias typically is an abbreviation of a command name. so assign HE for HatchEdit. and then pressing F. aliases work only with command names. and Help (already assigned to function key F1). such as: L. For example. add suffixes for related aliases. If it is already taken by another command. Alias Format The format for defining a command alias is simple: alias. and so on. status bar button. and then the complete command name. Snap (already on the status line). You can assign aliases to system variables. AutoCAD should execute the Find command by displaying the Find and Replace dialog box. as well. Examples include the New command (already assigned to CTRL+N). • Try to assign the first character of the command. • For consistency. The . • Remember to use the hyphen for command-line commands.and two-letter command shortcuts. For example. *LINE Alias Rules Autodesk makes the following suggestions for creating command aliases: • An alias should reduce a command by at least two characters. AutoCAD also allows you to define one. or function key do not require an alias. For example.pgp File — Aliases In addition to keystroke shortcuts. Test the keystroke shortcut by holding down the CTRL and SHIFT keys. such as L for the Line command.

*DIMRADIUS DIMSTY.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . DOR.pgp file. HI.Layer command. IAT. *DIMREASSOCIATE *DSETTINGS *DIMSTYLE *DTEXT *DVIEW ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ D D. *PROPERTIES DDCOLOR.*DIMALIGNED D I M A N G . -ATE. AEX. DR. AP. *DIMOVERRIDE D I M R A D . -AR. ATE. IMP. -CH. *COLOR C O L O U R . *BHATCH *HATCH *HATCHEDIT *HIDE ○ DIM DIMALI. CO. ASQ. BH. GR. *DIMEDIT DI. 3F. *ATTEXT DDCHPROP. -H. *DBCONNECT DCE. You may. *DIMCONTINUE DDA. *DIMSTYLE DAL. BR. 3P. *DIMANGULAR DBA. IM. IN. DOV.*DIMLINEAR DIMORD. EX. ATTE. DLI. of course. AV. *OSNAP DDUCS. ALI. DV. *DIMEDIT DIMLIN. change any of these that you wish: 3 3A. ARO. DRA. DS. DST. AL. *INSERT IO. *DIMDISASSOCIATE DDATTDEF. 3DO. *CIRCLE *CHANGE *PROPERTIES *CHAMFER *COPY ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ INSERTURL. AA.*DIMANGULAR DIMBASE. *DIST ○ ○ ○ E E. ADC. *GROUP *-GROUP *DDGRIPS ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ H H. INF. EXT. -ATT. *DIMSTYLE DIMTED. CH. EXIT. AR. *3DARRAY *3DORBIT *3DFACE *3DPOLY COL. *DIMALIGNED DAN. DT. *DIMORDINATE DIMOVER. Aliases Defined by Autodesk The following 247 commands are assigned to aliases by Autodesk in the acad. -IM. *LAYER DDLTYPE. EXP. -BO. *LINETYPE DDMODIFY. ICL. CHA. HE.*COLOR CP. ED. *ATTDEF DDATTEXT. -B. EL. -I. *DIMDIAMETER DDLMODES. *DIMBASELINE DBC. *DIMBASELINE D I M C O N T. *FILLET *FILTER ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ G G. *INSERT *-INSERT *IMAGEADJUST *IMAGEATTACH *IMAGECLIP *IMAGE *-IMAGE *IMPORT *INTERSECT *INTERFERE ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ C C. *BLOCK *-BLOCK *BHATCH *BOUNDARY *-BOUNDARY *BREAK ○ ○ ○ ○ ○ ○ ○ ○ ○ I I. *PROPERTIES D D O S N A P. *ERASE *DDEDIT *ELLIPSE *EXTEND *QUIT *EXPORT *EXTRUDE ○ ○ ○ ○ ○ ○ A A. ATT. *UCS DED. *DIVIDE *DIMLINEAR *DONUT *DIMORDINATE *DIMOVERRIDE *DRAWORDER *DIMRADIUS ○ ○ ○ ○ ○ ○ ○ ○ B B. *INSERTOBJ ○ ○ ○ ○ ○ ○ ○ ○ L ○ ○ ○ ○ ○ ○ ○ ○ 50 • v2. *ARC *AREA *DBCONNECT *ADCENTER *DBCONNECT *ALIGN *DBCONNECT *APPLOAD *ARRAY *-ARRAY *DBCONNECT *DBCONNECT *DBCONNECT *ATTEDIT *-ATTEDIT *ATTDEF *-ATTDEF *-ATTEDIT *DSVIEWER ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ F F. *COLOR DDI. *DIMTEDIT DIV. *DIMCENTER DCO. ASE. AAD. FI. -G. BO. *DIMCONTINUE DIMDIA. *DIMDIAMETER DIMED. DO. IAD. *COPY DRE.

*SNAP SO. *MTEXT *-MTEXT *TABLET *THICKNESS *TILEMODE *TILEMODE *TOOLBAR *TOLERANCE *TORUS *TRIM ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ M M. RM. ME. LA. *PUBLISHTOWEB PU. *SUBTRACT ○ ○ ○ O O. -XB. TO. *STRETCH SAVEURL. *SCALE SCR. *POLYGON ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ Z Z. ML. *-PURGE T. *OPTIONS PRCLOSE. REA. -REN. RA. *PURGE -PU. *PROPERTIES PS. *OPEN ORBIT. *-PARTIALOPEN PE. *POINT POL. REC. -UN. -T. TOL. XC. MA. *-LINETYPE LW. MI. *PROPERTIESCLOSE PRE. TH.L. REG. XB. MS. *REDRAW *REDRAWALL *REGEN *REGENALL *RECTANGLE *REGION *RENAME *-RENAME *REVOLVE *DDRMODES *ROTATE *RPREF *RENDER ○ ○ R ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ U UC. *OFFSET OP. *-LINETYPE LTS. MO. *SPLINE ST. -XR. TI. UN. *DSETTINGS SEC. LE. *LWEIGHT PR. -LA. -W. *SCRIPT SE. *PSPACE PTW. *LTSCALE LTYPE. RPR. *MOVE *MATCHPROP *MEASURE *MIRROR *MLINE *PROPERTIES *MSPACE *MTEXT *MVIEW R. *LIST LT. TA. *3DORBIT OS. *PREVIEW PRINT. XL. *LWEIGHT LO. XA. *SPLINEDIT SPL. RO. *LINE *LAYER *-LAYER *QLEADER *LEADER *LENGTHEN *LIST LINEWEIGHT. *PASTESPEC PARTIALOPEN. REN. TOR. UNI. LI. LEAD. *VIEW *-VIEW *DDVPOINT *VPOINT ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ W W. *-OSNAP ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ X X. RR. MV. *SECTION SET. *-PAN PA. LEN. UCP. *PLOT PROPS. RE. *DDUCS *DDUCSP *UNITS *-UNITS *UNION ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ V V. TM. *SETVAR SHA. WE. *PEDIT PL. *LINETYPE -LT. *PLINE PO. *-LAYOUT LS. REV. VP. *WBLOCK *-WBLOCK *WEDGE ○ ○ S S. *EXPLODE *XATTACH *XBIND *-XBIND *XCLIP *XLINE *XREF *-XREF ○ ○ ○ ○ ○ ○ ○ ○ P P. XR. *SHADE SL. -VP. *STYLE SU. *SAVE SC. MT. -V. *PAN -P. TR. *OPTIONS OPENURL. *OSNAP -OS. *ZOOM ○ ○ ○ ○ ○ ○ T ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ tailoring AutoCAD 2004 chapter 3 command aliases • 51 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . *SLICE SN. *LINETYPE -LTYPE. *SPELL SPE. *SOLID SP.

52 • v2.Creating New Aliases To create a new alias. type an alias. Click Add. Under AutoCAD Command. select Tools | Command Alias Editor. you add the HOR alias for the DimHorizontal command. or to edit existing aliases. From the Express menu. 1. you can either enter a command name (such as DimHorizontal). you must ensure that the Express Tools are installed with AutoCAD 2004. 2. Notice the AutoCAD Alias Editor dialog box. For this tutorial. 3.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . or by dialog box. Here we look at both methods. or select it from the list. there are two methods — by hand. Notice the New Command Alias dialog box. Tutorial: Alias Creation by Dialog Box 2004 To edit aliases via dialog box. In the Alias text box. such as HOR. Alias: hor 4.

Notice that Notepad displays the file: 2.pgp). Click OK to exit the dialog box. as follows: From AutoCAD’s Tools menu. until you reach the dimensioning commands. AutoCAD warns that you will redefine it. 6. but it does include system variables. Tutorial: Alias Creation by Hand If you prefer to handcraft aliases.pgp file. AutoCAD asks if you want to add it to the list of commands. Notice that the new alias is listed in the dialog box. 5. In this tutorial. Scroll down to the alias section. the AutoCAD Alias Editor allows you to edit (change) and remove aliases. Open the acad.pgp file with the Notepad text editor. If you enter an alias the same as an existing one. (There is no need to use the ReInit command to update AutoCAD with the new alias. follow these steps to directly edit the acad.Notes: The list does not include all of AutoCAD’s command. ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ tailoring AutoCAD 2004 chapter 3 command aliases • 53 . 1. Click Yes. If you are adding a new command. select Customize | Edit Custom Files | Program Parameters (acad. you add the LIN alias for the DimLinear command. Click OK.) In addition to adding aliases.

onLine Web site at www. as in DIMLINEAR.pgp file. From the Edit menu. 6. Press Enter to make room for another line of text. Test your change by entering “lin” at the ‘Command:’ prompt.com/ebooks. Select the PGP File option. Ltd. As the owner of the copyright. does not give you permission to make electronic or print copies. select Save. AutoCAD should start the DimLinear command: Command: lin DIMLINEAR Specify first extension line origin or <select object>: Notice that AutoCAD reports the full name of the command in uppercase letters.eZine Publishing.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . as follows: Command: reinit Notice the Re-initialization dialog box.com. Copyright Information This book is covered by copyright.eZine Publishing. Send your email to editor@upfrontezine. For more of our technical e-books. Copyright © 2004 by upFront.pgp file into AutoCAD so that the new alias becomes active. Ltd. Contact editor@upfrontezine.upfrontezine.* dimlinear 5.upfrontezine. AutoCAD reloads the acad. and then click OK.com to purchase additional copies. 4. TIP Command aliases can be used in toolbar and menu macros. Feedback I welcome your feedback for correcting and improving the text. 54 • v2. upFront. and then start the Reinit command. All rights reserved worldwide. Enter the following text: lin. 7. visit the eBooks. You may not claim authorship or ownership of the text or figures herein. Visit the Tailoring AutoCAD 2004 e-book Web site at www.com/tailor2004. This reloads the .3. 8. Switch back to AutoCAD.

It was meant by Autodesk to be more of an experiment than a working release. toolbars let you collect your most-used commands in convenient strips. t tailoring AutoCAD 2004 chapter 4 toolbar macros • 55 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . Toolbars buttons operate by executing one or more commands and options. The variety of options for writing creative macros is limited compared with AutoCAD’s programming languages. called macros.four toolbar macros tailoring autocad 2004 he easiest part of AutoCAD to customize. There are drawbacks. and was called the “AutoCAD Windows Extension.” or AWE for short. my rule-of-thumb is to write a macro any time the same action is repeated more than three times.) Toolbar buttons give you single-click access to almost any command or group of commands. which were first added to AutoCAD with the Windows version of Release 11. however. Instead of hunting through AutoCAD’s maze of menus (is the Hatch command under Draw or Construct?) or trying to recall the exact syntax of a typed command (was that Viewpoint or Vpoint). The length of the macro is limited to a maximum 255 characters. to using toolbar and toolbox macros. Despite these drawbacks. the toolbar is the fastest and most convenient way to minimize keystrokes and mouse clicks in AutoCAD. (The first version of AutoCAD for Windows came out during Release 11. are the toolbars. Figuring in the time it takes to write and debug the macro. in my opinion. Toolbar Macros Are No Panacea Toolbar macros are best suited for quick’n dirty programming.

By dragging the toolbar by its handle. it has four toolbars that are docked along the edges of the drawing area.0 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . If you have a dual-monitor setup. or containing commands not found on the four toolbars AutoCAD displays by default — Draw. When toolbars float. the text window. They can also float. Edit. and Object Properties. Tutorial: Dragging Toolbars Look closely at the end of each toolbar. on the second monitor. When you move or change the size of the AutoCAD window. That maximizes the first monitor for the drawing area.Customizing Toolbars There are two approaches to customizing toolbars. Toolbars don’t have to be docked. you can move the toolbar around AutoCAD. 56 • v2. creating new icons for the buttons. they are independent of the AutoCAD window. and notice the double-line (shown enlarged in the figure below). In this chapter. the toolbars move along. Rearranging Toolbars When you start a fresh copy of AutoCAD. These are drag handles. the Properties window. and modifying the help text. Standard. and so on. it can be useful to have toolbars. One is to simply rearrange the icons. we look at both approaches. The second approach is to delve into all aspects of toolbar customizing: writing macros that activate when their button is clicked. perhaps creating a toolbar containing oft-used commands. “Docked” means the toolbars are attached to the edges of the drawing area. and floating toolbars remain where they are. Move or resize the AutoCAD window.

it indicates that you can resize the toolbar. 2. gray. Additionally. With the toolbar floating. the toolbar floats. 3.You can relocate toolbars to other edges of the drawing area. making it more square or more rectangular. This is the float indicator. Drag it away from the edge of the drawing area. you can resize the toolbar by grabbing at any of its edges. you can move the toolbar by dragging it by its title bar. the toolbar would jump back to its docked position. tailoring AutoCAD 2004 chapter 4 toolbar macros • 57 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . shown in the figure above. Drag the toolbar further. rectangular outline. When you let go of the mouse button now. To move a toolbar: 1. 4. or make the toolbars float. and notice that the rectangular outline changes to a thicker line. Notice the twoheaded cursor. Notice the thin. the dock indicator. 5. If you were to release the mouse button at this point.

the command-prompt area can also be resized and be made to float. hold down the Ctrl key to prevent docking. To float. Once floating. The number of prompt lines changes from the default setting of 3. and drag up or down. To resize. If necessary. grab the dividing line between the prompt area and the drawing area. and resize it by its edges — just like a toolbar. To dock the toolbar again.6. To dock. 58 • v2. as shown below. TIP Although not a toolbar. drag the prompt area back into place. you can move the prompt window by its title bar. drag the prompt area at its lower right corner. drag it by its title bar back against one edge of the drawing area.0 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ .

To turn off a toolbar. To turn on a toolbar. repeat steps 1 and 2. 3. you turn it off by clicking the x in the upper right corner. Notice the shortcut menu that lists the names of all the toolbars. which can be of use in a macro or AutoLISP routine. To turn on other toolbars. When a toolbar is floating. Notice that the toolbar appears. 1. The check mark means the toolbar is displayed. and the menu disappears. but select a toolbar name with a check mark. tailoring AutoCAD 2004 chapter 4 toolbar macros • 59 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . repeat steps 1 and 2. 2. as follows: Command: -toolbar Enter toolbar name or [ALL]: all Enter an option [Show/Hide]: s This command also turns on and off individual toolbars. select its name from the shortcut menu. Right-click any toolbar. use the undocumented -Toolbar command. TIP To turn on (or off) all toolbars at once.Tutorial: Toggling Toolbars Toolbars can be turned off and on.

” Toolbar name: My Toolbar Click OK. In the New Toolbar dialog box. such as “My Toolbar. 1. and you may have to hunt around the screen to find it. 60 • v2.Tutorial: Changing Toolbar Buttons You can create a new toolbar with the buttons (commands) to your liking. In the Toolbars tab. Notice that AutoCAD’s commands are presented in two ways: categorized by function (File. but AutoCAD creates a new. Edit. (If no toolbar is visible. enter a name for your toolbar. 4. From the shortcut menu. click New to create a new toolbar. select Customize. Notice the New Toolbar dialog box. and alphabetical (scroll down to find All Commands). Now it’s time to populate the empty toolbar with buttons.0 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . It’s easy to miss. select Customize | Toolbars. and so on). Here is how to create such a toolbar. 3. Right-click any toolbar. empty toolbar. from the Tools menu. It’s just a tiny thing.) 2. In the Customize dialog box. select the Commands tab.

it is saved automatically by AutoCAD. TIP While the Customize dialog box is open.5. AutoCAD asks. “Are you sure you want to delete the button from the toolbar?” Answer in the affirmative. This means you can add and remove buttons from the other toolbars. When done. click Close to dismiss the Customize dialog box. From the Command list. simply drag it out of the toolbar. Standard. 6. drag command names into the new toolbar. such as Draw. Your new toolbar acts just like the any other toolbar in AutoCAD. tailoring AutoCAD 2004 chapter 4 toolbar macros • 61 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . notice the buttons appearing. Note: There is no need to “save” the new toolbar. Yes. and so on. 7. To remove a button from the toolbar. all toolbars are customizable — not just the one you created. The I-beam cursor helps you position the button in the toolbar. As you do. and will appear the next time you start AutoCAD.

Notice that the buttons immediately grow larger. 62 • v2. You can make the buttons 50% larger.Tutorial: Changing Button Size The buttons on toolbars are 16 pixels in size. If you don’t. 2. Select Large Buttons. as follows: 1. that may be too small if your eyesight isn’t as strong as that of user-interface designers. 3. In some cases. and then close the dialog box. and select the Toolbars tab. click Close to dismiss the dialog box.0 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . uncheck the Large buttons option. If you like the size. Open the Customize dialog box.

You are limited to 16 colors to ensure the icons look correct with any depth of color display. tailoring AutoCAD 2004 chapter 4 toolbar macros • 63 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . Right-click the blank button. lines. and then select Edit Button Image. ellipses (and circles). (The only purpose for this dialog box is to enter toolbar-customization mode. 1.) 2. The Button Editor provides a number of tools and functions: • The four tools along the top are for drawing freehand. unfortunately. • The colored squares on the right are the 16 standard Windows colors for drawing icons. Bring back the Customize dialog box by right-clicking the toolbar and selecting Customize. and erasing (changes colors back to neutral gray). we don’t actually use the dialog box in this tutorial.Tutorial: Drawing Icons You may have noticed that some command-buttons lack icons. • The small square on the left shows you a preview of the icon in real-size. no floodfill tool. as shown below. AutoCAD has a built-in icon editor that lets you modify existing icons and create new ones. Notice the Button Editor. There is.

which must be 16x16 pixels in size.• The large gray square in the center is where you draw the icon. and there is no redo. Notice that the toolbar’s formerly blank button is now adorned with your artwork. • Undo undoes the last drawing step. and then click Close. it is a single undo. 3. When satisfied with your artistic endeavor.bmp (Windows bitmap) file. • Grid toggles the display of grid lines to assist your drawing. click Save.0 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . I recommend turning on the gird. • Save saves the icon to the toolbar. 4. Draw the icon. • Close closes the button editor. 64 • v2. • Clear erases the drawing from the button. • Open opens a .bmp file. • Save As saves the icon as a .

AutoCAD executes the macro (collection of commands) assigned to the button. 1. This is a brief description of the button’s function. Select a button on any toolbar. you assign a macro to the button with the custom icon created earlier. Notice that the Customize dialog box switches to the Button Properties tab. This is a longer description of the button’s function. you can also change the command(s) that lie behind each button. • Macro associated with this button is the collection of commands executed by clicking the button. The figure above shows quite a complex macro. most macros consist simply of the command’s name.Tutorial: Writing Toolbar Macros In addition to creating custom toolbars and icons. and then selecting Customize. In this tutorial. The Button Properties tab has several areas that correspond to AutoCAD’s user interface: • Name is the text displayed by the button’s tooltip. such as: Macro associated with this button: ^C^C_open ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ tailoring AutoCAD 2004 chapter 4 toolbar macros • 65 . When you click a toolbar button. • Description is the text displayed on the status line. 2. Bring back the Customize dialog box by right-clicking the toolbar.

like Ctrl+O.• Button Image is an enlarged view of the button’s icon. you pressed CTRL+C to cancel a command. ^E Switches to next isometric plane. for compatibility reasons. It imitates pressing ESC on the keyboard. like PEdit. prefixed by some unusual-looking characters: ^C^C_open The characters have the following meaning: ^C is a control character. described earlier. and then click Apply to see the icon on the button. ^P Toggles MenuEcho system variable. ^C^C Most macros start with two ^C because some AutoCAD commands are two levels deep. ^O Toggles ortho mode. like Ctrl+H. Select an icon. like Del1. these ASCII codes are still used today. because early computers used teletype terminals to communicate with humans. ^H Backspaces. see chapter 10. ^B Toggles snap mode between on and off. ^I Same as pressing Tab.0 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . like Ctrl+G. ^X Deletes. like Ctrl+E. ^M Same as pressing Enter. ^U Toggle polar mode. $M= Allows use of Diesel expressions. CTRL+C means “copy to Clipboard” but continues to mean “cancel” in macros only. • Apply applies the changes you made to the button. ^V Switches to next viewport. the C was short for “cancel. and not a command. CTRL+C comes from ASCII code 003. which cancels the command currently in progress. which meant ETX — end-transmission — in the days of telegraphs and teletypes. What does C have to do with the ESC key? In versions of AutoCAD older than Release 13. • Reset changes the button’s properties back to when you first began. like Ctrl+D. like Ctrl+B.” (Going back even further in history. I recommend three of ’em — ^C^C^C — because some commands. 66 • v2. and some things never change. ^W Toggle object snap tracking. are three levels deep. Simple Macros A simple macro consists an AutoCAD command. And below the Edit button is a collection of icons.) TIP AutoCAD recognizes these control characters in toolbar macros: ^A Toggles group mode. 1 Not documented by Autodesk. • Edit brings up the Icon Editor. ^G Toggles grid display. so that you can edit the icon. like Ctrl+W1. ^C Cancels current command. 3. This leads to some clashes: ever since Release 13. like Ctrl+U1. which you can borrow for use with the button. ^D Changes coordinate display mode. ^Z Suppresses automatic Enter at the end of a macro. The carat ( ^ ) alerts AutoCAD that this is a control character. More than a hundred years later. like Ctrl+V. like pressing Esc. like pressing Ctrl+A1.

0 (model space) and value of system variable CvPort Black Diesel expressions.$(and. $(if.cvport). open is the command name. Suppress Enter at end of Diesel expression.cvport). you can include Diesel expressions and AutoLISP routines (see chapters 10 and 11 for details).refeditname).^P. $(getvar. 1 (no viewports) then $M= $(if.$(getvar. 1) ). For example. use aliases instead of the full command name. leading to a non-operational macro. ^C^C_refset. if and Red Macro control characters. and system variables.$(eq.))^Z value of RefEditName system variable to empty Yikes! Ugly. hang a ^Z at the end of the macro. Nothing is needed at the end of the macro to terminate it.. Autodesk wrote the following macro for the RefSet button: tailoring AutoCAD 2004 chapter 4 toolbar macros • 67 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . or Spanish versions of AutoCAD.$(getvar. $(=. In macros. $(=. then you don’t prefix the macro with the Cancel character. $(getvar.^C^C_refset _add. "").^C^C_refset. $(and. ^C^C^P(ai_refedit_alert). execute RefSet command or RefSet Add command.^C^C_refset _add. however. _ The underscore is an AutoCAD convention internationalizing the command. 0). whether used with German. $(getvar.When the command is transparent (starts with the ' apostrophe).$(=.$(getvar. Prefixing command and option names with the underscore ensures the English-language version of the command always works. like this: ^C^Copen^z Advanced Macros Start of Diesel expression: If $M=$(if. ) ) ^Z You may string together more than one command in a toolbar macro. this is discouraged.. In addition. ^P.$(if.$(=. Otherwise. isn’t it? I’ve parsed the code in colors to make so that you can see the structure: then execute the (ai_refedit_alert) AutoLISP function. That means you can. $(eq.tilemode). AutoCAD automatically does the “pressing ENTER” for you. ^C^C^P(ai_refedit_alert).0). Japanese. you type AutoCAD commands and their options exactly the way you would type them on the keyboard at the ‘Command:’ prompt.""). If you need to suppress the automatic Enter for some reason. equal tilemode).refeditname). because aliases can be changed.1)). equal value of system variable TileMode Cyan AutoCAD commands. for instance. AutoLISP functions.

Copyright © 2004 by upFront. All rights reserved worldwide. For more of our technical e-books.com to purchase additional copies.onLine Web site at www. does not give you permission to make electronic or print copies. You may not claim authorship or ownership of the text or figures herein. 68 • v2.upfrontezine. visit the eBooks.com.upfrontezine. Ltd.eZine Publishing. Contact editor@upfrontezine.Copyright Information This book is covered by copyright. Ltd. Feedback I welcome your feedback for correcting and improving the text.eZine Publishing.0 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . As the owner of the copyright.com/ebooks. Visit the Tailoring AutoCAD 2004 e-book Web site at www.com/tailor2004. upFront. Send your email to editor@upfrontezine.

five menu macros tailoring autocad 2004 t o customize the menu bar. the . It also defines all: • Toolbars. respectively). you learn how to customize the menu bar only. tailoring AutoCAD 2004 chapter 5 menu macros • 69 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ .mnu (menu) files. • “Accelerator” keys (keyboard shortcuts). tablet overlays. and screen menu. • The rarely seen screen menu. In this chapter. you’ll find the answer to why I ignore them on the last page of this chapter. you work with AutoCAD’s .mnu file controls far more than just the contents of the menu bar. AutoCAD provides a much easier customizing environment for toolbars and accelerator keys (as was described in Chapters 4 and 3. • Image tiles (an old form of dialog box). Because. As for the image tiles. In a curious twist. • Tablet overlays (used with digitizing tablets). as it turns out.

mnu. and replace it with a new one. and others. To remove a menu group. Edit. AutoCAD has a clever system for loading and unloading partial menus will. You can always reload the menu group with the Browse button. and .mnc files. the Menu Bar tab determines the display order of menu titles. • Use Replace All only when you are sure you want to erase the existing menu system. ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ 70 • v2. with two tabs: The Menu Groups tab loads and unloads partial menus. The Menu Groups list shows the menu groups loaded into your AutoCAD session. you see a number of labels: File. Each of these is a partial menu (a. select it and click the Unload button. To load and unload partial menus.1 11 nov 2003 . • EXPRESS is the menu for the Express Tools. The related MenuUnload command is identical. In the figure above • ACAD is the standard menu provided with AutoCAD. View. such as the File | Exit item. . Notice the correlation of items under Menu Bar (at the far right) — File.k. Edit. Both commands display the identical dialog box. and the purpose for its existence is not clear to me. with one exception: you cannot remove portions of partial menus defined by Windows. Tools. and so on — with the menu bar displayed by AutoCAD: Loading Menu Groups The Menu Groups tab loads menu and partial menu files: • Click the Browse button to locate .Loading (and Unloading) Menu Files When you look at the menu bar.a. you use the MenuLoad command.mns. “menu group”).

it means that all the titles of a menu group are already on the menu bar.mnc or . MNR Menu resource file contains the menu’s bitmaps. AutoCAD remembers a maximum of 24 partial menus.Loading Menu Bar Items The Menu Bar tab gives you control over which partial menus appear on the menu bar. If the Insert button is grayed out. which you can view and edit. it is compiled. To add and remove titles to and from the menu bar. such as Notepad. use the Menu command. select Customize | Edit Custom Files | Current Menu.) When you load the menu into AutoCAD. MNL Contains the AutoLISP functions used by the menu. It prompts you to select . TIPS To load an full menu system. Menu File Types AutoCAD uses a number of files for its menu system. Compiled menus load and display faster.mns file with the Notepad text editor in AutoCAD 2004: from the Tools menu. MNS Source menu file generated by AutoCAD. You probably see titles such as File.mns file. tailoring AutoCAD 2004 chapter 5 menu macros • 71 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . you see the titles that currently appear on the menu bar. you see all titles associated with a specific menu group. and then save the file with the . MNT Menu resource file generated when the . while others are hands-off. You can write new menus with a text editor. because they are generated by AutoCAD: File type Meaning User Accessible MNU Primary menu file. and so on. Edit. For example. some of which you can access.mnu.mns files. Under Menus. In the list under Menu Bar. . the ACCOV menu group contains the Image menu title. Notice that Notepad opens with the .mnr file is unavailable. TIP To open the acad.mnu extension. Hands Off! MNC Compiled menu file defines the menu’s functions and appearance. click the Insert and Remove buttons. (See tutorials following.

The regular text is your stuff.mnu in a word processor — but don’t save it!) You typically create custom menus to make commands and functions easily available. Later. open acad.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . This is pretty much the minimum needed for placing a command on AutoCAD’s menu bar. such as Notepad. We’ll work our way through the steps of creating a single-command menu. we add more features.Your First Menu Writing a menu is simple — or can be complex. The following figure illustrates the connection between the menu file and AutoCAD’s menu bar: In the figure above. Let’s take a look at what those lines of text mean. 72 • v2. while the text in color is hidden from view. The characters shown in boldface are macro syntax — required parts of the menu so that AutoCAD understands what’s going on. and then enter the following lines of text: ***MENUGROUP=MyFirstMenu ***POP ID_mnuTailoring [Tailoring] [Rectangle]rectang. Tutorial: A Single-Command Menu Menus are written with text editors. the text shown in black appears on the menu bar. (To view a complex menu. which you are free to change. Open Notepad. 1.

When you leave out ***POP. 2.Getting into the details. [Rectangle]rectang. Specify the file name of mymacro. just like pressing Enter at the keyboard. d. the macros would show up on the screen menu. This helps distinguish your menu from others written by Autodesk and third-party developers. here’s what it means: ***MENUGROUP=MyFirstMenu The ***MenuGroup tag identifies the menu by name. the command! The [Rectangle] text in square brackets appears as the name on the menu. finally. the label “POP” comes from pop-down menus.” ***POP The ***POP section label specifies that the macros following the title (as noted next) should be placed on the menu bar. And now. we’ll use “MyFirstMenu. Click Save. unless you create more than one pop-down menu. The semicolon ( .mnu file: a. Save the macro in an . such as ***BUTTONS1.) If you want the macro to operate elsewhere. use a different section label. ) terminates the macro. the word “Tailoring” — appears on the menu bar. Contrary to Autodesk documentation. c.mnu. such as from a mouse button. you don’t need a number behind ***POP. (The complete list of sections is described later. This macro executes the Rectang command. the macros don’t show up — anywhere! (In older releases of AutoCAD. The “Tailoring” text following ID_mnu identifies the menu item.) ID_mnuTailoring [Tailoring] ID gives a name to the menu title — the word that appears on the menu bar. From the File menu.) (Historically. the name originally given to menus in Windows. select the \AutoCAD\Support folder. They were called “pop-down” to differentiate them from the pulldown menus used in Macintosh. In the Save As dialog box. You can give it any name you like. select Save As. Notice the Save As dialog box. b. tailoring AutoCAD 2004 chapter 5 menu macros • 73 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . while the text in the square brackets — in this case.

change Look in to \AutoCAD\Support. click Load. b. select Customize | Menus. (If necessary.) Notice the Menu Customization dialog box.3. c. Select mymacro. and then click Open. at the ‘Command:’ prompt. From the Files of type drop list. click the Menu Groups tab.) d. Back in the Menu Customization dialog box. (Alternatively. If necessary. Click Browse. Notice the Select Menu File dialog box.mnu. From the Tools menu. e. Switch over to AutoCAD. enter menuload. select Menu Template (*. Notice that AutoCAD warns you needlessly: 74 • v2. and load your new menu file: a.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ .mnu).

Click Insert. d. Notice that the Rectangle item appears below.” 4. Notice that Tailoring now appears under the Menu Bar list. In the Menu Customization dialog box. Here’s how to make it appear: a. notice that AutoCAD starts the Rectang command. Your new menu is loaded into AutoCAD. MENUGROUP: MyFirstMenu. Select Rectangle. b. tailoring AutoCAD 2004 chapter 5 menu macros • 75 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . Notice that Tailoring appears under the Menu list. select MyFirstMenu.(The warning is needless because your menu was not previously loaded.) f. it is time to test the new menu: a. but it does not yet appear. b. it can’t be overwritten. click the Menu Bar tab. In the command prompt area. c. 5. probably located before File. “Menu loaded successfully. In the Menu Group droplist. In the command prompt area. Finally. Look at the menu bar: you should also see Tailoring there. Click Close. AutoCAD reports. On the menu bar. Click Yes. click Tailoring.

Buttons.Congratulations! You’ve written your first custom menu file. Image menus (palettes). I’ll list some of the macro conventions. Pull-down menus: ***POP0 ***POP1-499 ***POP500-999 Toolbars section: ***TOOLBARS **name Image section: ***IMAGE Screen menu section: ***SCREEN Tablet menu areas: **TABLET1 **TABLET2 **TABLET3 **TABLET4 ***HELPSTRINGS ***ACCELERATORS Default object-snap shortcut menu.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . Before continuing with more customization. Menu bar items. ***AUX2 Shift+button. all. Additional pointing device buttons: ***AUX1 Buttons. ***AUX3 Ctrl+button. Left area. metacharacters. Screen menu. Toolbar name. Shortcut menu items. including section labels. Section Labels Section labels segregate the menu file into major sections and associated subsections. Accelerator keys (keyboard shortcuts). AutoCAD menu files can have any. Right area. or none of these sections: Section Label ***MENUGROUP=name Pointing device buttons: ***BUTTONS1 ***BUTTONS2 ***BUTTONS3 ***BUTTONS4 Meaning Menu’s group name. and shortcut aliases. Shift+Ctrl+button. Top area. 76 • v2. Ctrl+button. ***AUX4 Shift+Ctrl+button. Help text displayed on the status bar. Shift+button. Bottom area.

○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ tailoring AutoCAD 2004 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ chapter 5 menu macros • 77 .

Menu Metacharacters AutoCAD menus use special characters to indicate actions equivalent to pressing keys on the keyboard. Restores menu item n (after swapping or removing). Displays an image menu. Removes menu item n. Returns to top-level menu. [ ] Provides a label for the macro. + Macro continues on the next line (when the last character). can also use / . after entering commands at the keyboard. 78 • v2. End of the submenu and the parent menu.”) For example. Returns the disabled and marked status of menu item n in a string: "~" Item is disabled. *^C^C Repeats the macro until you press the Esc key. can be used within macros to separate commands from options. Labels [--] [->label] [<-label] [<-<-label] ~ !. you use the semicolon ( . & \t Separator line between items on pull-down and shortcut menus. Start of a submenu. Here is a list of menu metacharacters acceptable to AutoCAD: Character Menu Controls $ =* $I= $M=$( $Pn= $Pn=$Pn=* Pn. Menu accelerator key character. Unavailable menu item (grayed out). but . Starts a DIESEL macro. _ Translates AutoCAD commands and options as English. ^C^C^C Cancels the current command before starting macro. space Equivalent to pressing the spacebar. Similarly. Command Prefixes ’ Indicates transparent command." Item has check mark.i=? Meaning Loads menu sections. Command Postfixes . End of the submenu or parent menu. Equivalent to pressing Enter or the spacebar. in menus. there is no metacharacter for the Alt key.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . "" Item is neither disabled or check-marked. the carat ( ^ ) is represents the Ctrl key. ) to represent the Enter key. Swaps menu items at position n. Right justifies text following. you can also use ^M. "!. is preferred. (These special characters are sometimes called “metacharacters. you press Enter. \ Wait for input from user (cannot be used in the ***Accelerators section). Prefixes menu item with the check mark.

^O Toggles ortho mode on and off. Defines Command shortcut menu (right-click while a command is active). ^V Changes the focus to the next viewport (equivalent to Ctrl+R). TIP To include comments in the mnu file. Defines shortcut menu specific to the object (obj = DXF name). ^P Toggles MenuEcho system variable on and off. ^E Changes the isometric plane. Defines default shortcut menu (right-click blank area in the drawing). Defines shortcut menu specific to a command (cmd = any AutoCAD command). ^Z Suppresses the space at the end of a menu item. ^H Equivalent to pressing Backspace. ^T Toggles tablet between command and point modes.Ctrl Characters ^B Toggles snap mode on and off (equivalent to pressing Ctrl+B). such as: //This menu was written by moi. ^C Cancels command (equivalent to Esc). I fleshed out for you the basics of menu files. In review. ^G Toggles display of the grid. tailoring AutoCAD 2004 chapter 5 menu macros • 79 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . ^Q Records user input and AutoCAD prompts to a log file. prefix the text with two slashes ( // ). while shortcut menus can have as many as 499 items. TIPS Pop-down menus can contain up to 999 items. Shortcut menus do not display titles. but a dummy title must still be provided. the skeleton consisted of: ***MENUGROUP=name ***POP ID_mnuname [menuLabel] [label]command. Defines Edit shortcut menu (right-click an object). Shortcut Menu Aliases The following aliases are reserved for use by AutoCAD: Alias GRIPS CMDEFAULT CMEDIT OBJECT(S)_obj CMCOMMAND COMMAND_cmd Comment Defines hot grip shortcut menu: right-click a hot (red) grip. Your Second Menu Earlier in this chapter. ^I Equivalent to pressing Tab. ^D Changes coordinate display.

b. TIP Make sure there is a blank line following the last line of text in the . select the Menu Groups tab. Click Browse. select MyFirstMenu. Adding Menu Macros It’s not a good idea to keep creating new menu items.mnu file.mnu menu file in Notepad — remember to save it! — and load the modified menu into AutoCAD with the MenuLoad command. Test the new menu and its macros. and then load the new one. For example. It’s as easy as adding to the end of an existing menu file. you must save the file. and select the .1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . and then load it into AutoCAD. Unlike the good old days. No. c. Here’s how: 1. it makes more sense to list a number of menu macros under a single menu item.mnu file. Under the Menu Groups list. When you select the Tailoring item. like so (the original menu code is shown in color): ***MENUGROUP=MyFirstMenu ***POP ID_mnuTailoring [Tailoring] [Rectangle]rectang. Click Load. 4. In AutoCAD. you can’t simply reload it. [Turn on log file recording]logfileon. Tutorial: Loading . the menu now has two commands.You can re-use the code by filling in your own text for that in colored italics.mnu file in Notepad. 2. and insert the Tailoring menu.mnu a Second Time After making changes to the mymacro. Now you can load your modified menu file: a. Update your mymacro. and then click Unload. If necessary. and answer Yes. 80 • v2. use the MenuLoad command to display the Menu Customization dialog box. today you have to first unload the old version of the menu file from AutoCAD. Switch to the Menu Bar tab. here is how to use the code listed above to create a new menu item that turns on the log file: ***MENUGROUP=MySecondMenu ***POP ID_mnuLogFile [Log File] [Turn on log file recording]logfileon. 3.

This time.Adding Options to Commands In addition to command names. For this reason. AutoCAD selects the last-drawn object visible on the screen — but does not erase it! Recall that when you use the Erase command.) 1 found Select objects: (Press Enter. Using Coordinates in Macros The Rectang command starts off with the following options: Specify first corner point or [Chamfer/Elevation/Fillet/Thickness/Width]: The options have the following meaning: Option Abbreviation Meaning X.) Return to Notepad. To access options in commands that normally use a dialog box. Bummer. Distance for corner chamfers. it is good to have a command reference handy. and add a second semicolon to the macro. You enter them just as you would at the keyboard. complaining “0 Unknown command. TIP Menu macros cannot control dialog boxes. you can also have command options in menu macros. you cannot draw an A-size rectangle using [Rectangle]rectang 0 0 8. Height of the rectangle above the x. such as this erase-last macro: [Erase Last]erase l. AutoCAD selects the object and erases it. Options are simply added to the command. as follows: [Erase Last]erase l. The l is short for “last. use the command-line versions.. In many cases. Linewidth of all four segments. you prefix the command with a dash. which lists commands and all their options. Thickness of the rectangle in the z-direction.5 11. such as my own The Illustrated AutoCAD Quick Reference (Autodesk Press).y-plane. you need to press Enter twice: Command: erase Select objects: l (Press Enter.” Add it to mymacro.y-coordinates of the rectangle’s first corner. eh? For example.” tailoring AutoCAD 2004 chapter 5 menu macros • 81 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . Radius of corner fillets. such as: [Array]-array. Specify first corner point none Chamfer C Elevation E Fillet F Thickness T Width W To draw a rectangle of a specific size. When you select Erase Last from the menu. . It would not work because AutoCAD interprets the numbers as commands (silly AutoCAD!).mnu and load it into AutoCAD. you cannot enter coordinates as you would at the keyboard.

you press ALT+F+S because the F and the S are underlined.0" "8.. Cancelling a Previous Command: ^C The ^C (code for ESC) cancels any other command that might still be running when you select this menu item. such as PEdit. every macro should start with ^C^C^C_. to access the File menu’s Save command.. 82 • v2.mnu file. Making Macros “Official” So far. We haven’t observed conventions for writing menu macros. while the underscore appears inside the parentheses in front of the command name. When a menu item calls a dialog box.” also known as typesetter’s quotes.The workaround is to use the AutoLISP Command function with the coordinates in quotations marks.11") [Turn on log file recording]^C^C^C_logfileon. like this: [Open. To do so.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . Three of the ^C in a row ensures commands with many levels of options. Make sure you use "straight quotes" and not “curly quotes... Modify the mymacro. plus-or-minus Two. The underscore ( _ ) ensures your macros work with other language versions of AutoCAD.11"). [Erase Last]^C^C^C_erase l. and perhaps the items should be split among two menus. you hold down the Alt key.. The three ^C appear before the AutoLISP parentheses. we have been cheating. The ideal menu has between three and seven items.5. ) as a suffix. are cancelled effectively. For example. and the items should perhaps appear on another menu. AutoCAD does not understand curly quotes. and then press the underlined letter on the menu. the convention is to include the ellipsis ( .0" "8. Any fewer than three. Notice that the AutoLISP code is handled differently.5. Specifically.]^C^C_open. as follows (changes shown in boldface): ***MENUGROUP=MyFirstMenu ***POP ID_mnuTailoring [Tailoring] [Rectangle]^C^C^C(command "_rectang" "0. Any more than seven. Adding Keyboard Shortcuts: & Most menus have keyboard shortcuts that let you access them from the keyboard. as follows: [Rectangle](command "rectang" "0. TIPS The rule-of-thumb in user interface design is: Five. such as in the German or Chinese versions.

In the example above.0" "8. That’s because the letter T is already taken by the Tools item in AutoCAD’s menu.0" "8. [Erase &Last]^C^C^C_erase l. as shown below twice: ***MENUGROUP=MyFirstMenu ***POP ID_mnuT&ailoring [Tailoring] [&Rectangle]^C^C^C(command "_rectang" "0. I placed the & in front of the “a” in T&ailoring. include the [--] metacharacter. Rule 2: Do not duplicate underlined characters.. I placed the & in front of the “R” in &Rectangle. In the example above.For AutoCAD menus.11") [&Turn on log file recording]^C^C^C_logfileon. but keep in mind these two rules: Rule 1: The underlined character should be logical. a shown in the figure below: tailoring AutoCAD 2004 chapter 5 menu macros • 83 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . you use the ampersand ( & ) to specify the keyboard shortcut (and underlined) characters.5.5. The result is two gray lines. The result looks like this: You can prefix any character you wish with the &. you would only ever get to the first word. Separating Macros Visually: -- Horizontal lines are often used in menus to separate similar groups of commands. To add such lines. when possible.. I’ve added & in four places below (shown in boldface): ***MENUGROUP=MyFirstMenu ***POP ID_mnuTailoring [T&ailoring] [&Rectangle]^C^C^C(command "_rectang" "0. [--] [Erase &Last]^C^C^C_erase l.11") [--] [&Turn on log file recording]^C^C^C_logfileon. If both had the T underlined.

1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . 84 • v2. Right-Justified Text: \t When shortcuts have been assigned to commands. use the tilde metacharacter: [~label]. such as CTRL+S for saving drawings. Notice how AutoCAD generates the submenu: When you have additional parent menu items beyond the submenu. as shown by the boldface below: ***MENUGROUP=MyFirstMenu ***POP ID_mnuT&ailoring [Tailoring] [&Rectangle]^C^C^C(command "_rectang" "0. [->Erase] [Erase &Last]^C^C^C_erase l. You only want the menu item grayed-out when it is not available..5. for example. when it is available.11") [--] [&Turn on log file recording]^C^C^C_logfileon..] metacharacter. It’s optional. Notice. “Partial Load” in the figure above. it means they are not available. you indicate the end of the submenu with the [<-label] metacharacter: [<-Erase All]^C^C_erase _a. Modify the menu.0" "8.Adding Submenus: -> Adding a submenu is as easy as adding the [->label] metacharacter. you can include them in the menu as right-justified text. Here is what \t looks like in a macro (shown boldface): [&Save\tCtrl+S]^C^C_qsave And here is the result in the menu itself: Grayed-out Items: ~ When menu items are grayed-out. but you can also indicate the end of both a submenu and its parent with the [<label. To make the text gray. The \t metacharacter separates text from the menu label by pushing the text following to the right side of the menu..

or pick a point with the mouse. To use it effectively. however.fullopen). Center.0). What this means is that the PartiaLoad command is available only when FullOpen is 0 (which indicates that the drawing was partially loaded). and commands you need. it should not appear when off.!.)O&ff]^C^C_tablet _off Again.$(getvar. don’t prefix it. Once again. Here is the code for toggling text between gray and black in the Partial Load command (replaceable text is in boldface): [$(if. Fortunately..$(eq.you want it in regular black text. prefix Partial Load with ~. The macro waits for the user to enter something at the keyboard. Adding a checkmark prefix is. • If FullOpen is equal to 0. unfortunately. is not trivial because it requires the use of Diesel code (see Chapter 10). just as complex as graying out text. This sample code displays a checkmark next to Off.0). when system variable TabMode equals 0. Waiting for User Input: \ You can make menu macros wait for users to input values. The checkmark appears only when an option is turned on.~)Partia&l Load]^C^C_partiaload This code reads as follows: • If system variable FullOpen is not 0.tabmode). I’ve boldfaced the parts of the code which you can replace with the system variables.$(eq. Angle]^C^C_arc \_c \_a tailoring AutoCAD 2004 chapter 5 menu macros • 85 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . values. as shown by this example: [S&tart.mnu file for examples of how to use metacharacters and macros in AutoCAD’s menus. substituting in values for your specific need.$(getvar. You use the backslash metacharacter ( \ ). and then continue on with the macro. it helps to copy existing Diesel code that performs the checking (user-replaceable text shown in boldface): [$(if. Adding Checkmarks: !. you can simply reuse existing Diesel code. as shown by the figure: TIP Search the acad.

such as the following set of angles: [30 Degrees]30a^H [60 Degrees]60a^H [90 Degrees]90a^H The ^H is needed at the end of the macro to prevent the automatic ENTER that AutoCAD otherwise adds. It gets used like this: [Change single linetype]^C^C_change.0). Writing Really Long Macros: + Upon rare occasions. such as Donut. Autodesk suggests replacing long macros with AutoLISP routines.+ ^C^C_refset _rem.tilemode). AutoCAD knows to read the next line as part of the same macro. place the plus ( + ) metacharacter at the end of lines.^C^C^P(ai_refedit_alert). you might find yourself writing r-e-a-l-l-y long macros.$(getvar.This macro executes the Arc command with the Center and Angle options. you prefix it with Multiple at the command prompt. Notice there is no semicolon ( . 86 • v2.$(eq.properties. AutoCAD provides the Single option to force the Select command (and any other command that prompts for object selection) to limit itself to one of two kinds of selections: a single object.))^Z TIP Macros are limited to 1. The exception to the single-selection rule is the Select command.~.””)..lt. do not.^P.continuous.$(=. or a windowed selection.040th character is ignored by AutoCAD.$(getvar. To allow macros to span more than one line.$(getvar. Providing Input to the User: ^H Conversely. AutoCAD accepts just one user input per \ metacharacter.continuous.$(eq..+ $(if. When you want a command to repeat itself.lt. Here is sample code that changes selected objects back to the Continuous linetype: [Change linetype]^C^C_select \change.p.single.””). others. This used to be more common in the early days of AutoCAD. you can write macros that let the user select values from the menu. The “a” is a dummy character that AutoCAD backspaces over..refeditname).1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . It waits twice for the user to input a value before continuing on. you can have more than one \ in a row.$(getvar..)&Remove from Working set]+ $M=$(if. Repeating Commands: * Some commands repeat automatically.^C^C_refset. Text beyond the 1. if required by the command.cvport). ) after select \ because the user has to press ENTER to signal the end of object selection. which waits for the user to press Enter to finish selecting one or more objects..refeditname). The sample below illustrates this: [$(if.properties.$(=. You then use the Previous option to obtain the selection set. before AutoLISP came along.1)).040 characters.$(and. such as Circle.

digitizing tablet overlays. Accelerator Keys.sld files.k. icon. and the side screen menu.a keystroke shortcuts) are easier to customize with the Tools | Customize | Keyboard command. Toolbar Customization Toolbars are far easier to define using the Tools | Customize | Toolbars command than tediously coding them in the . Tablet Menus Tablet overlay menus are rarely used anymore. writing the macros in the . rows)] TAG2 [Button (“btnname”. orient.mnu file for a typical 625-cell overlay is so incredibly tedious that even in the early days of AutoCAD that third-parties wrote utility programs to automate the process. and let AutoCAD generate the macro codes on your behalf! Custom Shortcut Keys Accelerator keys (a. See chapter 3 to learn how to create custom keystroke shortcuts visually. id_large)]macro TAG3 [Flyout (“flyname”. in practice. you don’t. yval. visible. Image Tiles.mnu file.exe utility program has been broken for ten years. xval. ever since the mouse became overwhelmingly popular. and let AutoCAD do the hard work for you! Image Tiles Image tiles create a type of dialog box so rarely used by AutoCAD that it appears in just one undocumented command: Draw | Surfaces | 3D Surfaces. you cannot complete construction of the image tile because it requires . tailoring AutoCAD 2004 chapter 5 menu macros • 87 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . In any case. Toolbars. and the Screen Menu With the . In any case. see Chapter 4 to learn how to customize toolbars visually. id_large. But. id_small.mnu file. however. and the slidelib. id_small. alias)]macro TAG4 [Control (element)] [--] Instead. you use the asterisk ( * ) prefix. Tablet Overlays. you can also define custom toolbars. Here’s why. image tile dialog boxes. like this: [Multiple &Point]*^C^C_point which repeatedly execute the Point command — until you press Esc.In menu macros. Here are some of the macro codes you’d have to learn to construct a custom toolbar: ***TOOLBARS **TOOLS TAG1 [Toolbar (“tbarname”.

All rights reserved worldwide. Ltd. it is turned off by default.upfrontezine.com to purchase additional copies.com. Indeed. For more of our technical e-books. Copyright Information This book is covered by copyright. does not give you permission to make electronic or print copies.eZine Publishing. Visit the Tailoring AutoCAD 2004 e-book Web site at www.com/ebooks. 88 • v2. upFront.upfrontezine. Feedback I welcome your feedback for correcting and improving the text. As the owner of the copyright.onLine Web site at www.Screen Menu The screen menu was the original “point and click” interface for AutoCAD. You may not claim authorship or ownership of the text or figures herein. Copyright © 2004 by upFront.com/tailor2004. Contact editor@upfrontezine. so most people aren’t even aware of its existence. but very few use it anymore. Ltd.eZine Publishing.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . Send your email to editor@upfrontezine. visit the eBooks.

The characters for the complex linestyles is stored in ltypeshp. eh? Until Release 13.lin files external to AutoCAD. You can apply a linetype to individual objects with the Linetype command. With Release 13 (and LT Release 3).shx. Too large. Like text. The Linetype command (and its command-line cousin. and dots ordered in a variety of patterns. (That’s probably one reason R13 files are 40% larger than in R12!) tailoring AutoCAD 2004 t y p e s • chapter 8 6 line9 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ .” while 2D linetypes are called “complex linetypes. The 1D linetypes are called “simple linetypes. say. as of Release 13 — and LT R3 — you can apply different linetype scale factors for each and every object in the drawing. or you can have all objects located on a layer use the same linetype through the Layer command. You have to size the gaps and dashes in just the right way. It’s always been a source of irritation to me that I gotta load the file into the drawing before I can use any linetypes — unlike. the scale used for text and dimensions and hatch patterns also applies to the linetype. and the line looks solid (but takes a suspiciously long time to redraw). Autodesk extended linetypes to include 2D shapes and text to create fancy linetypes.lin for AutoCAD LT) found in the \support folder.” AutoCAD stores simple linetypes in the acad. gaps. Nice.lin file (aclt. The complex linetypes are stored in file ltypeshp. -Linetype) loads linetypes and lists the names of those already loaded. AutoCAD linetypes were strictly one-dimensional. linetypes are tricky to size. Too small. like railroad tracks and — HW — hot water lines. linetypes are defined in .six linetypes tailoring autocad 2004 u ntil Release 13. Commands Affecting Linetypes As noted above. It’s the LtScale command that lets you set the scale of the linetype.lin. the linetype scale factor applied equally to all linetypes in the drawing. They consisted of lines. Typically. hatches and lineweights. and the line looks solid. too.

When changed to 1. and Properties commands let you change the linetype and scale. resulting in solid or continuous lines. the paper space scale is 1/4" = 1' (that’s 1:48 scale). Consider. MatchProp (a. AutoCAD centers the linetype pattern so that it looks nice and even at both ends. Then. While they look like one long connected line-arc-spline. instant relief! Customizing Linetypes AutoCAD provides several methods for creating new linetypes: • At the command prompt with the -Linetype command. for example. The solution is in a system variable. CeLtype holds the name of the linetype currently in effect. The Special Case of Polylines Then there’s the trick when it comes to polylines. the problem has been fixed with the PlineGen system variable. There are a couple of other system variables that relate to linetypes. Rename changes the name of linetypes.a.0). 90 • v2. AutoCAD never gets around to re-starting the pattern. however. then. As of Release 13 (and LT R3). ChProp. When the vertices are close together. polylines. Essentially. A linetype scale that looks fine in model space is going to look wrong in paper space (layout mode). AutoCAD works as before.lin file. even if you do not see them. like cartographers who use polylines for drawing contours. by setting PLineGen to 48. the other commands that affect linetypes: the MkLType bonus command creates complex linetypes from objects selected in the drawing. Its job is to scale all linetypes relative to paper space (default = 1. When set to 0 (the default).And quickly now. LtScale stores the current linetype scale factor (default = 1. AutoCAD automatically displays linetypes 48 times larger in paper space than in model space. Painter) is another way to set the linetype. System Variables Affecting Linetypes Because linetypes are affected by scale. AutoCAD generates the linetype from one end of the polyline to the other — ah. • Interactively with the MkLtype command. The Change. AutoCAD starts at one end of the object. AutoCAD faithfully restarts the linetype pattern each time it encounters a vertex. Say.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . Purge removes unused linetype definitions. This drives some people nuts. paper space becomes a problem. and then works its way to the other end. To understand the problem.k. they contain many vertices.0). You don’t get the linetype abruptly ending midway through. based on the length of the object and the linetype scale factor. PLineGen. generating the linetype from vertex to vertex. consider how AutoCAD generates linetypes: it attempts to apply linetypes as nicely as it can. • In text editors with the acad. Finally.

press ENTER. Step 2: Save to a . 4. AutoCAD pops up the Create or Append Linetype dialog box. Give a name to the linetype. __ . __ A good descriptive text is pattern you plan to create. I find it easiest to keep all linetypes in one file. Finally! You get to define the linetype pattern.25 units long. The code is a simple: • Use positive numbers to indicate dashes. AutoCAD would only ever read the first one it comes across. For example.. checking if linetype already defined ...25 means a dash 0.1 units long. Step 3: Describe the linetype. Start AutoCAD. -0. You cannot use the same code twice in a row: it just doesn’t make sense to have two gaps or two lines in a row. does it? Instead. __ .lin file. If two linetypes have the same name.lin — or acadIso. 5. • Use negative numbers for gaps. 3. Next. code that gap or line twice as long. This takes three steps: Step 1: Name the linetype. Overwrite? <N> In this case.lin.lin file. as follows: Command: -linetype Current line type: "ByLayer" Enter an option [?/Create/Load/Set]: c 2. and spaces. and then try giving it another name. That lets you decide where to place the custom linetype: • In a new . AutoCAD checks: Wait. • And use zeros for dots. which can be as long as 31 characters. underlines. A 0 is a single dot.. tailoring AutoCAD 2004 t y p e s • chapter 9 6 line1 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . 6.lin file. Follow these steps to create new linetypes on-the-fly: 1. so I recommend accepting acad. The first step is the name itself. describe the linetype with any words you like up to 47 characters long. • Or have AutoCAD append the linetype description to the acad. and also the nickname of one of my aunts): Enter name of linetype to create: dit-dah AutoCAD stores your new linetype in a .lin if you tend to work with the ISO (international standard) linetypes. If you accidently (or otherwise) enter a linetype name that already exists — such as “Dashed” — AutoCAD warns: DASHED already exists in this file. At this point. and then enter the -Linetype Create command. 0. Let’s name the pattern “Dit-dah” (after the Morse code pattern for the letter A — the only Morse code I know. for later reuse. Descriptive text: .. __ .1 is a gap 0.Tutorial: Making Linetypes with -Linetype Command Let’s look at the first one first. For example. Current definition is. After clicking the Save button to dismiss the dialog box. using dots.

1 You could go on for a total of 78 characters.. Which is exactly what we do in the next section. view names.) AutoCAD forces on you the A: Enter pattern (on next line): A. and so on). That’s what causes the linetypes start and stop with a dash. Well. then you know the screen has a width of 80 characters.-.There are two more codes to know about: • Commas separate the codes. Why is the DOS screen 80 characters wide? If you ever punch-coded computer cards back in the ’60s and ’70s.. Descriptive text: .lin file on the text screen.1. new linetypes are added to the end of the acad. the limit to names of named objects was 31 characters (such as layer names.-.-. checking if linetype already defined . Summing up. actually. For example: . linetype names. The asterisk and comma take up two characters. .-. then you know that the punch cards were 80 characters wide. Back to where 47 comes from . it made it the same size as the American dollar bill of the time (which were smaller than the current dollar bill). You still need to test the pattern. none of the text wraps around.25.lin file. That leaves 47: 80 .31 . Until AutoCAD 2000. making a nice display. TIP Where did 47 come from? A question: What about those unusual character limits of 31 and 47 and 78? They come from the limit of 80 characters being the maximum length of a line in the linetype definition. as follows: A.25.0. adjusted to fit.0.. (The A could also stand for “actually” because.. where did 80 come from? If you have ever used DOS. When AutoCAD displays the contents of the acad.1 Command: By the way. __ .. Press ENTER to end linetype definition and you’re done. __ . 92 • v2.1. __ .-. So.2 = 47. as follows (your responses are shown in boldface): Command: -linetype ?/Create/Load/Set: c Name of linetype to create: dit-dah Wait.0.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ .-.25. Why is that? When IBM invented the punch card. but I am guessing that IBM simply adapted the bill-counting machine to make punchcard readers. not quite. . 7.1 • The letter A forces the linetype to align between two endpoints. Type the codes after the A.. I don’t have a choice when I create linetypes on-the-fly. __ Enter pattern (on next line): A. you can write new linetype definitions within AutoCAD using the -Linetype Create command..1. Why the dollar bill? I don't know for sure.

which must be installed separately from AutoCAD 2004. and then click Open. Notice that you are prompted to select a . __ . Test the Dit-Dah pattern. Select would be more accurate. as follows: ?/Create/Load/Set: s New entity linetype (or ?) <BYLAYER>: 4. Select acad. Your debugging session is over. For fun.) Here’s how to use this command: 1. Select acad. Line. AutoCAD confirms: Linetype DIT-DAH loaded.) 6. Tutorial: Making Linetypes with MkLType 2004 The MkLtype command (short for “make linetype”) creates simple and complex linetypes by selecting objects from drawings. and then click Save — a misleading button name. such as a box or letters. Point. 3. draw a line and appreciate the linetype it is drawn with. (This command is part of Express Tools. or one of these loaded linetypes: Name Description -----------------. linetypes are no exception. tailoring AutoCAD 2004 t y p e s • chapter 9 6 line3 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ .Tutorial: Testing New Linetypes It is important to always test new customization creations. and AutoCAD tells you: BYLAYER. __ 5. Here you can type either the name of a loaded linetype (such as “dit-dah”) or enter “?” to see which linetypes are already loaded. 2. Use the -Linetype Load command to load the pattern into drawing. type ? . BYBLOCK.lin. select Tools | Make Linetype. As simple as they are. You may find it useful to employ these commands: PLine.lin linetype file. This time. and Shape. Up pops the Select Linetype File dialog box. From the Express menu. Use the -Linetype Set command to set the linetype. Text. as follows: 1.------------------------------CONTINUOUS Solid line DIT-DAH . get serious and set the current linetype to “dit-dah”: ?/Create/Load/Set: s New entity linetype (or ?) <BYLAYER>: dit-dah ?/Create/Load/Set: (Press Enter. such as CW (cold water).lin. __ . Now. since the linetype is not being save. as follows: Command: -linetype ?/Create/Load/Set: L Linetype(s) to load: dit-dah 2. Before defining the linetype. draw a symbol.

083736. Finally. Look at the command prompt area. AutoCAD prompts you to select the objects that become part of the linetype pattern: Select objects: (Pick one or more objects. Load the acad. AutoCAD prompts you to pick two points that define the length of the linetype: Specify starting point for line definition: (Pick a point. because it defines the distance between the symbols.lin linetype file directly to create custom linetypes.Cold Water Line A. 7. Linetype "COLDWATER" created and loaded. The first couple of prompts are similar to that of the -Linetype command.) 6.lin file from the \support folder.lin file.780678.2]. 2. following the explanation later in this chapter. In the .["CW". 94 • v2. Enter a name and a description: Enter linetype name: Coldwater Enter linetype description: Cold Water Line If you enter a name that’s already in the . AutoCAD adds the definition to the .) Specify ending point for line definition: (Pick another point.367254 You can edit this linetype code. AutoCAD asks if you want to overwrite it.) Select objects: (Press ENTER to end object selection. draw a line using the linetype: Tutorial: Making Linetypes with a Text Editor You can edit the acad. 4.-2.Standard.-1.0. the linetype code looks like this: *COLDWATER. Start a text editor (not a word processor).y=-.) The length you pick is important.lin file.lin file.s=. Here’s how: 1.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . such as NotePad. 5. familiar to you from the previous tutorial. and then automatically loads it into the drawing (nice touch!).3.

with two exceptions: (1) AutoCAD isn’t there to prompt you. __ .lin file with the same name (acad. __ . .1. Save the .25.-. or add a new linetype. __ The text describes the linetype to a maximum of 47 characters. then test it within AutoCAD. .0. __ . . 4. __ A. Simple (1D) Linetype Format The linetype definition consists of two lines of text: *DIT-DAH. __ . such as *DIT-DAH. tailoring AutoCAD 2004 t y p e s • chapter 9 6 line5 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . .lin) or a new name. __ . The process is exactly the same as when you did it within AutoCAD. You can modify an existing linetype. DIT-DAH Name of this linetype. 3. this is displayed by the Linetype ? command. you see the Dit-Dah pattern.-.1 Line1 – Header Line 1 is the header. . if you defined as per the earlier tutorial.When you scroll down to the end of the file. and (2) You don’t need to use the A prefix. where: * The asterisk indicates the start of a new linetype definition. __ . The comma separates the name from the description.

and dot you learned of earlier in this chapter.HW ---. that’s all they are: characters — or.-.HW ---A. The complex linetype can consist entirely of 2D shapes. simply combine a dash and gap with the letters GAS and HW from the Standard text style. the gas line and the hot water supply. as found in the ltypeshp.1.0.S=.05]. It’s the square brackets that allow the embedding of text in linetypes. -. .R=0.-. . Two of them.["HW". Understanding and creating shapes is described in chapter 8. gap. Anything after the semicolon is ignored by AutoCAD.X=-0. such as A.5.1.shx shape file.2.---.1.Line 2: Data Line 2 is the data. 0 The zero indicates a dot. more accurately.-.0. shapes. Here is what the hotwater code looks like.25 The positive distance indicates the length of a dash when LtScale = 1. The 2D shapes can be a combination of: (1) text characters from an .shx font file.STANDARD.. every linetype data line must begin with a dash. every linetype data line follows the initial dash with a gap. or can be mixture of 2D shapes and the 1D linetype codes — the dash.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ .HW ---.0.0. AutoCAD comes with several complex linetypes.lin 2D linetype definition file: *HOT_WATER_SUPPLY.Y=-. Complex (2D) Linetype Format “Complex” linetypes are 2D: they can wiggle back and forth (within limits) and include text characters. 96 • v2.25.HW ---. with the exception of the stuff between the square brackets shown in boldface. where: A The “A” is the optional alignment flag.-. Truth be told.1 The negative distance indicates the length of a gap when LtScale = 1. which forces AutoCAD to start and end the linetype with a line. Here’s what it means: Text "HW" prints the letters HW between dashes.2 Much of this should look familiar to you.HW ---. and/or (2) shapes from an . You can use a semicolon ( . ) to prefix any line as a comment line.1.

0. you can create a text-based linetype with a single parameter. Text Scale Factor S=. or (2) when the text style height parameter is not 0. This is optional. in this case. in this case. Only problem is that Autodesk didn’t include a “linetype editor” to visually tweak the parameters until they look right (MicroStation.lin file. this ensures the text is always oriented in the same direction. such as R=45d (there are 360 degrees in a circle). It means one of two things: (1) when the text style’s height is 0 (as is so often the case). 0. tailoring AutoCAD 2004 t y p e s • chapter 9 6 line7 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . AutoCAD assumes zero degrees. such as R=1. That’s so that the text isn’t rotated way off near the orbit of Pluto.05 shifts the text in the y-direction from the linetype definition vertex.1 units. Instead. it’s a tedious back and forth between editing the ltypeshp. which is stored in system variable LtScale. but you can use other forms of angular measurement: • r specifies radians. the units are in linetype scale factor.0 rotates the text relative to the x-axis (the “A” is short for absolute). and testing the linetype.4r (there are 2 pi radians in a circle). rotation. which helps center the text in the line. for example. such as R=150g (there are 400 grads in a circle).1 shifts text in the x-direction from the linetype definition vertex. stored in system variable TextStyle. has a built-in linetype editor). no matter the direction of the line. Text Rotation Angle R=0. such as ["HW"] or you can exercise fine control over the font. The default measurement is degrees. Y=-0. Text Offset Distance X=-0. By the way. in this case. and position with six parameters. • g specifies grads.Text Style STANDARD is the name of the text style to apply the text.0 means there is no rotation. This parameter is optional and can be left out. then S defines the height. the rotation is always performed within the text baseline and capital height. In both cases. when missing. • d for degrees. then loading it into AutoCAD.1 is the text scale factor. Summing up.0 rotates the text relative to the direction of the line. the linetype would place the text at 10% of the height defined in the text style. in this case. AutoCAD uses the current text style. size. then this number multiplies the text style’s height. Text Orientation A=0.

Tutorial: Attempting a Parallel Linetype Chris Neperud asked if it were possible to create a custom linetype that is simply a continuous double line. you can add your own shapes to this file. a parallel linetype should be possible. Autodesk found a new use for the languishing shape: complex linetypes. Here is what I found — if you can find a work-around that fixes the problem..1]. and math chips were too pricey to afford.2.shx. smoothing it.044.1 Scale factor for the size of the shape. The other thing you can embed are shapes from . I would like to digitize water features using a double polyline. If there were. when hidden-line removal took all weekend.s=..0 s=. The MLine and MlEdit commands do not allow me to smooth vertices. the linetype is merely drawn without it.shx Name of compiled shape file. I recall when regenerating the Nozzle.shx files. For example..-044. but in practice.[BAT.10. AutoCAD old timers will remember a time — say. and then offsetting it is a possibility but I am hoping to find a better way to do it. it is not. but coding shapes is hard work (see chapter 8).10. ltypeshp.4 Here is what the text boldfaced in brackets means: BAT Name of shape found in the . There is no such thing as a 3D linetype in AutoCAD.-.10. Chris replied with more details: “This works great.shx file.dwg sample drawing took four minutes.2.shp file: *134. when AutoCAD cannot find the shape. a serious consideration when an 8MHz 8086 CPU was considered a hot machine. The use of shapes pretty much faded away as CPUs grew faster and math chips became free. With the invention of the complex linetype.ltypeshp. please let me know! ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ 98 • v2. I suggested he use the MLine command (or the DLine command in LT and earlier releases of AutoCAD).025. Why. Digitizing with one polyline. To use a shape takes these parameters: *BATTING.BAT 025. about 19 years ago — when shapes were preferred over blocks. I guess it might look like a bottle brush or the ribs on an electrical cord’s strain relief. when. Here’s what the coding for this batting symbol looks like in the source code ltypeshp. which I can then smooth with the PEdit Fit command.0001.1 11 nov 2003 . Not at all.” In theory.04B.Embedding Shapes But embedding text is not the last word in complex linetypes. Shapes were faster and more compact. The same rules apply as described earlier. 3D Linetypes Just kidding. What I was hoping for was a linetype that I could use with polylines. but I should have been more specific.SSSSSSSSSSSSSSSSSSSSSSSS A.

Signals the end of the shape definition. scale = 10%.shx contains 132 bytes That defined the double-line shape.1. here. I wrote a parallel linetype definition. Starts the complex linetype section. optional. AutoCAD was pleased with me: Command: compile Compiling shape/font description file Compilation successful.02C. The shape codes have the following meaning (see Chapter 8): Code *135 11 DUAL 2 014 1 020 02C 028 014 0 Meaning Start of the shape code. I opened the ltypeshp.020. With the Notepad text editor. 2. then switched to AutoCAD. Name of the .shx file containing the shape code. where "2" is the length and "0" is the direction (west) Two-unit vector in direction C (straight down.014.1 ] Meaning Starts and names the linetype.1. I switched back to Notepad. Output file c:\acad\support\ltypeshp. Name of the shape code to use. 5. tailoring AutoCAD 2004 t y chapter 6 line9 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ p e s • 9 .shx s=.lin file. and then used the -Linetype Load command to load the newly-defined linetype.2.2. 4.lin file. I compiled the .11.1. Vector. as follows: *135.) I added a parallel line shape. Now I needed to define the linetype. Number of bytes in the code (fill in this number last).shx. as follows: *PARALLEL_LINES.shx file with AutoCAD’s Compile command. Descriptive representation using ASCII characters. Two-unit vector in direction 8 (east). or south).[DUAL.014. the eleventh byte.shp source code file for the shapes used by complex linetypes. where "1" is the length and "4" is the direction (straight up or north).028.1] This code is supposed to draw a parallel linetype.0 This code draws a pair of parallel line segments.====== A. Draw (pen down) command. each two units long. Move (pen up) command Vector (line).DUAL 2.shp file into an . which is referenced by the linetype . The parallel lines are offset by one unit from the centerline. The linetype codes have the following meaning: Code *PARALLEL_LINES ====== A [ DUAL ltypeshp. 3. I switched back to AutoCAD. Because I made no errors. Alignment code.s=. (The file is found in the \support folder. Ends the complex linetype section. I saved the ltypeshp. Scales the shape. and loaded the ltypeshp.shp file.ltypeshp. One-unit vector in direction 4 (north). Name of the shape code.

AutoCAD demands there be a dash (such as the .com. Oh. I worked through the command.upfrontezine. As for the MLine command.com/tailor2004.1).-. As a historical note. I drew two lines.01 After all that. For more of our technical e-books. automatically filleted lines. Now use PEdit Spline or PEdit Fit command to create a smoothly flowing polyline.Command: -linetype ?/Create/Load/Set: load Linetype(s) to load: parallel_lines AutoCAD displays the Select Linetype File dialog box. In fact. 2. instead. or Bezier curves.1 units apart.upfrontezine. Visit the Tailoring AutoCAD 2004 e-book Web site at www. and then clicked the Open button. Send your email to editor@upfrontezine.com to purchase additional copies. it can consist of straight lines only. the MLine first appeared in Autodesk’s Generic CADD software. a gap (-. which makes linetypes from selected objects.s=. selecting the objects. but when I got to the final step. perhaps the best way to deal with the problem is to apply the Offset command to a splined polyline. visit the eBooks. one unit long and 0.lin: Shape or text may not be first spec. If you are really desperate. Ltd. does not give you permission to make electronic or print copies. Contact editor@upfrontezine. Use the PEdit Join command to: (1) turn the line segments into polylines. As the owner of the copyright. it appears that the best I can come up with is a broken parallel line created by the following . multicolored lines as swooping Bezier curves is truly a beautiful sight to see. AutoCAD requires a dash (or gap) before and after the . otherwise AutoCAD complains: There must be between 2 and 12 dash/dot specs. That means that I cannot have a pure parallel line shape. Perhaps a splinable MLine will make its appearance in a future AutoCAD.com/ebooks. or a dot (0) resulting in less-than-perfect parallel lines — parallel lines with gaps.lin code: *PARALLEL_LINES. 3. AutoCAD complains: Bad definition of PARALLEL_LINES at line 11 of file ltypeshp.[DUAL. All rights reserved worldwide.1].shx. I selected ltypeshp. 2004 My next step was to try AutoCAD 2004’s MkLtype command. you could follow these steps: 1. AutoCAD complained: *Invalid* That's the continuous linetype! So. oh. Feedback I welcome your feedback for correcting and improving the text. and (2) join the polyline segments into a single polyline.lin. Ltd.onLine Web site at www.shx shape. You may not claim authorship or ownership of the text or figures herein.1 11 nov 2003 .eZine Publishing.eZine Publishing.= = = = = = A. Use the Explode command to reduce the mline to parallel line segments. To see Generic CADD generate 14 parallel.ltypeshp. ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ 100 • v2.1 code).01. Copyright Information This book is covered by copyright. Copyright © 2004 by upFront. which could draw straight lines.. upFront.

4). solid fills. Even though AutoCAD comes with many patterns. we look at how to create custom hatch patterns and edit existing ones. you may want to edit one of AutoCAD’s patterns. Or. the dots don’t show up in some drawing translations). To create repeating patterns. and dots. gaps. they consisted of three simple elements: combinations of dashes. your office drafting standard may require a specific pattern. tailoring AutoCAD 2004 chapter 7 hatch patterns • 101 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ .seven hatch patterns tailoring autocad 2004 w hen Autodesk first introduced hatch patterns to AutoCAD (many years ago in version 1. additionally. the definition is offset by a distance and an angle. In this chapter. and gradient fills. During the intervening decades. such as Dots (which has a serious problem: pretty much all laser printers cannot plot the dots because they’re too tiny. Autodesk added associativity (as the boundary changes. the pattern updates itself automatically).

Hemispherical. Specifies the rotation angle of the hatch pattern in degrees (default = 0 degrees). As an alternative.Where Do Hatch Patterns Come From? Hatch patterns are defined in files external to AutoCAD. Commands and System Variables The Hatch and -BHatch commands create hatch patterns at the command line.0 units).y-coordinates of the origin for the hatch pattern (default = 0. Inverted hemispherical. you can double-click hatch patterns to edit them. You can have many pattern files. When you apply a hatch to an area. change the values of SnapAng and SnapBase as required. the pattern assumes an origin of (0. Specifies the x.0). AutoCAD has many system variables that report the most-recent setting of hatch pattern parameters: GfAng GfClr1 GfClr2 GfClrLum GfClrState GfName Specifies the angle of the gradient fill. acad. Cylindrical.pat file. Specifies the current scale factor (default = 1. which is where AutoCAD stores all of its hatch patterns (located in the \support folder). Specifies the current angle of the hatch pattern in degrees (default = 0 degrees). Specifies the name of the current hatch pattern (default = ANSI31). Since Release 14. AutoCAD also supports solid filled areas in any color. The pattern consists of only lines.pat. hatch pattern files are loaded automatically the first time you use the Hatch or BHatch commands. The infinite pattern comes to a stop when it reaches a boundary (see figure below).0). however. Specifies luminance for one-color gradients. Once in place. Determines whether the hatch is applied a second time at 90 degrees. Spherical. AutoCAD generates an infinite number of parallel patterns based on the definition in the . dots. Specifies the spacing between hatch pattern lines (default = 1. I find it easier to keep all patterns in a single file. Unlike linetypes. you can use the Move command to move the hatch pattern elsewhere in the drawing. and gaps. Specifies whether the gradient uses one or two colors. GfShift HpName HpScale HpAng HpDouble HpSpace SnapAng SnapBase The last two system variables allow you to control where hatch patterns begin. Specifies the position of gradient fill: centered or shifted to the upper-left. Specifies second gradient color in RGB format. Curved. Normally. Inverted cylindrical.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . and since 2004 AutoCAD support gradient fills and named colors defined by the Pantone and RAL standards. 102 • v2.0) and an angle of 0 degrees. however. The HatchEdit command edits hatch patterns. line segments (dashes). Inverted spherical. Specifies the gradient pattern: Linear. AutoCAD cannot create hatch patterns made of circles and other nonlinear objects. These files have the extension of . No hatch patterns are predefined in new AutoCAD drawings. the BHatch command displays a dialog box.pat. But if you need to precisely control the placement of the pattern. Specifies first gradient color in RGB format. and Inverted curved.

the pattern does not change. extended entity data allows the HatchEdit command to change the parameters of the pattern. spacing.Associative and Non-associative Patterns AutoCAD creates non-associative and associative hatch patterns. As an alternative. and pattern name. when you change the boundary. Associative hatching means the shape of the pattern changes as you change the boundary. Non-associative means the shape of the pattern’s area is fixed. Hatch Patterns and Gradient Fills tailoring AutoCAD 2004 chapter 7 hatch patterns • 103 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . prefix the pattern name with an asterisk ( * ) and AutoCAD draws the pattern as individual lines and dots. not as a block. such as its scale. This is useful when you want the pattern to remain fixed. You can use the Explode command to explode the “block” into its constituent lines. AutoCAD treats both kinds of hatch pattern as blocks.

unfortunately. Specify the three parameters for the custom hatch pattern.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . by default.0000>: 2 6. Select objects: (Press Enter. save the fruits of your labor (unlike creating custom linetypes at the ‘Command:’ prompt with the -Linetype command). the angle. Specify angle for crosshatch lines <0>: 45 TIP The hatch angle is measured from the setting of system variable SnapAng (0 degrees. which is in the direction of the positive x-axis). Double hatch area? [Yes/No] <N>: y 7. use the Hatch or BHatch commands. decide if you want the pattern double-hatched.) AutoCAD draws the pattern. Here’s how to do this with the Hatch command. First.) Retain polyline boundary? [Yes/No] <N>: y Specify start point: (Pick a point. the angle you specify here is added to the value stored in SnapAng.) Specify next point or [Arc/Close/Length/Undo]: a Specify next point or [Arc/Close/Length/Undo]: (Pick a point. as follows: Select objects to define hatch boundary or <direct hatch>. 5. you select the object or boundary to hatch.) Specify start point for new boundary or <apply hatch>: (Press Enter to apply the pattern. This applies a second pattern at 90 degrees to the first pattern. Tutorial: Creating Patterns with Hatch Your options for creating hatch patterns on-the-fly are really limited. • You can edit the acad.) Specify next point or [Arc/Length/Undo]: (Pick a point. When SnapAng is set to something other than 0. Second. Finally. • You can fill an area with any object using the SuperHatch bonus command.Creating Custom Hatch Patterns AutoCAD has several ways to create custom hatch patterns: • You can create simple patterns at the ‘Command:’ prompt. the spacing between parallel lines Specify spacing between the lines <1. Start AutoCAD. AutoCAD does not. Select the User-defined option: Enter a pattern name or [?/Solid/User defined] <ANSI31>: u 4. 1. 104 • v2. Third.pat file.pat file with a text editor. Enter the Hatch command: Command: hatch 3. but — as I mentioned earlier — your custom hatch pattern isn’t saved to the .) Specify next point or [Arc/Close/Length/Undo]: (Press Enter. To create simple hatch patterns at the ‘Command:’ prompt. 2.

. 2. or stored on disk as .bmp. it’s more like filling out a form: 1.gif. From the Draw menu. • Raster images.) 5. • Any xref (externally-referenced) drawing. When the Boundary Hatch dialog box appears. select User Defined from the Pattern Type area. . at the keyboard enter the BHatch command).jpg.e.. Click the PickPoints button and then select the area you want hatched. and . Click Apply. 3. Spacing. Enter values for Angle. 4.dwg files (i. (AutoCAD automatically creates an invisible boundary. The SuperHatch command is not available until you install Express Tools for AutoCAD 2004. Tutorial: Creating Patterns with SuperHatch 2004 The SuperHatch command lets you fill an area with these kinds of objects: • Blocks defined in the drawing.tif files.Tutorial: Creating Patterns with BHatch To do the same thing with the BHatch command is a bit different. and Double. such as . which are blank areas created with the Wipeout command. any AutoCAD drawing). select Hatch (or. • Wipeouts. tailoring AutoCAD 2004 chapter 7 hatch patterns • 105 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . and AutoCAD applies the hatch pattern.

Select an option: • Image displays the Select Image File dialog box.dwg file from disk. which looks identical to the Insert dialog box. AutoCAD asks: Is the placement of this IMAGE acceptable? [Yes/No] <Yes>: Answer Y. You select a block in the drawing. and wipeouts: 1. xrefs. and AutoCAD prompts you to select all or a portion of the block: Specify block [Extents] First corner <magenta rectang>: 106 • v2.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . and AutoCAD prompts you to pick a point inside the hatch boundary. select Draw | Super Hatch. AutoCAD inserts the block in the drawing using the Insert command’s prompts. AutoCAD asks: Is the placement of this BLOCK acceptable? [Yes/No] <Yes>: Answer Y. or a . images. Select an image file. 2. After the block is placed. From the Express menu. AutoCAD inserts the image in the drawing using the Image command’s prompts. After the image is placed. Notice the SuperHatch dialog box. An example result using an image is shown below: • Block displays the SuperHatch .Follow these steps to create a hatch pattern from blocks.Insert dialog box.

Notes: The “hatch pattern” created by SuperHatch is not a pattern. I couldn’t get it to work. and polylines. SuperHatch does not add the pattern definition to . tailoring AutoCAD 2004 chapter 7 hatch patterns • 107 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . AutoCAD prompts you to pick a point inside the hatch boundary. and so on) into a series of short lines.pat files. Ordinary objects. but an unnamed group. Unlike the MkLtype command. Other than that. circles. Finally. • Wipeout requires that the Express | Text | Text Mask command be used beforehand.AutoCAD uses a magenta (pink) rectangle to show the extents of the block. image. xref. and AutoCAD displays the External Reference dialog box. or wipeout in the drawing. An example result is shown below (block at left. pattern at right): • Xref Attach displays the Select Reference File dialog box. AutoCAD asks: Is the placement of this XREF acceptable? [Yes/No] <Yes>: Answer Y. the pattern is not associative. such as lines. After the xref is placed. or else pick two points to create a new extents (picking different points allows some creativity). and AutoCAD prompts you to pick a point inside the hatch boundary. AutoCAD inserts the xref in the drawing using the Xef command’s prompts. • Curve Error Tolerance is required because AutoCAD converts curved objects (arcs. Thus. Select any .dwg file. cannot be selected. • Select Existing prompts to you select a block. arcs. The result is similar to the block example illustrated above. Press ENTER to accept that.

The comma is optional.. Semicolons ( . .0. That lets you include notes to yourself that are ignored by AutoCAD.. 1. 0. 0. 2. 0. 0. Stone masonry 45. Ver.075 90. *ANGLE. ANSI Steel 45. such as “Angle Steel. it doesn’t have to be there.. 12. Comma following the name merely separates the name from the description.. 0. come from AEC/Architectural. The first line is called the header.075 *ANSI31.AutoCAD Hatch Pattern File . ANGLE Name of the hatch pattern.0 . ANSI Iron.pat file from the \support folder for your version of AutoCAD.. such as *ANGLE. Ver.AutoCAD Hatch Pattern File.275.125 *ANSI32.0.pat file to get a better understanding of how patterns are constructed. *AR-B816. Angle steel 0. The name must be unique in the file. such as . . AutoCAD uses the first pattern it finds by that name.176776695. 12. 0..pat File Let’s now dig into the contents of the acad. such as: .375 45.. use comment lines. ) indicate comment lines. I’ve reproduced the first dozen lines here. . Take a look at the seemingly-incomprehensible series of numbers and punctuation contained by this file.0 . such as Notepad. 0. comma.. If you need more room for the description. Angle steel. .2. You are limited to a maximum of 80 characters for the name. . 0. The hatch patterns that start with AR-xxxxx . If it isn’t.0. 8x16 Block elevation stretcher bond 108 • v2. 3.-. Brick.275.2.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ .375 Comment and Header Lines The definition of a hatch pattern consists of two or more lines of text. and the description. it’s my job to make them comprehensible to you: .Understanding the acad. a space works just as well. Start a text editor (not a word processor).. such as ANGLE.0.” This description is also optional but highly recommended. .0.-. Angle steel The text following the pattern name is the description displayed by the Hatch ? command. * Asterisk ( * ) signals to AutoCAD the start of the next hatch pattern definition. Open the acad. 0.

0. TIP The dot drawn by the hatch pattern is actually a zero-length line. For example. Comma Commas (. draws a gap. Dash1 Dashes in the hatch pattern line (the code is the same as for linetypes): • A positive number. you should use a very short line segment. X-origin The first line of the hatch pattern passes through this x-coordinate. ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ tailoring AutoCAD 2004 chapter 7 hatch patterns • 109 .] Angle Angle at which this line of hatch pattern data is displayed. AutoCAD will never find them. X-offset The distance between line segments.075 Every line of data uses the same format: angle. The filename must be earth.) In most hatch patterns. a “90” means the line is drawn vertically.. The “0” means the hatch line is drawn horizontally.075 90. let’s get down to the nitty-gritty hatch pattern data and how it is coded. dash1. Y-origin The first line of the hatch pattern passes through this y-coordinate.-. and Lake).pat can contain other hatch pattern definitions (say.01. you have created a new hatch pattern called “Earth” and you want it separate from the acad. 0. y-origin. x-offset. Forest. Note that if you use a file name other than acad. . • A 0 draws a dot. and so on.275. Even though earth..pat.pat file. this parameter is used by every hatch pattern. x-origin.pat.25.. is the length of the dash. aka the gap distance. 0.pat or by itself in forest. save the . . Lines 2 and following are the data.2.The Hatch Data With the comment lines and the header line out of the way. such as: 0. since dots in a hatch pattern are not printed by some plotters. such as 0.25. Meadow. it is not optional. use the dash1 parameter. Instead of code 0. Even though this parameter is rarely used.-. 0. 0. especially laser printers. You use this parameter only to specify the offset for vertical or diagonal lines (To specify the distance between dashes. such as -0. x-offset has a value of 0.pat file with the same name or a new name. otherwise AutoCAD cannot find it..0. When you are finished editing a pattern or creating a new one. Y-offset The vertical distance between repeating lines.pat.) separate the numbers. y-offset [. • A negative number.275. The Forest pattern must be added to acad.2.0. the filename must match the pattern name. such as 0. . This creates a problem when it comes time to plot.

because xoffset is always in the direction of the line and y-offset is always perpendicular (90 degrees) to the line. For this reason. There is no limit to the number of data lines for a hatch pattern definition. Very complex patterns can take dozens and dozens of lines of code. What this means is that AutoCAD draws the line as long as necessary.5 Rotation angle <0>: 20 The DSettings command lets you set these values via a dialog box: Snap Angle. then AutoCAD starts the hatch at 5. which is important for accurate placement of the patterns or lining the pattern up with another pattern.1. then AutoCAD draws the hatch lines at 65 degrees. use system variable SnapBase. This draws a continuous line. If you are uncomfortable using system variables.0. as long as it reaches a boundary. But be careful: a complex hatch pattern takes a long time to draw.0>: 5. At the very least. the two lines of data (above) represent a hatch pattern with two lines. The dash1 parameter(s) is optional but when used draws a line with the dash-gap-dot pattern.and y-origin.1.1. each line of pattern code must include the angle. Thaw the layer when you need to see the pattern or plot the drawing. The effect of SnapBase on the hatch pattern origin is additive: if the hatch pattern specifies that the lines start at 0. you’ve got a couple of options: • Specify the angle during the Hatch and BHatch commands. To change the x.5. • Set the angle in system variable SnapAng. AutoCAD will not draw the hatch pattern unless it does find a boundary. x. For whatever reason. place hatch patterns on their own layer in a drawing. To change the angle of a hatch pattern upon placing it in the drawing. The effect of SnapAng on the hatch pattern angle is additive: if the hatch pattern defines the lines drawn at 45 degrees and SnapAng is 20 degrees. then the Snap command provides the same opportunity via its Rotate option: Command: snap Snap spacing or ON/OFF/Aspect/Rotate/Style: rotate Base point <0. and Y Base.y-origin of a hatch pattern upon placing it in the drawing. then freeze that layer.and y-offset. and the x. For example: Command: snapang New value for SNAPANG <0>: 20 The x-offset and y-offset parameters are unaffected by the angle parameter.11 and SnapBase is 5.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ .5. Hatch pattern lines are drawn infinitely long.Tips on Creating Pattern Codes Some miscellaneous comments on hatch pattern coding: Each line of code applies to a single pattern segment. X Base. 110 • v2. AutoCAD does not make it easy to change the origin of the hatch pattern.

along with the others. -1.y-offset 37. 2.123.pat files into the acad. -. . This means that AutoCAD 2004 stores user-specific files. -1. The problem is that AutoCAD 2004 is designed for use with Windows 2000 and XP.678. -. gap. have to restart AutoCAD after adding patterns to acad.. I added the following pattern definition to the end of the acad.. 0. such as acad. dot.625 -. 0.5. 0.0. Random dot pattern .. in a variety of locations in order to keep files customized by different users separate from each other. like this: *AR-SAND.0. -42.angle x.25 You cannot specify arcs. -1. use a series of very short dashes. 0. dash 0.5. six months from now) to read your hatch pattern code if you use tabs and spaces to format the code into nice columns. gap) -1.37. tailoring AutoCAD 2004 chapter 7 hatch patterns • 111 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ .02.25. 0. Craig Hunt made the following discovery: “In AutoCAD 2000 and newer you no longer need the slide library utility (slidelib.678.2.25 0.1. both of which are multi-user operating systems. 0. 0. 0.005 45. 0.0.-.0.6234.5.0. -1.866 1.35 Adding Custom Patterns to the Dialog Box Finally.5. 0.exe) to show hatch pattern previews.52. such as: *Thick_Line.01. No sign of the pattern. I did eventually get the new pattern to show up in the Boundary Hatch dialog box’s preview panes.6234.5. gap. 0. however..567.-yorigin x.18. -1.pat before they show up.82.23.25.pat file.5. Closely spaced lines 0. 0. 0. “I combined several separate .005 I saved the file.5. use the sine of the angle in degrees. -1.0.pat file: *CUSTOM. -. 1. Everything consists of straight lines and dots. . The new hatch patterns are previewed.7.123.2. let’s see how to add your custom-made hatch pattern to the BHatch dialog box.. You do. -32.5. 0. 0. 0. like this: Angle 0 30 45 60 90 Dash length (sine) 0 0.25 0. AutoCAD automatically creates the preview from the hatch patterns in the acad.8. 0.433 0. Tailoring AutoCAD 0.-. 0.567. codes (dot. circles..You cannot specify a weight (or linewidth) for a hatch pattern line. and other round elements in a hatch pattern file. -1. 1. 0. The workaround is to define two or more very closely spaced lines.pat..707 0. 7.pat file. 0.35 -1. dot.23. 0.1.0 It’s a lot easier for someone else (or you. To draw dash and gap segments at an angle. 0. To simulate circular elements. 0.0.525 -2. 2. and then started AutoCAD.” To test Mr Hunt’s finding.

Ltd. one at a time.eZine Publishing.upfrontezine. I found acad..upfrontezine. button (next to Pattern). Copyright Information This book is covered by copyright. All rights reserved worldwide. I finally discovered that the correct acad.eZine Publishing. upFront. Scroll to the end to see the preview of the added pattern definition (“CUSTOM”). and then click the . For more of our technical e-books. Feedback I welcome your feedback for correcting and improving the text. some of which are hidden folders: \AutoCAD 2004\Support \AutoCAD 2004\Backup \AutoCAD 2004\UserDataCache\Support (a hidden folder) --->\Documents and Settings\username\Application Data\Autodesk\AutoCAD 2004\R16. Copyright © 2004 by upFront.pat file is the one stored in \documents and settings\username\application data\autodesk\autocad 2004\r16. re-starting AutoCAD each time. You may not claim authorship or ownership of the text or figures herein. 112 • v2.Using the Windows Search facility. Visit the Tailoring AutoCAD 2004 e-book Web site at www. To see the preview image. Send your email to editor@upfrontezine. does not give you permission to make electronic or print copies.pat stored in seven locations.com to purchase additional copies.0\en\Support (a hidden folder) \Documents and Settings\username\Favorites\Autodesk \Documents and Settings\username\Recent I added the code to each acad.com/ebooks.0\en\support (a hidden folder). visit the eBooks.com. highlighted above with the arrow. Contact editor@upfrontezine. Select the Other Predefined tab. Ltd.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ .onLine Web site at www. As the owner of the copyright. start the BHatch command.pat file..com/tailor2004.

shp file. The squiggles and text found in complex linetypes are defined by shapes in the ltypeshp. which is the subject of this chapter. The drawback to shapes. and GDT symbols. Complex linetypes are loaded and placed with the LType command.shp files. and then more recently TrueType fonts (.shx files for several purposes: shapes.000). The first time a . The symbols are defined by shapes in the gdt. as computer became faster. unlike blocks. however. Fonts are loaded with the Style command. however. Shapes are like blocks. and placed with the Text and MText commands. but take up a fraction of the memory. the shape definition allowed for efficient text. Fonts were originally coded as shapes for the same reason: text was one of the slowest parts of the drawing display (hence the QText command that turned lines of text into rectangles). found in the \autocad\support folder. you must first use the Compile command to change it to an .shx fonts. which could take minutes). GDT symbols (geometric dimensioning and tolerancing) is the other area where shapes are still used. Over the last decade. AutoCAD compiles it into a . The symbols are placed with the Tolerance command. Autodesk switched initially to promoting PostScript fonts (. Shapes are loaded with the Load command.psf). although the MkShape command can be used to create shapes from selected objects. See chapter 6. and as a limited form of security. when memory was scarce and expensive (1MB of RAM cost $10. nor can they fill the font’s outline. when computers were slow (every zoom and pan forced a drawing regeneration. complex linetypes. AutoCAD still supports .psf font. to use a .eight shapes & fonts tailoring autocad 2004 a utoCAD uses .shp file found in the \autocad\support folder. Shapes were popular in the early days of AutoCAD.shx file.shx file automatically for faster execution. You can create your own .ttf).shp file is loaded. fonts. ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ tailoring AutoCAD 2004 chapter 8 shapes & fonts • 113 . and then placed in the drawing with the Shape command. Complex linetypes is one area where shapes are still in use.shp and . is that they are not well-suited to defining the complex curves that fonts require. shapes are usually to be hand-coded using an arcane method described in this chapter.

.002. Tutorial: Creating Shapes 2004 The traditional method of creating shapes was tedious: writing the code in a text editor.shp and . Normally. and then repeated debugging by loading it into AutoCAD. AutoCAD prompts you to give the shape a name: Enter the name of the shape: spotlight . 5. (A search in Google for “shx decompilers” comes up with several products..) TIP A higher resolution draws a more accurate shape.shp file looks like this: *130. A . include the source .shp file.shp files are found in the \autocad\support folder. you cannot edit .shp file. which creates shapes from objects selected in the drawing. and the objects Select objects: (Select one or more objects.Select Shape File dialog box. and then click Save — a bit misleading.) 114 • v2. since the saving doesn’t occur until later.) Select objects: (Press ENTER. and a resolution: Enter resolution <128>: (Press ENTER.TRACK1 014.6.) TIP When AutoCAD is installed on your computer. Notice that AutoCAD displays the MKSHAPE . Note: You can add shapes to an existing .shx and gdt. Here’s how to use it: 1. 2. Resolution is rounded to the nearest value 8. When you write or edit a shape or font.) • . In summary. unless you have access to a shape decompiler program written by third parties. such as the center or lower-left. The default of 128 is good enough for most cases.shx and .. draw something you want turned into a shape.About Shape Files There are two kinds of shape files: . From the Express menu. In AutoCAD.shx fonts in the \autocad\fonts folder. Enter a file name.) .shp files for the ltypeshp. 3. AutoCAD compiles .767. select Tools | Make Shape. 4. AutoCAD asks you to pick the insertion point: Specify insertion base point: (Pick a point.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . it places its . or start a new file. the maximum value is 32.01C. you work with the .0 AutoCAD no longer includes any sample shape files.01C.shx are compiled shape files.001. Via the Express Tools collection.shx.shp are shape source files..shp files automatically into .shx files. AutoCAD 2004 provides the MkShape command. All other . however.ttf fonts in the \windows\fonts folder and its . it does.shx format. the differences are: • .shx files in \autocad\support folder.

(0.80.001.3).) Specify height <1.0000>: (Press ENTER.AutoCAD then gets busy creating the shape: Determining geometry extents.|Done.7).(-5.3).0).0).(-7.0).-3).(0.-43).(1.9.002.6).(-68.9.9.001.100.002..80.-68). Shape "SPOTLIGHT" created.17).9. Formating coords.(0.3).3.(5.2).(0.2).(-7.9.-6).001.-6).4.3).SPOTLIGHT 4..(0.6). Use the SHAPE command to place shapes in your drawing.(-20.(-5.0).4).(0.125.002. Compiling shape/font description file Compilation successful.1).19). and punctuation.9.(0.69) (0.(-43.002.9.(-2.(0.(-5.(13.-3).(-3.Done.-16). The prompt is.-3) (-6.(0.(0.0) 002.0).4).002.(43.3. Writing new shape.26).(6.0).002.45) (0.(-6.4.-56).128.128.(2.shp file reveals the following mysterious string of numbers.shx file contains one or more shapes.9.Done..(7.-7).(0.(-20.(4.001.0).5).(7.(0.(11.(7.(3.(-7.4.3.(33.0).100.shx contains 315 bytes.001.(93.12)..(-7.(-4.(6.(-2.3).9.9.001.002.001.5). • The Shape command places the shape in the drawing: Command: shape Enter shape name or [?]: spotlight Specify insertion point: (Pick a point.0).21). followed by the Shape command: • The Load command loads the .(0. unfortunately.12).0).(0.0).0).125.0).0).9.(-7.0).0).-17). 6.(-7.shp) file into AutoCAD.002.2).0).0).(0.(0.shx (compiled .0 tailoring AutoCAD 2004 chapter 8 shapes & fonts • 115 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ .9.001.7).9.(0.0).9.002.001.(-26.2).(5.(0.(-11.001.35).0).(0..0).(8.0).0)..2).0).(0.002.(7.(8.001.3).001.001.(1.Done.(-18.(0.(5.0). incorrect: To place shapes in the drawing..9.0).0). Examining the code in the tailor.7). Aren’t you glad that someone took the time to write MkShape? *1.-5).-4).-7).001. first use the Load command.(-13.9.(0.9.-12).0) 002. Recall that the .002.(0.(0.-5).(0.0). Building coord lists..(11.001.-12) (0.9.(76.-4).268.9.16).9.(-16. Output file C:\Tailor.(-11.(0.9.(-7.-2).125.002.4).0).0).0).9.(7.3.9.(2.-6).(0.002.9.) The shape appears in the drawing.-45).9.-4) (0.4. letters.9.9.9.(0.6).3.125.9.(16.9.(26.9.002.(0.(0.9.9.-1).(0.-7).(7.001.) Specify rotation angle <0>: (Press ENTER.(7.001.002.

000 bytes. You can use blank lines to separate shape definitions. and 258 for the degree.The Shape File Format There are two forms of the shape file: one for shapes (simple blocks). Unicode font files can have up to 32. Font files typically define all the characters — such as A-Z... U+00B1 and U+2205 in the Latin Extended-A subset. 116 • v2. A single definition is limited to 2. followed by one or more definition lines: *shapeNumber. TIP AutoCAD reserves shapeNumbers 256. Like some other customization files. and the semicolon ( . 0. Each line can be up to 128 characters in length. (Makes no sense to me. Because names with lowercase characters are ignored. For shapes. a shape definition consists of two or more lines. Header Fields The general format of a shape definition a header lines.. including the terminator. starting with 1. such as 65 for the letter A. shapeNumber Each shape requires a unique number by which it is identified. The difference is that fonts include a code 0 that alerts AutoCAD to treat the file as a font. you can use them for in-line comments. for fonts. totalBytes After defining the shape. which is called the terminator. which labels the shape. ) to include comments in the file..shapeName byte1.totalBytes. plus-orminus.000 bytes per shape definition. Unicode shape numbers count as two bytes each.byte3. you have to add up the number of bytes that describe the shape. 0-9.byte2. the number is the equivalent ASCII code. the numbers are usually sequential. these are numbered U+00B0. while the second (and following) lines define the shape through codes.0 The following describes the fields of the shape’s header description: * The asterisk signals to AutoCAD that the next shape definition is starting. The final code in each definition is 0.768 definitions.) There is a limit of 2. and one for fonts. 257. and punctuation — for a single font. Shape files typically define one or more shapes. shapeName Shape names must be in all uppercase. and diameter symbols. a-z. AutoCAD will not compile a shape file with longer lines. The first line is the header. up to 258 shapes in total.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . In Unicode fonts. not a shape.

Vector codes are always in hexadecimal notation. Bytes define vector lengths and directions. Vector Codes Vector codes describe how the shape is drawn. By now. and can be in decimal (base 10) or hexadecimal (base 16) format. ranging from 1 through F (15 units). 02C would draw a line 2 units long in the -y direction (downward).Definition Lines The header line is followed by one or more lines that define the shape or font. and a maximum of 2. Definition lines are a maximum of 128 characters long (including commas). Vector codes are limited to 16 directions. and you will now see why shapes are rarely used anymore. tailoring AutoCAD 2004 chapter 8 shapes & fonts • 117 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . Thus. you can see that you need to understand hexadecimal notation. • 2: Second character specifies the vector’s length. byten The shape is defined by “bytes.” called that because each code is a single byte (the common computer measurement) in size. They define movement (pen up) and drawing (pen down). and instruction codes. as noted by the figure above. as shown by the figure: Notice that the lengths are not radial: the diagonal vectors (such as 2 and E) are 1. • C: Third character indicates the direction. such as 00C (12. this means that the two characters following are in hexadecimal. in decimal). This is the nitty-gritty part of shape files.414 (square root of 2) times longer than the orthogonal vectors (such as 4 and 0). The codes are all numbers. such as 02C: • 0: First character is always 0 to alert AutoCAD that the number is in hexadecimal. The last definition line ends with a 0. TIP When the first character of a byte is a 0.000 bytes overall (not including commas).

For example.y displacement and bulge. note that drawing is limited to lines.2 TIPS Within a shape definition. Each shape starts off at the height of one of the orthogonal vectors.63).(2. X.0. every shape definition starts with draw mode turned on. 0/000: End of Shape Code 0 must mark the end of every shape definition. Multiply vector lengths by next byte. It appears at the end of the last line.0) code. 3. In the sample below.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . Draw subshape number given by next byte.y displacements. Multiple bulge-specified arcs.(-36. Fractional arc defined by next five bytes. Divide vector lengths by next byte. 2/002: Move Mode Code 2 starts move mode (“pen” is up).(36. arcs. Process next command only if vertical text code exists. the following code draws the shape half as large: 3. 118 • v2. By default. At the end of the shape definition.-127). End draw mode (pen up). Pop current location from stack.0 3/003: Reduced Scale Code 3 specifies the relative size of each vector. terminated with (0. 1 through 255. To make the shape smaller. 00C. Hex 000 001 002 003 004 005 006 007 008 009 00A 00B 00C 00D 00E Dec 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 Description End of shape definition.Instruction Codes In addition to describing direction and length. Arc defined by x.2 followed by another 3.8. Using the same scale code twice multiplies the effect. the scale factor is cumulative. Push current location onto stack.2 makes part of the shape four times smaller.2.1. Notice that some codes rely on additional codes following.0 1/001: Draw Mode Code 1 starts drawing mode (“pen” is down). use code 3 followed by a byte specifying the scale factor. Multiple x. such as 4. For example. the pen is raised before moving to a new location. Code numbers can be in decimal (dec) or hexadecimal (hex) . shapes codes provide drawing instructions. And. return the scale to unity so that other shapes are not affected. Octant arc defined by next two bytes. 8.-63).y displacement given by next two bytes. Begin draw mode (pen down). and gaps.

” When two numbers are stored in the stack memory.01E.1.01E.(8.14. Think of an elevator.6.01A.-32).14. 14.14.2. 5/005: Save (Push) Code 5 saves the current x.8. Code 8 defines a distance using two bytes that range from -128 to 127: 8.1. between 1 to 255. You then use code 6 to recall (pop) the coordinates for later use. 8.0E0.y-coordinate to the stack memory.(13.1.01A. which helps reduce the tedium of coding shapes. For example.1.3.19).02B.012. Shapes can be used within other shapes.-32). which is simply another shape. 8. last out.2.8.-19).14.8.xDistance.8.(6.0 A stack is a specific type of memory called FILO memory.) For example: 7.(-15. 8.2.-50) draws 21 units down (-x).02C.0E0.1.8.4. 8.2 calls shape 2 as a subshape.02C.(-21.5.8.016.(-6.(-21.(-7.2.2.2 Note that you can use the 3 and 4 codes within a shape definition to make parts of the shape smaller and larger.-25). By the end of the shape definition. (Recall that all shapes within a .2. 1 through 255.(8.14. 8/008: X.-32).14. The stack memory is limited to four coordinates. as shown below: 2.2.14..02B. where the first person in is usually the last one out.(4.2. use code 4 followed by a byte specifying the scale factor. the following code draws the shape twice as large: 4.-6).2.e.5). 7/007: Subshape Code 7 calls a subshape.4/004: Enlarged Scale To make the shape larger.2.(-8.(21.5. and 50 units left (-y).14.shp file are identified by number.-6).-50).6.y Distance Codes 8 and 9 overcome the restriction that the vector codes (limited to just 16 directions) place on the drawing.32).(11.yDistance The example below shows that code 8 is used often: 2.-9).25).8.8.14. you must recall all coordinates that you saved. i. the last number stored is the first one out. 6/006: Recall (Pop) Code 6 recalls the most-recently saved coordinates from the stack memory. Unicode fonts use code 7 followed by a Unicode shape number between 1 to 65535.01A.1.8.24). tailoring AutoCAD 2004 chapter 8 shapes & fonts • 119 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ .3.8.012.(-7.0 In the first example.016.(4.01A.14. Code 7 is followed by reference to another shape number.8.4. there must be an equal number of code 5s and 6s. short for “first in.14.

. The startingOctant specifies where the arc starts.(1.2). The 0 specifies the following characters are hexadecimal. leave it out for counterclockwise direction.(0. The octantSpan specifies how hard the arc travels. The octant arc code usually uses parentheses to make itself a bit clearer.(25. which is an arc whose angle is limited to multiples of 45 degrees. as shown by the figure. code 9 specifies a series of coordinates.radius. terminated by (0.0) 10/00A: Octant Arc Code 10 defines an octant arc.-6).0 startingOctant octantSpan The 10 specifies an octant arc. The negative sign changes the direction of the arc to clockwise.(-3. such as: 10.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . TIP When octantSpan is 0. the shape draws a circle.4). For example: 9.9/009: X.0). The radius is a value between 1 and 255.-040) 120 • v2. the value ranges between 0 and 7). The arc is specifies by the following bytes: 10. again a number between 0 through 7.(5.y Distances Whereas code 8 specifies a single coordinate.

leave it out for counterclockwise direction. five bytes: 11. The highRadius specifies a radius larger than 255 units. The octantSpan specifies how hard the arc travels. tailoring AutoCAD 2004 chapter 8 shapes & fonts • 121 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . the magnitude of the bulge is ((2 * H / D) * 127). when the arc has a radius of 255 units or smaller. Here is how Autodesk says the bulge is calculated: “If the line segment specified by the displacement has length D. while line would have a value of 0. Here is how Autodesk suggests finding the value of startOffset and endOffset: 1. and the perpendicular distance from the midpoint of that segment has height H. then this parameter is 0. The radius is a value between 1 and 255. For an arc of greater than 180 degrees. The bulge specifies the curvature of the arc. Divide the result by 45. however. 0C. 3.startOffset. again a number between 0 through 7. use two arcs in a row.11/ 00B: Fractional Arc Code11 is more useful because it draws arcs that are not limited to ending and starting at octant angles. The startingOctant specifies where the arc starts. Determine the offsets by calculating the difference in degrees between the starting octant's boundary (which is always a multiple of 45 degrees) and the start of the arc. The 0 specifies the following characters are hexadecimal. 2. Its specification requires.y-coordinates of the arc.radius..endOffset. Multiply the difference by 256.” A semicircle (180 degrees) would have a bulge value of 127 (drawn counterclockwise) or 127 (drawn clockwise).xDisplacement.highRadius. The endOffset specifies how far from an octant angle the arc ends.0 startingOctant octantSpan The 11 defines the fractional arc.bulge The xDisplacement and yDisplacement specify the starting x. TIP 12/00C: Bulge Arc Code 12 draws a single-segment arc by applying a bulge factor to the displacement vector. the value ranges between 0 and 7. then adds it to radius value to find the radius of the arc. The negative sign changes the direction of the arc to clockwise. All three values range from -127 to 127.yDisplacement. The startOffset specifies how far (in degrees) from the octant angle the arc begins. AutoCAD multiplies the highRadius by 256.

Visit the Tailoring AutoCAD 2004 e-book Web site at www.13/00D: Polyarc Code 13 draws a polyarc. Contact editor@upfrontezine. When the orientation is vertical.(0. in The The Express Tools collection has several commands useful for working with addition to MkShape described earlier in this chapter. the code is skipped.com. All rights reserved worldwide.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ .upfrontezine.upfrontezine.onLine Web site at www. does not give you permission to make electronic or print copies. Send your email to editor@upfrontezine.2. Shp2Blk command converts shapes into blocks.0).com/ebooks.(0. Copyright © 2004 by upFront. 122 • v2.eZine Publishing.eZine Publishing. if horizontal.(0. It is terminated by (0.127). 13. upFront.-127).com/tailor2004. Ltd. You may not claim authorship or ownership of the text or figures herein. visit the eBooks. an arc with two or more parts. than to switch between arcs and lines. For more of our technical e-books. 14/00E: Flag Vertical Text Flag Code 14 is for fonts only. As the owner of the copyright. Ltd. Feedback I welcome your feedback for correcting and improving the text. and only fonts that are designed to be placed horizontally and vertically. the code following is processed. Copyright Information This book is covered by copyright.2. TIP The shapes. TxtExp command explodes text and mtext into polylines.0) TIP To draw a straight line between two arcs. it is more efficient to use a zerobulge arc.com to purchase additional copies.

don’t use a word processor.scr . and — significantly— AutoLISP code.scr. and to close tailoring AutoCAD 2004 chapter 9 script files • 123 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . I write scripts at the Windows command prompt: C:\> copy con filename. A script file to draw a line and a circle looks like this: line 1. Sometimes.2 circle 2. w-w-a-a-y-y back in 1983. when I feel like a power user. Instead. That includes AutoCAD commands. Anything you type in AutoCAD that shows up at the ‘Command:’ prompt can be put into a script file.nine script files tailoring autocad 2004 i n this chapter. their option abbreviations.1 2.4. or Word. For that reason. A script does one thing and one thing only: it mimics what you type at the keyboard. cannot be included in a script file.2 circle 2. CTRL+Z to tell Windows that I’ve finish editing. The purpose of the script is to reduce keystrokes by placing the keystrokes in a file. we look at AutoCAD’s clearest customization possibility: the script. Script files are in plain ASCII.This is the script file line 1. such as WordPad. What are Scripts? Script programming was introduced to AutoCAD with version 1. I press F6 or the file.2 1.1 2. use Notepad to write scripts.1 Script Files Script files have an extension of .1 When I’m done. Think of it as a predecessor to the toolbar macro. Anything you cannot type at the keyboard.2 1. OpenOffice. including selecting buttons in dialog boxes and toolbars. your responses.

use the related system variable(s) instead. and FileOpen (Open). For example. Some third-party developers have attempted to write automated script creation software. use the -Plot command. such as (dialog box version in brackets): Layer (Layer). An alternative to controlling the plot process is to pre configure a bunch of . For example: Command: script Script file: ~ (AutoCAD displays Select Script File dialog box. such as my own The Illustrated AutoCAD Quick Reference (Delmar Learning). Thus. call other script files. Strictly Command-Line Oriented There are two limitations to scripts that are significant in this age of GUIs (graphical user interfaces): scripts cannot record mouse movements.Drawbacks to Scripts One limitation to scripts is that only one script file can be loaded into AutoCAD at a time.pcp files. which lists all command names and their options. The script can. Or. Turn filedia . and other times it’s a system variable. the DSettings dialog box controls about a dozen system variables. to change settings in the script. ChProp (DdChProp).1 11 nov 2003 .) • To control plotting with a script. and scripts cannot control dialog boxes. nearly all commands that display a dialog box have a command line equivalent in AutoCAD. as follows: . however. a script file would include the following lines to turn off dialog boxes: . Script. • Sometimes it’s a command. you can use some other customization facility to load script files with a single mouse click. Another limitation is that scripts stall when they encounter invalid command syntax. ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ 124 • v2. This forces commands that display the Open File or Save File dialog boxes — such as DxfIn. Change layer: clayer layername • Some commands need system variable FileDia turned off (set to 0). It is useful to have an AutoCAD reference text on hand. use the ~ (tilde) as a file name prefix to force the display of the dialog box. inconsistent in how it employs these commands. I sometimes have to go through the code-debug cycle a few times to get the script correct. AutoCAD is.” and can be accessed via a pair of system variables: Plotter lets me select a plotter configuration. as follows: -plot Detailed plot configuration? [Yes/No] <No>: etc.. and AutoLISP routines. If a script needs to change a layer. These hold “plot configuration Parameters. For these reasons. Load vslide off dialog boxes: 0 slide file: filename When FileDia is turned off. and VSlide — to prompt for the filename at the command line. use the -Layer command — or better yet — the CLayer system variable. such as toolbox or menu macros. PlotId tells me the name of the current plotter configuration.. There are. five different ways to going about this: • Some commands have different names. however. in fact.

There is no way to control these commands from a script file. Again. where 1. There are no options: Command: rscript Story Time: When AutoCAD first introduced AutoLISP in version 2. and (2) immediately begins running it: Command: script Enter script file name <C:\AutoCAD\Drawing1. prefix the hyphen. In fact. it was a rudimentary form of LISP that Autodesk called “Expressions and Variables.scr>: filename Remember to turn off (set to 0) the FileDia system variable.000 millisec○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ tailoring AutoCAD 2004 chapter 9 script files • 125 . In fact. AutoCAD displays the following prompt: Mline editing option AV/DV/CC/OC/MC/CT/OT/MT/CJ/CS/CA/WA: I leave it as an exercise to the reader to figure out the meaning of those 12 options! • Some commands have no command-line version. use the Delay command along with a number. In rough order of importance. Third-party programmers proved him wrong by using the RScript command to repeat AutoLISP functions. The number specifies the pause in milliseconds.” It was so weak that it lacked conditional expressions. Pause a script file by pressing the Backspace key. no options: Command: resume Delay To create a pause in a script file without human intervention. instead of the dialog box. RScript Short for “repeat script. Resume This command resumes a paused script file. while. Scene. so that prompts appear at the command line. Render. Script Commands and Modifiers There are a grand total of four commands that relate specifically to scripts. these commands are of absolutely no use for any other purpose.” this command reruns whatever script is currently loaded in AutoCAD. Lights. these are: Script The Script command performs double-duty: (1) it loads a script file.(hyphen) as a prefix to force the command line version. To use these in a script file. The list primarily consists of commands related to OLE and rendering: OleLinks. such as if-then.• Some commands use the . Autodesk CEO John Walker said there was no way to create a loop in Expressions and Variables. Start the multiline edit command: -mledit Instead of the Multiline Edit Tools dialog box. and repeat. A great way to creating an infinite loop. as follows: .17. and so on.

onds equal one second.. Sometimes. Edit the attributes one at a time: attedit 1.2 Now it’s easier to count those four spaces. That lets you create a delay during the operation of a command — as if I needed an excuse to run AutoCAD slower! 126 • v2. Edit the attributes one at a time: attedit 1. that makes little sense. both are interchangeable. there are some special characters and keys. For this reason.2? I’ll wait while you count them . (semicolon) You probably have already noticed that the semicolon lets you insert comments in a script file. like this: .1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . Simply prefix the Script command to run a script while another command is active. AttEdit is an excellent example: . since there is one per blank line. ' (apostrophe) Scripts can be run transparently during a command. Delay is used in a script file to wait while a slide file is displayed or to slow down the script file enough for humans to watch the process.. AutoCAD ignores anything following the semicolon. The minimum delay is 1 millisecond. the maximum is 32767 milliseconds.2 How many spaces are there between attedit and the coordinates 1. instead. it is better to place one script item per line. (space) The most important special characters are invisible: both the space and the carriage return (or end-of-line) represent you pressing the spacebar and Enter key. all four of AutoCAD’s script-specific commands are transparent. While you could use Delay at the ‘Command:’ prompt. which is just under 33 seconds. like this: Command: line Specify first point: 'script >>Script file: filename The double angle bracket >> is AutoCAD’s way of reminding you that it has two commands on the go. even 'Delay. In fact. like this: . Pause script for ten seconds: delay 10000 Special Characters In addition to these four script-specific commands. . But the tricky part is that they are invisible. I’ll write a script that requires a bunch of blank space because the command requires that I press the Enter key several times in a row. In fact.

. use the RScript command to start it up again from the beginning (In Release 12. tailoring AutoCAD 2004 chapter 9 script files • 127 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ .* (asterisk) There is one special case where the asterisk gets used. AutoCAD pre-loads it to provide faster slide viewing performance: *vslide Backspace ..stops a script file dead in its tracks. and earlier. instead. Esc .is the key I already mentioned for pausing a script file. to stop the script). press CTRL+C. LT R2... When you prefix the VSlide command with the *.

com. You may not claim authorship or ownership of the text or figures herein.eZine Publishing. visit the eBooks. Send your email to editor@upfrontezine.Copyright Information This book is covered by copyright.com/tailor2004.upfrontezine. does not give you permission to make electronic or print copies. 128 • v2. Feedback I welcome your feedback for correcting and improving the text.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . As the owner of the copyright. Contact editor@upfrontezine.com/ebooks.com to purchase additional copies.eZine Publishing.onLine Web site at www. Copyright © 2004 by upFront.upfrontezine. Ltd. upFront. For more of our technical e-books. Visit the Tailoring AutoCAD 2004 e-book Web site at www. Ltd. All rights reserved worldwide.

Users wanted more information. S (snap is on). Newer additions included P (paper space is on) and a square indicating the current color. the display driver allowed users to customize the status line to a limited extent. however. the x. the status line displayed O (ortho is on).ycoordinates. and the layer name. even fundamentally basic information.ten diesel expressions tailoring autocad 2004 or a dozen years. Sometimes. those seven indicators were not enough. Right through to Release 11. For all that AutoCAD does. T (tablet is on). such as the missing z-coordinate. the status line of AutoCAD remained unchanged. The official Autodesk response was along the lines of. so it’s best we do nothing. f tailoring AutoCAD 2004 chapter 10 diesel expressions • 129 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . We wouldn’t be able to add more without missing out on what some other user wants.

What Diesel Does Diesel allows you to change AutoCAD’s status line so that it displays useful information. who are more price sensitive. where the result of one function is evaluated by another function. While its purpose is to customize the status line. however: the text displayed by Diesel is truncated after a certain number of characters. and the time. Is Diesel a true programming language? For me. and so on. simply select options from a dialog box. A comma always separates the function name and the variable(s). Despite the word “string. the . Despite the handicap. or even GreaterThan. This allows Diesel functions to be nested.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . Short for “direct interactively evaluated string expression language. Also. Diesel has an unusual format for its macro language. who deliberately disabled the AutoLISP that was supposed to ship with LT (retailers were worried LT’s low price would cannibalize sales of full-blown AutoCAD). There is a limitation. the parentheses allow Diesel to work on more than one variable at a time. 130 • v2. unfortunately. and 39 characters in Release 13 for Windows and later.” the programming logic of Diesel is as clear as the acronym’s meaning. but the syntax is so obscure and its functions are so few that it begs to be known as a simple macro language — and that’s how I’ll refer to it from now on. While. European and Australian programmers. The limits are 32 characters in AutoCAD 12. the line of differentiation between a macro language and a programming language is whether it contains logical functions. some take as many as nine variables. users needed to learn Yet Another Programming Language. such as the z-coordinate. The closing parenthesis alerts Diesel that there aren’t any more variables. the purpose of the $-sign is to alert the AutoCAD command processor that a Diesel expression is on the way.dwg file name. Diesel works with 28 functions names. Diesel has found its way into menu macros. Instead. Diesel has logic functions. All Diesel functions take at least one variable. Autodesk introduced the fully customizable status line. Diesel tolerates no spaces. such as If. Logic functions make it possible for the program to make decisions. Users could not.variable) No doubt. and the sixth programming interface added to AutoCAD at the time. no matter how big you make the window. this one called Diesel. have done some amazing things for LT third-party software with Diesel’s limited facilities. just as the ( symbol alerts AutoCAD that an AutoLISP expression is coming up. The opening and closing parentheses signal the beginning and end of the function.The History of Diesel Then with AutoCAD Release 12 for DOS. not strings.” Diesel operates on numbers primarily. and became the most powerful programming environment available in AutoCAD LT — much to the chagrin of Autodesk. Every function begins with the dollar sign and a bracket: $(function.

although it is limited to toggling the display of existing buttons. Right-click the status line to display the shortcut menu: tailoring AutoCAD 2004 chapter 10 diesel expressions • 131 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . Returns the length of the display TIP AutoCAD 2004 allows interactive modification of the status line.Brief Listing of Diesel Functions Here is a summary of the functions supported by Diesel: Math Functions + * / Addition Subtraction Multiplication Division Logical Functions = Equal < Less than > Greater than != Not equal <= Less than or equal >= Greater than or equal and Logical bitwise AND e q Determines if all items are equal if If-then o r Logical bitwise OR xor Logical bitwise XOR Conversion Functions angtos Converts number to angle format fix Converts real number to an integer rtos Converts number to units format String Functions index nth strlen substr upper Extract one element from a single comma-separated series Extract the nth element from a one or more items Returns the number of characters of the string Returns a portion of a string Converts text string to uppercase characters System Functions edtime eval getenv getvar linelen Displays the system time Passes a string to Diesel Gets a variable from the .ini file Gets a system variable. and not the addition of user-useful items.

Use the function to display the current elevation by calling the Elevation system variable. 1.0000 or something similar on the status line. The cryptic error messages are printed by Diesel on the status line. along with an example of how the error can occur: $? This error message means you left off the right parenthesis.??) You provided the wrong number of arguments the function.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . Enter the ModeMacro system variable at the ‘Command:’ prompt. you forgot the left quotation mark. type the ModeMacro system variable with a "" (null string).Jumping Into Diesel Enough of the preliminary stuff. for example. for example: $(+. $(if) $(++) The output string too long. or . for example. To restore the status line. for none <"Tailoring AutoCAD">: "" 3. $(stringlenth. and displays it on the status line. the words “Tailoring AutoCAD” should appear near to (or in place of) the coordinate display: 2. for none <"">: Tailoring AutoCAD Depending on where the status line is in your copy of AutoCAD.. Diesel Error Messages To go along with its obscure syntax. To display the value of a system variable on the status line.2 Or. . ) $(func.. Here’s what they mean. as follows: Command: modemacro New value for MODEMACRO. as follows: Command: modemacro New value for MODEMACRO. for none <"">: $(getvar.elevation) AutoCAD displays 0. and type something: Command: modemacro New value for MODEMACRO. and put the customizable status line feature to work. for example: $(eq. This function gets the value of a system variable.1. Diesel has an equally-bazaar set of error messages— all four of them. 132 • v2. or ."To $(func)?? You typed the wrong name of the function. Let’s jump right in. or . use the $(getvar function.

Use AutoLISP’s (strcat) function to string together a Diesel macro within AutoLISP. tailoring AutoCAD 2004 chapter 10 diesel expressions • 133 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ .$(getvar. Use the ModeMacro system variable to output the Diesel macro to the status line. ModeMacro outputs directly to the status line.27 A bug in MacroTrace causes it to reevaluate the most recent Diesel expression over and over again. use double quotations: ""Test"" Use the MacroTrace system variable to debug the macro.2.filletrad)) Command: macrotrace New value for MACROTRACE <0>: 1 Command: modemacro New value for MODEMACRO. for none <"">: $(*.54. To prevent evaluation of a Diesel macro.Debugging Diesel To help track down bugs in Diesel macro. however.filletrad)) Eval: $(*. there must be no spaces within the expression.54. turn on the undocumented MacroTrace system variable. It does not. $(getvar. Use the $M= construct to use Diesel expressions in a menu macro. 2. until it reaches a $(.filletrad)) Eval: $(GETVAR. interfere except visually. use quoted strings : "$(+. filletrad) ===> 0. to display quotation marks on the status line. then it begins evaluating the macro. MacroTrace re-displays its evaluation.5 ===> 1.1)". the maximum display on the status line is roughly 32 characters. or . as follows: Command: macrotrace New value for MACROTRACE <0>: 1 When on. For this reason. The maximum length of a Diesel macro is approximately 460 characters. turn off MacroTrace when you no longer need it.2. as follows: Command: macrotrace New value for MACROTRACE <1>: 0 Diesel Programming Tips Here are some tips for working with Diesel: Each argument must be separated by a comma.54. which converts the value of the fillet radius to metric: $(*. Each time I type something at the ‘Command:’ prompt (such as the Line command). $(getvar. AutoCAD displays a step-by-step evaluation of the Diesel macro in the Text window. Here’s how it works for this Diesel macro.

which has four different meanings. Here starts the if Diesel expression. or the macro won’t work!) Before we step through the menu macro. “false” means the value is zero. depending on who is accessing the value: DimAso 1 (default) 0 Meaning for AutoCAD Use associative dimensions Use non-associative dims Meaning for Diesel "if" Expression True False .dimaso). No spaces are allowed! The pair of characters !. “True” in Diesel means the expression has a value of 1. It is fairly trivial to display the check mark: simply prefix the word with the !. it sets the value of system variable DimAso to 0) and removes the check mark from in front of Associative Dimensions in the menu. Recall that the comma separates expressions and values in a Diesel statement.!.dimaso)) (When you type this in. keep this in mind: A menu macros have two parts: (1) the label. To use Diesel code within a menu file. with or without the check mark.)/vAssociative Dimensions]'_dimaso $M=$(-. For example. you would see Associative Dimensions.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ .$(getvar. AutoCAD turns off associative dimensions (actually. In this case. The menu macro below shows how Autodesk programmers accomplished this: [$(if. you must prefix the code with the $M= code. don’t break the line. If the expression is true. and see just how complex Diesel can get. which is inside the square brackets (shown in cyan).dimaso) This is an embedded Diesel expression that gets the value of system variable DimAso.Diesel in Menus Let’s now see how to use Diesel in menu macros and AutoLISP routines. make sure you type it as one long line of text. symbol. then apply the next expression. which follows the square brackets (shown in black). (called a metacharacter) are interpreted by AutoCAD’s menu system to mean “display a check mark. Autodesk uses Diesel in the menu files it provides with AutoCAD to turn check marks on and off in the pull-down menus. $(if. This system variable has two possible values. click on the Associative Dimensions item in the Options menu. That’s the word(s) you see on pulldown menus.1.” 134 • v2.$(getvar.!. Turning the check mark on and off is tricky and requires the use of Diesel programming. bit by bit. which tests the following expression. [ The opening square bracket is the start of a macro label. and (2) the macro code. $(getvar.

(The stack is a simple form of memory known as FILO — first in. it is subtracted from 1.1. the SetVar command is optional. the Diesel if statement prevents the !. the value following (shown below). ) The final parenthesis ends the Diesel "if" expression. however. and it is further prefixed by the _ (underscore) to internationalize the command name.I hope you can see how the check mark is displayed by the above bit of Diesel code: the if statement uses the !. “Where the heck is all that going on?” It’s true that tailoring AutoCAD 2004 chapter 10 diesel expressions • 135 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . after the value of DimAso is gotten. Recall that the underlined character is the keyboard shortcut: you don’t need to pick Associative Dimensions with the mouse. Why here. It’s the DimAso system variable. metacharacter from being activated. In this case. That makes me want to ask.) $(-. This is the Diesel function that subtracts. Text in the macro area (following the square brackets) is treated as code. Recall that all system variables can be typed at the ‘Command:’ prompt like a command. In this case. and the $M= could have something to do with storing data on the stack. My guess is that AutoCAD treats the stuff inside the label section — [inside the square brackets] — as plain text input. it is subtracting from 1. last out — used by AutoCAD’s menu programming system to remember jumps between menus. ] The closing square parenthesis ends the label section of the menu macro. /vAssociative Dimensions The / metacharacter is how AutoCAD displays the underlined character in pull-down menus. When DimAso is false (equals 0). metacharacter to display the check mark whenever the value of DimAso is true. DimAso is prefixed by the ' (apostrophe) to make it a command transparent. $(getvar. What follows is the actual menu macro: '_dimaso This is the only part of the menu macro that looks recognizable to me. the v in the word Associative is underlined. you can press the letter v if you are so inclined. and not earlier inside the label? I dunno.dimaso) Embedded inside the subtract function is Diesel’s GetVar function again. then stored back into DimAso. $M= The $M= combination of characters is a special code to alert AutoCAD that a Diesel function is coming. This time.

gridmode)) The macro is one long line. I don’t know if there is a preference for either among the programming community. dimaso ). For example. Keep Replace with system variable name. ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ 136 • v2. Via the setvar Function The setvar function is used in conjunction with the ModeMacro system variable.$(getvar. Keep. dimaso )) . the change in the value of DimAso happens sort of automatically. TileMode. as follows: DimAso 1 (default) 0 Action of Macro 1-(DimAso) 1-(DimAso) New Value of Macro 0 1 ) Finally. same as above. To show how this works. The same trick is used here. Ortho. You’ll recall from the earlier tutorial that the ModeMacro system variable is used to execute Diesel from the ‘Command:’ prompt.)/GGrid Markings]'_gridmode $m=$(. Replace with system variable name. simply replace the parts shown in boldface: [$(if. The effect of the code is to toggles the value of the DimAso variable.$(getvar. . . I am accessing Diesel in an indirect manner.1.1 11 nov 2003 . Reusing Toggle Code Does your head hurt yet? The happy ending to this mind-numbing exercise is that you can reuse the code for all kinds of toggle situations.$(getvar. in either case. the macro ends with the closing parenthesis. Snap. SplFrame . simply go though the list of system variables: any one with a value of just 0 or 1 is a toggle.1. here is the code reused for toggling the display of the grid: [$(if. I'll write an AutoLISP routine to displays the fillet radius on the status line — using Diesel (shown in boldface).$(getvar. There are many toggle-type commands in AutoCAD. don’t split it into two lines in your menu file! Diesel in AutoLISP There are two ways to use Diesel expressions inside an AutoLISP routine: (1) with the SetVar function. (defun frad () (setvar "modemacro" "Current fillet radius: $(getvar. . . Keep.. Keep. ... . Replace with appropriate shortcut key and label name.!. In fact.filletrad)") ) The FilletRad system variable stores the current setting for the filleting radius.gridmode). .!. Replace with appropriate system variable name. .)/ vAssociative Dimensions ]'_ dimaso $M=$(-. I can think of Grid.there is no equivalent $(setvar function in Diesel. same as above. To reuse the code for other toggles. Keep this code. and (2) the MenuCmd function.

Concatenate Two Diesel Strings To display more than one piece of information on the status line. The following AutoLISP code displays the two chamfer distances at the status line: (defun chab () (setvar "modemacro" (strcat "Chamfer A: $(getvar. I use the StrCat function to concatenate the two Diesel strings to the ModeMacro system variable in one piece. along with the M= construct.filletrad)") ) The M= should be familiar from the earlier discussion of using Diesel inside of menu macros. tailoring AutoCAD 2004 chapter 10 diesel expressions • 137 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ .chamfera)" "Chamfer B: $(getvar. as follows: (defun chab () (menucmd "M=Current fillet radius: $(getvar.chamferb)") ) ) Via the MenuCmd Function The second method for using Diesel in AutoLISP functions uses the MenuCmd function.

visit the eBooks. Ltd.com for payment on additional copies. does not give you permission to make electronic or print copies. Send your email to editor@upfrontezine. Ltd.onLine Web site at www.com.upfrontezine. As the owner of the copyright.upfrontezine.eZine Publishing. For more of our technical e-books.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ .com/ebooks.eZine Publishing. Visit the Tailoring AutoCAD 2004 e-book Web site at www.com/tailor2004. You may not claim authorship or ownership of the text or figures herein. Copyright © 2004 by upFront. 138 • v2.Copyright Information This book is covered by copyright. upFront. Feedback I welcome your feedback for correcting and improving the text. Contact editor@upfrontezine. All rights reserved worldwide.

we look at the most powerful way for a non-programmer to customize AutoCAD. In this chapter.eleven autolisp programming tailoring autocad 2004 w hile toolbar and menu macros are easy to create. tailoring AutoCAD 2004 chapter 11 autolisp programming • 139 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . they limit your ability to control AutoCAD.

the code was yanked in the last days before ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ 140 • v2.1 11 nov 2003 . to generating a new user interface for AutoCAD. and adapted it for AutoCAD. Look for file names ending in . For this reason. (AutoCAD 2000 switched to another programming interface. This was not an issue for short routines. Early uses of Variables and Expressions included gimmick routines like repeatedly zooming into a drawing. v2. only third-party developers were told about the new feature. then called “Variables and Expressions. Third-party developers could now write powerful routines that manipulated the entire drawing. a search of the AutoCAD 2004 folders finds 85 LISP files!) The most important aspect of AutoLISP. I show you how to integrate AutoLISP code into toolbar macros and script files.” Finally. which compiled LISP code to run faster.5. With AutoCAD v2. Regular users found AutoLISP simple for writing short routines that helped automate their everyday drafting activities. called ADS (AutoCAD development system). Autodesk wrote most of the new commands in ObjectARX. Autodesk got serious: they renamed the programming language AutoLISP.arx as examples of ObjectARX program and commands — I found 107 of them in AutoCAD 2004. AutoCAD has had a full-fledged programming language embedded in itself: AutoLISP. Later. Even though Autodesk had AutoLISP in the beta version of LT Release 1.18 the new programming language was documented by Autodesk.The History of AutoLISP For 20 years now. lacking even conditional statements. called ObjectARX.17. was the AutoLISP was interpreted. The primary advantage to using ObjectARx is speed: these programs run compute-intensive code as much as 100 times faster than AutoLISP. Autodesk introduced with AutoCAD Release 10 for OS/2 a new programming environment. With the next release of AutoCAD. is that you can toss off a few lines of code to help automate your work. however. and added the GETxxx and SSxxx routines that provided direct access to objects in the database. but did affect large programs. I’ll show you how to write simple AutoLISP code that makes your AutoCAD drafting day easier. (AutoCAD LT users are out of luck: AutoLISP is not available to you. The AutoLISP Programming Language AutoLISP lets you do anything from adding together two numbers — in the middle of a command — to drawing parametrically a staircase in 3D. Still. which allowed programmers to hook C-language routines into AutoCAD. The drawback.15 during the summer of 1985. In this chapter’s tutorials. AutoLISP has the ability to manipulate data in the drawing database. Autodesk purchased Visual LISP from Bitwise Solutions. in my opinion. AutoLISP lets you create programs that manipulate nearly every aspect of AutoCAD and the drawing. AutoCAD’s most powerful programming facility— known as ObjectARx (AutoCAD Runtime eXtension) — is merely an interface: you have to buy additional the programming tools (read: $$$) and have an in-depth knowledge of advanced programming methodology. many new commands (such as 3dArray and Edge) and Express Tools are actually AutoLISP programs. In fact. At no extra cost to you. in v2. In contrast. to provide new commands. which meant that it ran slowly. Programmers at Autodesk had taken XLISP. The first versions of AutoLISP were very weak. To solve the problem. Also. AutoLISP first appeared as an undocumented feature in AutoCAD v2. a public domain version of LISP written by David Betz.

AutoCAD reacts unfavorably to each space character you type: Command: + (Press Unknown command Command: 9 (Press Unknown command Command: 7 (Press Unknown command Command: Spacebar. 3.) 16 Command: AutoCAD instantly replies with the answer. When you try to use AutoLISP. Think of it in terms of “add 9 and 7. (. Parentheses surround every AutoLISP statement. Start with something easy. any version from v2. on the keyboard: Command: (+ 9 7) (Press Enter. type the boldface text.) 1> AutoCAD displays the 1> prompt to tell you that one closing parenthesis is missing. Here’s what happens when you leave out the closing parentheses: Command: (+ 9 7 (Press Enter. Start AutoCAD. Spacebar. LT responds: “AutoLISP command not available. ). 2. (LT users can read along. and division. 9 and 7. multiplication. shown below. 6. Indeed. let’s dive right into using AutoLISP.”) Simple AutoLISP: Adding Two Numbers With that bit of background. 1. Try each of the other three. just in case AutoLISP ever shows up again!) There is no need to open a drawing. something everyone knows about: add together two numbers.) "+". Type ? for list of commands. Type the missing ) and AutoCAD is satisfied: 1> ) 16 Command: 5.18 through to today’s most recent version. like 9 plus 7. When the ‘Command:’ prompt appears. requires a closing parenthesis. getting to that answer through (+ 9 7) may seem convoluted to you. Spacebar.) "+". 16.” This is similar to how AutoCAD itself works: type in the command name first (such as Circle).” Every opening parenthesis. That’s because AutoLISP uses prefix notation: the operator. Type ? for list of commands.) "+". and then enter the coordinates of the circle. The parentheses serve a second purpose by alerting AutoCAD that you are using AutoLISP. first subtraction: Command: (. appears before the operands. However. LISP is sometimes said to be short for “lost in stupid parentheses. subtraction. I’ll tell you right now that balancing parentheses is the most frustrating aspect to AutoLISP. As you probably suspect.9 7) 2 Command: tailoring AutoCAD 2004 chapter 11 autolisp programming • 141 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . 4.the software began shipping because dealers were worried the cheaper LT would be too powerful and eat into sales of the more expensive AutoCAD. AutoLISP provides all the basic arithmetic functions: addition. When you start to enter the same AutoLISP function ‘+ 7 9’ without parentheses. +. Type ? for list of commands.

that’s not correct! Dividing 9 by 7 is 1.28571 Command: And AutoLISP returns the answer correct to five decimal places.) Number of rows (---) <1>: (Press Enter. This calculator pays its way when you employ AutoLISP to perform calculations within a command. This converts integers to real numbers and forces AutoLISP to perform real. as follows: Command: -array Select objects: L 1 found Select objects: (Press Enter. 142 • v2.) Diameter/<Radius>: d 2.) Number of columns (|||) <1>: 7 Distance between columns (|||): (/ 9.0 7.7. 9.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . add a decimal suffix.(* (/ 9. although this was not apparent until you performed a division. AutoLISP in Commands Okay. Now go on to the -Array command. enter the AutoLISP equation.28571 inches. not 1. you use AutoLISP to specify the array spacing.0) Once again.0) 1. Instead of typing the value for the diameter.250 four-function calculator. as follows: Command: circle 3P/2P/TTR/<Center point>: (Pick a point. Multiplication is done using the familiar * (asterisk) symbol. For example.28571. To work with real numbers. as follows: Diameter: (/ 9. you need to draw a linear array of seven circles to fit in a 9" space. What happened? Up until now. and draw the other six circles.0 7. so you’ve learned how AutoCAD works as a $3.number division. Start the Circle command. AutoLISP has been returning the result as an integer number. 1. Finally. division is performed with the / (slash) symbol: Command: (/ 9 7) 1 Command: Oops. as follows: Command: (/ 9.14286 Command: Note how the parentheses aid in separating the nesting of the terms.0 7) Command: AutoCAD draws a circle with a diameter of 1. which happens to equal the circle diameter.0) 4) 3) 2) 4. let’s see how AutoLISP lets you nest calculations: Command: (+ (. For that reason. Finally. as follows: Command: (* 9 7) 63 Command: 8. you have been working with integer numbers (also known as whole numbers).) Rectangular or Polar array (R/P): (Press Enter.0 7. 3. You can use an appropriate AutoLISP function anytime AutoCAD expects user input.

T. as follows: Command: (setq x (/ 9. You can make up any combination of characters to create variable names. this time using variable Dia. Redo the Circle and -Array commands. such as x. in case you’ve forgotten or are wondering what happened during the calculation. This curiously named function is short for SET eQual to. which are lacking from AutoLISP roster of functions.28571 Command: 4. 3. Its primary benefit is that it includes advanced vector functions.) Rectangular or Polar array (R/P): (Press Enter. You make one variable equal another. Diameter.28571 Command: The ! prefix (sometimes called “bang”) is useful for reminding yourself of the value contained by a variable. you employ the most common AutoLISP function known as SetQ. and GetInt. AutoLISP isn’t limited to just one variable. But you also want to balance a descriptive name. In fact. To prove to yourself that x contains the value of 1. The x is known as a variable because it can have any value. Notice the extra set of parentheses. you probably recall equations like ‘x = 7 + 9’ and ‘x = 7 / 9’. use AutoCAD’s ! (exclamation) prefix. AutoLISP can be made to remember the results of all your calculations. use the SetQ function together with a variable.TIP An alternative to using AutoLISP for mid-command calculations is the ’Cal command. 2. such as the circle diameter calculated above. as follows: Command: (setq dia x) 1.) Diameter/<Radius>: !dia Command: -array Select objects: L 1 found Select objects: (Press Enter. A good compromise for our example is Dia.28571 Command: From algebra class. as follows: Command: !x 1. 1. it is good to create variable names that reflect the content. To save the result of a calculation. Remembering the Result: SetQ In the above example. as follows: Command: circle 3P/2P/TTR/<Center point>: (Pick a point.0 7) equation twice: once in the Circle command and again in the -Array command. you used the (/ 9. such as SetQ.0) calculation. x remembers the result of the (/ 9. such as Pt1.28571 Command: !dia 1. Just like the M-key on a calculator lets it remember the result of your calculation.28571. To do this.0 7)) 1.0 7.) tailoring AutoCAD 2004 chapter 11 autolisp programming • 143 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . The only limitation is that you cannot use AutoLISP function names.) Number of rows (---) <1>: (Press Enter. such as Diameter with minimized typing. In this case. and Yvalue.

0) pi)) 0. PI is the only constant predefined by AutoLISP and is equal to 3. By the way.14159 AutoLISP displays the results to six decimal places. Remember from the last tutorial that either the 45 or the 180 needs the decimal ( .0 ) to force division of real numbers. one type of function missing is matrix manipulation.3) radians in 360 degrees. logarithmic. you can refer to variable MinNbr. you must first convert the degrees to radians. rather than integers. you get a taste of the many different kinds of functions AutoLISP offers you for manipulating numbers and words. AutoLISP Functions Autodesk made AutoLISP so powerful that it can manipulate almost any aspect of the AutoCAD drawing.1415926 each time you need the value of pi in a function. not degrees. even though it performs calculations to 32-bit accuracy. to get the sine of 45 degrees. For example.Number of columns (|||) <1>: 7 Distance between columns (|||): !dia AutoCAD precisely draws the same seven circles. Here’s an example of a trig function. because if you are working with degrees. the Min function returns the smallest (minimum) of a list of numbers: Command: (min 7 3 5 11) 3 To remember the result of this function.707107 Here I divided the degrees (45) by 180. AutoLISP has many of the mathematical functions you might expect in a programming language. then multiplied by pi. Recall that there are 2*pi (approximately 6. you have to indulge in some fancy footwork. as follows: Command: (setq minnbr (min 7 3 5 11)) 3 Now each time you want to refer to the minimum value of that series of numbers. instead of 3. As we start on our whirlwind tour of five groups of functions. first: Command: (sin (* (/ 45 180. so long as you code it correctly. and bit manipulation functions. use the exclamation mark at the command prompt: Command !pi 3. 144 • v2. use the SetQ function. Fortunately.1415926. This is an inconvenience. To see this for yourself. That means you just type PI. In this tutorial. sine: Command: (sin minnbr) 0. TIP You must provide the angle in radians (such as for MinNbr).14112 Returns the sine of the angle of 3 radians. logical. AutoLISP can do this for you. Math Functions In addition to the four basic arithmetic functions you learned to use. For example. start AutoCAD and type the examples in the text screen at the ‘Command:’ prompt.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . The list includes trigonometric.

equal.Geometric Functions Since CAD deals with geometry. That tells AutoLISP you are creating a pair (or triple) of coordinates.7).z.7) Command: (setq p2 '(7. TIPS Don’t use commas! Use spaces to separate the values of the coordinates.z-coordinates. The toolbar macros have no conditionals. They check if something is true. Conditional Functions You could say that conditional functions are the most important. Other geometric functions of interest include the angle from 0 degrees (usually pointing east) to the line defined by P1 and P2: Command: (angle p1 p2) 5.72309 It returns the 3D distance between two points.1 11) Command: (distance p1 p2) 6. they are not a true programming language.0. as in: '(1.3 5. It is conditionals that allow a computer program to “think” and make decisions.coordinates that result from applying an object snap mode to a point. in this function. Thus. they repeat an action until something is false.y.5) where the "mid" refers to the midpoint object snap mode. you are finding the midpoint of the line that starts at P1 (1. The intersection of two lines is determined by Inters: Command: (inters pt1 pt2 pt3 pt4) The x.5 3.1 11)) (7.4 5. check for conditionals. If you’re not sure if it’s a programming language or merely a macro language. Conditional functions check if one value is less than.4 4. returns a 3D point of a specified distance and angle.5 3.7)) (1.y. tailoring AutoCAD 2004 chapter 11 autolisp programming • 145 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . When you leave out the z-coordinate. 5. The other geometric functions are Textbox (find the rectangular outline of a line of text) and Polar.3 5. or greater than another value.3 5. the Distance function is just like the Dist command: Command: (setq p1 '(1.88611 The result is returned in radians. For example. AutoLISP assumes it equals 0.) Command: (osnap p1 "mid") (4.7). since they define the existence of a programming language. You may have missed that single quote mark in front of the list of x. The object has to actually exist: Command: line From point: !p1 To point: !p2 To point: (Press Enter. AutoLISP has a number of functions for dealing with geometrics.3. and that it shouldn’t try to evaluate the numbers.

3711 degrees. however. That tells AutoLISP you are working with a string. For example: Command: (setq autocad "A software package") "A software package" Command: (setq world "The planet earth") "The planet earth" Command: (strlen autocad world) 34 Other string functions change all characters to upper or lower case.For example. Notice how “AutoCAD World” is surrounded by quote marks.796214 Here we’ve supplied Angtof with the angle in degrees-minutes-seconds format. That’s so it doesn't get confused with the closing quote mark (") that indicates the end of the string. like 45.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . Related to string functions are the conversion functions because some of them convert to and from strings. It converts an angle string to a real number radians: Command: (angtof "45d37'11\"" 1) 0. so we tell it by means of the mode 146 • v2. such as 13 “steps drawn” by mixing text and variables. returns part of a string. Then use 14 steps. if the floor-to-ceiling distance is greater than eight feet. Notice how the seconds indicator (") is handled: \". For example. then draw 14 steps. which AutoCAD represents as 45d37'11"? That’s where a conversion function like Angtof (short for ANGle TO Floating-point) comes in. But how do you convert 45 degrees. If String and Conversion Functions You can manipulate strings (one or more characters) in AutoLISP but to a lesser extent than numbers. If you type (strlen AutoCAD World). smart enough to know that. else. not a variable. For example. earlier we showed how to convert 45 degrees to radians. AutoLISP isn’t. A similar wording is used in condition functions: Command: (if (> height 96) (setq steps 14) (setq steps 13)) 13 Let's break this down to see how the function compares with our statement: (if (> height 96) (setq sets 14) ) (setq steps 13) greater than floor-to-ceiling distance 8 feet. 37 minutes and 11 seconds. That’s fine for decimal degrees. draw 13 steps. AutoLISP tries to find the length of the strings held by variables Autocad and World. Else use 13 steps. as follows: Command: (strcat autocad " used all over " world) "A software package used all over The planet earth" That’s how you create reports. you can find the length of a string as follows: Command: (strlen "AutoCAD World") 13 The StrLen (short for STRing LENgth) function tells you that “AutoCAD World” has 13 characters in it. finds a pattern in a string. counting the space. and join two strings together.

that’s just AutoLISP’s way to letting you know it is finished with its work.3964 N 45d37'11" E Notice the similarity between the mode numbers and the values of system variable AUnits. Let’s see how the Command function works by drawing a circle. Anything you type at the ‘Command:’ prompt is available with the Command function.5 Command: nil (Don’t worry about that ‘nil’ at the end. Command executes AutoCAD commands from within AutoLISP.) Let’s look at one of the more complex commands to use with the Command function. First. After you type that in. and translates (i. place text. AutoCAD responds by drawing the circle: circle 3P/2P/TTR/<Center point>: 2. an integer number into a string. the AutoLISP function that gets the value of a system variable. which holds the state of angular display as set by the Units command. 1 in this case. whatever. though.1234 0. Later in this chapter.” yet one of AutoLISP’s most powerful functions is its simplest to understand: the Command function.e. you mimic what you type at the ‘Command:’ prompt like this: Command: (command "circle" "2. Other conversion functions convert one unit of measurement into another (via the Cvunit function and the acad. let’s recall how the Circle command works: Command: circle 3P/2P/TTR/<Center point>: 2.2" "D" "1. Think about it: this means that it is trivial to get AutoLISP to draw a circle. letter A into ASCII 65).number. As its name suggests.5") Notice how all the typed text is in quotation marks. as follows: Command: (angtof "45d37'11\"" (getvar "aunits")) 0. a character into its ASCII value (for example.unt file). The coincidence is not accident. tailoring AutoCAD 2004 chapter 11 autolisp programming • 147 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . moves) a point from one coordinate system to another.2 Diameter: D Diameter: 1. zoom a viewport. When you don’t know ahead of time the current setting of units. you make use of this fact by specifying the mode number as a variable.2 Diameter: D Diameter: 1.3711 45d 37' 11" 100. External Command Functions “Powerful” often equates to “complicated. This (and some other functions) use the following as mode numbers: Mode 0 1 2 3 4 Meaning Decimal degrees Degrees-minutes-seconds Grad Radian Surveyor units Example 45.5 In the Command function.796214 Here we use GetVar (short for GET VARiable). We used Getvar to get AUnits. you learn how to prevent nil from appearing.

’ I place the emphasis on the word type. Earlier. such as the Line command: Command: (command "line" "1.2" "3. By now it should be clear to you that you have to really know the prompt sequence of AutoCAD’s more than 300 commands to work effectively with the Command function. For example.2000>: 1. You use the same thing for commands that automatically repeat themselves.5 Rotation angle <0>: Text: Tailoring AutoCAD Command: nil and draws the text. as we see in a minute. while SetVar changes (sets) the value. and the range of permissible values. the value of SplFrame is 0: the frame is not displayed.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . That’s right: any command that uses a dialog box won’t work with the Command function — nor. this becomes: Command: (command "text" "5. AutoCAD presents these prompts: Command: text Justify/Style: 5. check that the quick reference book has a listing of all system variables. For the ‘Rotation angle:’ prompt. their default value. “Anything you type at the ‘Command:’ prompt is available with the Command function. Notice how that was dealt with in the AutoLISP function: "" — a pair of empty quotation marks.10" "1. then you leave AutoCAD hanging with a ‘To point:’ prompt and your AutoLISP routine fails.10 Height <0. But the Command function has a failing. by default. AutoLISP has a pair of more direct functions: GetVar and SetVar. When we use the Text command.10 Height <0. And. along with the complete prompt sequence.2000>: 1. I said. It is for this reason that AutoCAD includes command line versions of almost every (but not all) command.) Text: Tailoring AutoCAD Converted to AutoLISP-ese.5 Rotation angle <0>: (Press Enter. as confirmed by GetVar: Command: (getvar "splframe") 0 To display the frame.Text. we simply pressed the ENTER key.4" "") When you don’t include that final "". change the value of SplFrame to 1 with SetVar as follows: Command: (setvar "splframe" 1) 1 148 • v2. GetVar gets the value of a system variable.5" "" "Tailoring AutoCAD") And AutoCAD responds with: text Justify/Style: 5. for that matter. system variable SplFrame determines whether the frame of a spline polyline is displayed. The easiest way to get a handle on those is to purchase one of the “quick reference” books on the market. The Command function breaks down completely when it comes to dialog boxes. Accessing System Variables While you could use the Command function to access system variables. with the toolbar macros we looked at a couple of chapters ago. which list commands in alphabetical order.

9825 0. that’s a workaround that lets GetString accept a string of text with spaces. That’s where the a group of functions known collectively as Getxxx come into play.We have made.0 Notice how GetReal converts the 2 (an integer) to a real number. however.y.0.523599. a crass assumption here: that the initial value of SplFrame is 0. y. text the user types in. Not only did we change the prompts that the user sees. How do we know what the value of SplFrame is before we change it? We'll answer that question later in this chapter.523598775598299 Text: Tailoring AutoCAD Command: nil There! We’ve just customized the Text command to our liking. When you leave out the T. Some of the more useful ones include: GetPoint GetAngle GetString GetReal Returns Returns Returns Returns the the the the x.0) Notice how GetPoint returns the x. but we change the order of the prompts. It is trickier working with objects that already exist. value of a real number typed in by the user. These get data from the screen. Finally.z-coordinates of a picked point. then executes the Text command: Command: (setq TxtStr (getstring T "What do you want to write? ")) What do you want to write? Tailoring AutoCAD "Tailoring AutoCAD" Notice that extra "T". then GetString only accepts text up to the first space: you would end up with just “Tailoring” and no “AutoCAD. Command: (setq TxtHt (getreal "How big do you want the letters? ")) How big do you want the letters? 2 2. we execute the Text command with the four variables: Command: (command "text" TxtIns TxtHt TxtAng TxtStr) text Justify/Style: Height <1. Command: (setq TxtIns (getpoint "Where do you want the text to start? ")) Where do you want the text to start? (27. such as the new circle and text we drew above with the Command function. GetXXX Functions It’s one thing to execute a command to draw a new object. such as moving that circle and editing the text. even though z is zero. Zero is the default value but not necessarily the value at the time that you run the AutoLISP routine. tailoring AutoCAD 2004 chapter 11 autolisp programming • 149 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . Stay tuned.5000>: 2. Command: (setq TxtAng (getangle "Tilt the text by how much? ")) Tilt the text by how much? 30 0.” The SetQ function stores the phrase “Tailoring AutoCAD” in the variable TxtStr. 0. Let’s redo the code so that AutoLISP prompts us for everything first.523599 Notice how GetAngle converts the 30 (a decimal degree) into radians. Here’s how to use some of these with the Text command from above. and z values of the coordinate.000000000000000 Rotation angle <0>: 0.8068 4. angle in radians. 2.

AutoLISP has a group of functions for creating a selection set. which is powerful but simple. Reports the number of objects in the selection set. For example. These all begin with SS. text styles. Unlike the Command function. 150 • v2. and other named objects in the drawing. the AutoLISP SSxxx commands can work with up to 128 different selection sets. You can see that to work with these object manipulating functions.Selection Set Functions To work with more than one object at a time. Another five functions are for memory management. known as “dotted pairs. RightOfWay" Once again. whose use is so rarified that Autodesk recommends never using them. as in: SsAdd SsDel SsLength SsMemb Adds an object to the selection set. Another set of AutoLISP functions — 21 of ’em — are strictly for loading and displaying dialog boxes. Gets the data that describes an object in the drawing. Deletes an object from the selection set. The “symbol table” refers to the part of the drawing database that stores the names of layers. Here’s a summary of what some of these are: EntMake EntGet EntMod EntDel TblObjName Creates a new object. Checks if an object is part of the selection set. Gets the name of an object in a symbol table. AutoCAD’s Select command can only deal with one selection set at a time. and RightOfWay is the name of the layer. you employ the following format: "2 . Object Manipulation Functions The really powerful AutoLISP functions are the ones that go right in and manipulate the drawing database. the quotation marks indicate the start and end of the data. Erases an object from the database. These functions are not hard to spot: they all start with “Ase_”.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . to work with a layer named RightOfWay. while the dot in the middle separates the two values: 2 is the DXF code for layer names. as in Ase_LsUnite and Ase_DoCmp. these AutoLISP functions work with a variant on the DXF format. the object manipulation functions are powerful and complicated.” For example. Autodesk has written 41 AutoLISP functions for controlling the ASE (AutoCAD Structured query language Extension) link between objects in the AutoCAD drawing and records in an external database file. Changes the object. To create and manipulate objects. Advanced AutoLISP Functions There is a whole host of AutoLISP functions that you may never use in your AutoCAD programming career. the old name for AutoCAD objects. such as Load_Dialogue and New_Dialogue. you need a good grasp of the DXF format. The Ent prefix is short for entity.

probably by picking a point.5907 Z = 0. sometimes.z. it’s like being in school all over again. Obtain the coordinates from the drawing. as in (getpoint "Pick a point: ") tailoring AutoCAD 2004 chapter 11 autolisp programming • 151 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . next to the pick point? That would let you label x.y. The Plan of Attack Before you write any AutoLISP code.coordinates of the point. The nice thing about AutoLISP is that you can program it on the fly. like this: Command: id Point:(Pick a point. you learn the first steps in writing an AutoLISP routine of your own. We’ve just recognized the two parts to solving the problem: Part 1.9227 Y = 6. Learning some AutoLISP programming now means you’ll feel really good whipping off a few lines of code and letting AutoLISP perform a tedious task for you. Problem is. When you pick a point on the screen. Sitting in the classroom seems like a waste of time. you are so busy creating drawings that you have no time to learn how to program.y-coordinates and z-elevations easily all over a site plan.z. Why Write a Program? If you are like many CAD users. Id reports the value in the command prompt area. as in (command "ID").Writing a Simple AutoLISP Program In this part of the chapter. • Use the LastPoint system variable with the GetVar function. Obtaining the Coordinates AutoLISP provides several ways to get the coordinates of a picked point.coordinates off the command prompt area and into the drawing.y.) X = 8. Part 2. we find we could: • Use the Id command with the Command function. But the things you learn now make life easier later. • Use the GetPoint function. it tells you the 3D x. Place the coordinates as text in the drawing. No doubt. you can. you need to figure out how you’re going to get those x. With AutoLISP. Browsing through the Customization Guide. as in (getvar "lastpoint"). And you can use it for really simple but tedious tasks. “Why bother learning a programming language?” In some ways. you may be wondering.0000 Wouldn’t it be great if you could change Id to place the coordinates in the drawing. Here’s the example we’ll use for this tutorial: The Id Command AutoCAD has the Id command.

Type the following to see that it works exactly the same: Command: (setq xyz (getpoint "Point: ")) Point: (Pick a point. 2.0000 That’s great! You’ve typed in a tiny AutoLISP routine.) (8.) X = 8.0000) As before. Type at the ‘Command:’ prompt: Command: (setq xyz (getvar "LastPoint")) (8. In this case. and then see what happens. AutoCAD returns the value it has stored in variable Xyz: (8.1 11 nov 2003 . y. The "Point: " is called a prompt and tells the user what the program is expecting the user to do. you make mistakes.9227 Y = 6. Just like before. 4. which are the x. After typing the AutoLISP function. y.zcoordinates of the last-picked point in system variable LastPoint.5907 z = 0.0000). GetPoint. We did mention a third AutoLISP function we could use. This time use an object snap to snap to a geometric feature.It would be a useful lesson to use each of the three.9227 6.5907 Z = 0. respectively: x = 8. The GetPoint function waits for you to pick a point on the screen. By experimenting. 3.0000 AutoCAD always stores these values in the order of x. Before we can place the coordinates as text in the drawing.y. like the end of a line: Point: end of (Pick a point. The AutoCAD command is in quotation marks "ID" because the command is a string (programmer talk for “text”). Recall from earlier tutorials that the SetQ function lets us store a value in a variable. once again. AutoCAD prompts you for the point. load a drawing. And "LastPoint" is the name of the system variable.5907 0.5907 0. it is surrounded by quotation marks because it is a string. then learn from the mistakes. and z-coordinates.9227 y = 6.0000) Xyz is the name of the variable we are using to store the x. Programmers prefer GetPoint because it is more efficient than the Id-LastPoint combo we used above. Now.5907 0.coordinate first or the x-coordinate last. and switch to the Text window with F2. GetVar is the name of the AutoLISP that retrieves the value stored in a system variable. So. 1. The spaces separate the numbers. we have to store the coordinates in a variable.9227 6. we use the SetQ function to store the value of the coordinates in variable Xyz. You will never find the z.9227 6. At the ‘Command:’ prompt. AutoCAD stores the x. type: Command: (command "ID") You are executing an AutoCAD command from within an AutoLISP routine.z-coordinates.y. Start AutoCAD. and z. The Command function lets you use any AutoCAD command in AutoLISP. Note how the coordinates are surrounded by parenthesis. This is called a list and is the list format that LISP is famous for (LISP is short for “list processing”). we’ve now solved the first problem in one manner. We obtained the coordinates off the drawing and stored them in a variable. we mimicked the prompt of the ID command. Let’s make use of this now. ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ 152 • v2.

With the x. The Text command is trickier than the Id command. xyz — we’re lucky: the Text command accepts numbers stored in variables as text.) (8. It has four prompts that your AutoLISP routine must answer: • • • • Start point: a pair of numbers. like: Command: (setq xyz (getpoint "Press the mouse button: ")) Press the mouse button: (Pick a point.z-coordinates. But we could just as easily have written anything. there is just one solution: the command function in conjunction with the Text command.0>: 200 Rotation angle <0>: 0 Text: 2958. xyz variable stores the starting point for the text.) (8.5907 0. and the user puzzled at why nothing is happening. Change this number to something convenient for your drawings. A lack of communication.z-coordinates safely stored in a variable. 0 is the rotation angle of the text.9227 6. Let's try this out at the ‘Command:’ prompt: Command: (command "text" xyz 200 0 xyz) text Justify/Style/<Start point>: Height <1. Height: a number that makes the text legible. but we are placing one line of text.y. you might say. and the Text command is excellent for that.5907 0.348773815669. Or. I suppose the MText command might work. This is where I find a quick reference book handy that lists all the options of every AutoCAD command. the x.821183398367 tailoring AutoCAD 2004 chapter 11 autolisp programming • 153 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . probably 0. Rotation angle: a number.. We’ve now seen several approaches that solve the first problem in several different ways.0000) 6. "text" is the AutoCAD Text command being executed.0000) That’s right.5740.. as follows: Command: (setq xyz (getpoint)) (Pick a point.y-coordinates. That’s why prompts are important. Let’s see if we can now construct the AutoLISP function for placing the coordinates as text: (command is the Command function. ) and remember: one closing parenthesis for every opening parenthesis.y. No prompt. Text: a string. 200 is the height of the text.5. Just a silent AutoCAD waiting patiently for the right thing to happen .9227 6. let’s tackle the second problem Placing the Text To place text in the drawing. we could have no prompt at all. x.

Writing a Simple AutoLISP Program. Click the right mouse button. AutoCAD displays the cursor menu. not quite. Highlight the text: Press the mouse button and drag the cursor over the "X = 8.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . Select Copy from the cursor menu. A quick reminder on how to use it: 154 • v2. 3. In the next part of this chapter. then placing the coordinates as text. An Alternative to LISP Programming Just because this tutorial is about AutoLISP doesn’t mean that it is always the best approach. Well.9227 Y = 6.lsp file on disk. you find out how to save the code to a . Use the Id command and pick a point: Command: id Point: (Pick a point. the program labels the point with its x. 7. including suppressing that "nil" that gets output at the end of the routine. 4.z-coordinates. inserting the responses for its prompts. AutoCAD copies the coordinate text to the Windows clipboard. Switch to the text screen by pressing function key F2. 6.5907 Z = 0. You can use the Move command to shift the text into position. Cont’d In the last tutorial. you learned the first steps in writing an AutoLISP routine of our own. Press CTRL+V.0000" coordinates. Putting Them Together Let’s put together the two solutions to our problem: (setq xyz (getpoint "Pick point: ")) (command "text" xyz 200 0 xyz) There we have it: a full-fledged AutoLISP program.Command: nil AutoCAD runs through the Text command.9227 Y = 6. Here’s a wacky work-around to labeling points that uses no programming at all: 1. 5. It’s a pain to retype those two lines each time you want to label a point. Press F2 to switch back to AutoCAD drawing window.5907 Z = 0.) X = 8. AutoCAD always pastes stuff in the upper-left corner of the drawing screen.y.0000 2. We’ll also dress up the code. We’ve solved the second part of the problem. You created a two-line AutoLISP program that looks like this: (setq xyz (getpoint "Pick point: ")) (command "text" xyz 200 0 xyz) When you pick a point on the screen. AutoCAD pastes the text into the drawing using the current text style.

text size.y.. Sprucing Up the Code There we have it: a full-fledged AutoLISP program. Well. then you know how quickly a simple program fills up with feature-bloat. Grabowski. and quote marks are important.z-coordinates are printed to eight decimal places. tailoring AutoCAD 2004 chapter 11 autolisp programming • 155 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . All those spaces. When AutoCAD prompts. “Pick point: “. While all those added features sound desirable. they may make the program less desirable. you may not realize how a user interface adds a tremendous amount of code. and show how to add them in. and if we use this AutoLISP program a lot. Go right ahead. Can you image how irritated you’d get if you had to answer the questions about decimal places.. not quite. Conquering Feature Bloat “Okay. for most users. filename — each time you want to label a single point? Take a second look at the wishlist to check off what is important.y.y. Type the AutoLISP code in at the ‘Command:’ prompt exactly as shown. “I can agree that these are all desirable improvements. What we have is the algorithm — the core of every computer program that performs the actual work.. and we need to save it on disk so that we don’t need to retype the code with each new AutoCAD session. You may need to zoom window or extents to see the text.. text font. There are many user interface problems with our little program. “Pick point: ”. you would like some control over the size and orientation of the text. and cross off what you could live without.. • .” But.. layer name. • The x. • You may want a specific text style.z-coordinates to a file on disk — just in case you ever want to reuse the data. • Here’s an orthogonal idea: store the x. If you are familiar with programming. pick a point on the drawing: Pick point: (Pick a point. Mr. upper and lower case characters are not important.. • Certainly.1. text orientation.z-coordinates at the point you picked.” you may be thinking. parentheses. How many can you think of? Here’s a list of problems I’ve come up with: • It’s a pain to retype those two lines each time you want to label a point — we need to give the program a name . • You may want to control the layer that the text is placed on. What is lacking is most of the user interface — the part that makes it easier for the user to employ the program. wait a minute! When you’re not familiar with AutoLISP. Notice that AutoCAD writes the x. which mean more bugs and more debugging.. that’s way too many. which. 2. All we have for a user interface is part of the first line that prompts. • . then we should have a way of having it load automatically.) 3.

and routine are used interchangeably. xyz is the name of the variable that is used strictly within the program. such as to identify subroutines you created. as follows: Command: label Pick point: (Pick a point. I decided to call this program Label. the indents make it easier to read code. piece by piece: (defun defines the name of the function. as follows: (defun c:label ( / xyz) (setq xyz (getpoint "Pick point: ")) (command "text" xyz 200 0 xyz) ) Let’s take a look at what’s been added. the names of input variables appear before the slash. they become global. 156 • v2. c:label is the name of the function.) TIP The c: prefix turns an AutoLISP function into an AutoCAD command. program. as follows: Command: (label) Pick point: (Pick a point. If variables are not declared local. In my example program. For this reason. In AutoLISP.Wishlist Item #1: Naming the Program To give the program a name. such as: (defun rhg:label) ( / xyz ) declares the names of input and local variables. otherwise-local variables are kept global until the program is debugged. An input variable is for feeding data to the AutoLISP routine. all you need do is type “label” at the ‘Command:’ prompt. making debugging harder. To run the Label program. the names of local variables appear after the slash. The benefit to declaring variables as local is that AutoCAD automatically frees up the memory used by the variable when the AutoLISP program ends. I could give it any name that does not conflict with the name of a built-in AutoLISP function or any other user-defined function. This is standard among programmers. The c: prefix make this AutoLISP routine appear like an AutoCAD command.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . the slash separates the two. You can use a pair of spaces or the tab key since AutoLISP doesn’t care. You can use other prefixes for your own purposes. the drawback is that the value is lost. The value of a global variable is accessed by any AutoLISP function loaded into AutoCAD. ) closing parenthesis balances the opening parenthesis at the beginning of the program. the terms function. I indented the code in the middle to make it stand out from the defun line and the closing parenthesis. A local variable is used only within the program. then you run the program like an AutoLISP function with the parentheses.) When the c: prefix is missing. surround all of the code with the (defun) function.

Wishlist Item #2: Saving the Program By saving the program to a file on disk. Here's how: tailoring AutoCAD 2004 chapter 11 autolisp programming • 157 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . When AutoCAD starts up.lsp in AutoCAD’s folder named \support.lsp and store it in the \support folder).z-coordinates are printed to eight decimal places — that’s too many. Wishlist #4: Using Car and Cdr The x.lsp file.lsp is easy. There are two solutions. as shown by the following code fragment: Command: (setq uprec (getint "Label precision: ")) Label precision: 1 1 Or steal the value stored in system variable LUPrec — the precision specified by the user via the Units command — under the (not necessarily true) assumption that the user want consistent units. and (3) join the coordinates together again.y. Save the file with the name label. type the following: Command: (load "label") If AutoCAD cannot find the AutoLISP program. To add label. (2) apply the precision factor. then you have to specify the path. Open the acad. Wishlist Item #3: Automatically Loading the Program To load the program into AutoCAD. Assuming you saved label. Add the name of the program: (load "label. you avoid retyping the code with each new AutoCAD session. which takes three steps: (1) pick apart the coordinate triplet.y. To do this: 1. then start a new file called acad.lsp file with a text editor (if the file does not exist. AutoCAD automatically loads the names of AutoLISP programs listed in the file. One is to ask the user the number of decimal places.) AutoCAD provides a way to automatically load AutoLISP programs. as follows: Command: label Pick point: (Pick a point. The tough part is applying the precision to the x.lsp in the folder \autocad 2004\support you would type: Command: (load "\\autocad 2004\\support\\label") Now use the point labelling routine. Start AutoCAD and it should automatically load label. Type the code shown: (defun c:label ( / xyz) (setq xyz (getpoint "Pick point: ")) (command "text" xyz 200 0 xyz) ) 3. it looks for a file called acad. 2.z-coordinates. Start a text editor (the NotePad supplied with Windows is good). The code to do this is as follows: (setq uprec (getvar "LUPREC")) That was the easy part.lsp") Save the acad.lsp.

14595 8. Store them in their own variables.” so that I can check its value at AutoCAD’'s ‘Command:’ prompt. here is the RtoS function at work: Command: (rtos ptx 2 uprec) "6. 2. and so on. LISP has several functions for picking apart a list. If you don’t see the coordinates printed on the screen.lsp.1.14595 7. the y-coordinate. as follows: Command: (cadr xyz) 8.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ .10049 5. It removes the first item from the list and gives you what’s left: Command: (cdr xyz) (8. we are using a form of LISP shorthand that allows us apply the SetQ function to several variables. You now have a way to extract the x-coordinate. depending on where you picked.coordinates. There are a couple of ways to do this. Your results will differ. PtY for the y-coordinate.14595 10. Recall the reason for AutoCAD’s 1> prompt: it reminds us that a closing parenthesis is missing. At the ‘Command:’ prompt. and (2) converts the real number into a string. Here we’ll use the car and cdr functions. Now that the three coordinates are separated. as follows: Command: (setq ptx (car xyz) 1> pty (cadr xyz) 1> ptz (caddr xyz) 1> ) Use PtX to store the x-coordinate. The code should look like this: (defun c:label ( ) (setq xyz (getpoint "Pick point: ")) (command "text" xyz 200 0 xyz) ) Save and load label. To extract the y-coordinate. Run label. In addition to car and cdr. 9.z. and the z-coordinate from variable XYZ. type the following: Command: !xyz (6. Remove / xyz from the code.0) 6.14595 10.lsp in NotePad or any other text editor. For now. and combinations thereof. but we’ll use the RtoS function because it does two things at once: (1) changes the number of decimal places to any number between 0 and 8. LISP allows me to combine the “a” and “d” in several ways to extract other items in the list. use caddr. 3.10049 8.0) The exclamation mark forces AutoCAD to print the value of variable XYZ. This makes the variable “global.1" 158 • v2. as follows: Command: (caddr xyz) 8. you can finally reduce the number of decimal places. picking any point on the screen. 4. The car function extracts the first item (the xcoordinate) in the list. use cadr. The cdr function is the compliment to car. In addition. use the Zoom Extents command. Try it now: Command: (car xyz) 6. Why? You'll see later. And to extract the z-coordinate. Open label. which holds the x.y.lsp into AutoCAD.

y. you now have to string (pardon the pun) them together with the StrCat function. like this: Command (setq xyz (strcat ptx ".0" That’s more like it. then. Reusing a variable name like this helps conserve memory. Since LISP can’t know when we want spaces. 13.The RtoS function uses three parameters: PtX 2 Name of the variable holding the real number. shown in boldface: (defun c:label ( / xyz xyz1 uprec ptx pty ptz) (setq uprec (getint "Label precision: ")) (setq xyz (getpoint "Pick point: ")) (setq ptx (car xyz) pty (cadr xyz) ptz (caddr xyz) ) (setq ptx (rtos ptx 2 uprec) pty (rtos pty 2 uprec) ptz (rtos ptz 2 uprec) ) (setq xyz1 (strcat ptx ".” Assuming. " pty ". 8. which defines five modes of units: Mode 1 2 3 4 5 UPrec Units Scientific Decimal Engineering Architectural Fractional Name of the variable holding the precision (the code for that is at the beginning of this section). For example. short for string concatenation. since it lets you create a string that contains text and variables. You have to insert them. 10. and z. a 2 for architectural means “quarter-inch. Add in the code we developed here. The number 2 is based on system variable LUnits.18.110.10049 to 6.1. 11. Try it now: Command: (strcat ptx pty ptz) "6. StrCat is one of the most useful LISP functions. " ptz)) "6. Truncate and preserve the values of x. " ptz)) (command "text" xyz 200 0 xyz1) ) tailoring AutoCAD 2004 chapter 11 autolisp programming • 159 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . a value of 2 for decimal means “two decimal places”. Back to the text editor.1. depending on the type of units. 10. " pty ". it doesn’t provide any. Type of conversion. as follows: Command: (setq ptx (rtos ptx 2 uprec) 1> pty (rtos pty 2 uprec) 1> ptz (rtos ptz 2 uprec) 1> ) Notice that you can set a variable equal to itself: the first PtX holds the new value of the x-coordinate after RtoS gets finished processing the second PtX.1. This varies. Oops! Not quite the look we was hoping for.0" 12. the RtoS function in the code fragment above reduces 6. decimal in this case. that the precision in UPrec is 1. With the coordinates truncated.

Run the routine: Command: label Label precision: 1 Pick point: (Pick a point. we add the ability to save data to a file and learn how to fight feature bloat.0000>: 200 Rotation angle <0>: 0 Text: 5012. and then load the AutoLISP routine into AutoCAD with: Command: (load "label") "C:LABEL" 16. .coordinates in a text file.y. you should add comments to the code to remind you what it does when you look at the code several months from now. 1996. (defun c:label ( / xyz xyz1 uprec ptx pty ptz) . In this tutorial. too.y.lsp.0 Command: nil Saving Data to a File In the last tutorial.z.) text Justify/Style/<Start point>: Height <200.3.2. so I use Xyz1 as the variable holding the text string. " pty ".Lsp labels a picked point with its x. 25 February. What started out as two lines of code has now bulged out into 23 lines of code. Finally. Place text: (command "text" xyz 200 0 xyz1) ) 15. the change to variable Xyz in the last couple of lines: I don’t want the text placed at the rounded-off coordinates. " ptz)) . but I would like to be able to save the data collected on the x.1 11 nov 2003 .” Saving the data to file is easily done with the (open "a"). Label. Recombine individual values into a 3D point: (setq xyz1 (strcat ptx ". Ask user for the number of decimal places: (setq uprec (getint "Label precision: ")) . The semicolon ( . ) indicates the start of a comment: . 14. by Ralph Grabowski. Ask the user to pick a point in the drawing: (setq xyz (getpoint "Pick point: ")) . Dealing with files in AutoLISP is simpler than for most programming languages because AutoLISP has very weak file access functions. and (close) functions. (write-line).y. All it ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ 160 • v2. Separate 3D point into individual x. 0.z-coordinates.z-values: (setq ptx (car xyz) pty (cadr xyz) ptz (caddr xyz) ) . Let’s take a look at how to do this. “The LISP file comes in very handy with some of the programs I use. Truncate values: (setq ptx (rtos ptx 2 uprec) pty (rtos pty 2 uprec) ptz (rtos ptz 2 uprec) ) . Save the file as label. we began to worry about user interface enhancements. 773. A reader wrote.Notice that all the variables are local. Notice.

You have to choose one of these at a time. While AutoCAD users have often asked for those abilities. Now that you have the file descriptor stored in variable FIL. not the filename. you work with FIL. after erasing existing data. the write function. Step 2: Write Data to the File To write the data to the file. the new data is added to the end of the existing data. writes a single character to the file. It is important that the "a" be lowercase. (2) write data to the file. which I have decided to call xyzdata. so choose append mode. • When I open a file to append. For our purpose. The AutoLISP code looks like this: (setq FIL (open "xyzdata. This is a name (some sequence of letters and numbers) to which the operating system assigns the filename. all existing data in that file is erased and the new data is added.) The tailoring AutoCAD 2004 chapter 11 autolisp programming • 161 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . The options for the open function are: Option "a" "w" "r" Meaning Append data to end of file. AutoLISP cannot deal with binary file nor can it access data in random order. The Three Steps There are three steps in writing data to a file: • Open the file. • Write the data to the file. • Close the file. use the write-line function. Reading data is easy enough to understand but what's the difference between “writing” and “appending” data? • When I open a file to write. AutoLISP takes care of creating the file if it does not already exist. we want to keep adding data to the file.txt for appending data. In all three cases. Step 1: Open the File AutoLISP has the open function for opening a file. This function writes a line of data to the file. The final "a" tells AutoLISP we want to open xyzdata. Read data from file.can do is read and write ASCII files in sequential order. (A related function. we don’t deal with the filename directly but instead deal with a file descriptor. Write data to file.txt" "a")) Here you are setting something (setq) to a variable named FIL. this is the only occasion where AutoLISP is case-sensitive.txt. Autodesk has chosen not to add them. AutoLISP cannot do all three at once. and (3) append data to the file. What is it? In pretty much all programming languages. This function lets you open a file for one of three purposes: (1) read data from the file.

just write the raw data to the file because it would look like a lot of numbers with dots mixed in: 8. y. Closing the file is as simple as: (close fil) Putting It Together Add the code for opening. cadr.1548. Write coordinates to the drawing: (command "text" xyz 200 0 xyz1) . " pty ". writing. I can manipulate the data. we used the StrCat function along with the cdr. database programs. Open the data file for appending: (setq fil (open "xyzdata. For this reason. I tell these programs that when they read the data. " pty ". and caddr functions to separate the x. " ptz)) . So we can reuse the code.code looks like this: (write-line xyz1 fil) You cannot. In that way. With each number in its own cell. for good housekeeping purposes. we need code that formats the data.27520. Fortunately. AutoCAD automatically closes the file for you if you forget.2752. In the previous section. but good programmers cleans up after themselves. Add commas between the three coordinates: (setq xyz1 (strcat ptx ". Format the x.lsp program: (defun c:label ( / xyz xyz1 uprec ptx pty ptz) (setq uprec (getint "Label precision: ")) (setq xyz (getpoint "Pick point: ")) (setq ptx (car xyz) pty (cadr xyz) ptz (caddr xyz) ) . and z components of the coordinate triplet.z coordinates: (setq ptx (rtos ptx 2 uprec) pty (rtos pty 2 uprec) ptz (rtos ptz 2 uprec) ) .15483.y. we’ve already done that. however. formatting. like this: 8. Write the line of data to the file: 162 • v2. and even some word processing software. and not a comma. they should consider the comma to be a separator.0000 That includes spreadsheets. " ptz)) Step 3: Close the File Finally. close the file. and closing to the lable.0000 Most software is able to read data that has commas separating numbers.txt" "a")) .1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . the spreadsheet program places every number in its own cell. 3. 0. which looks like this: (setq pty ptz ) (setq ptx (car xyz) (cadr xyz) (caddr xyz) xyz1 (strcat ptx ".

but now takes up megabytes of disk space. 7.4883. especially in the area of user interface.0000 0. there are the same two methods as with setting the layer name. 3.) As you pick points on the screen. 5.0856.4331. One wishlist item was to control the layer that text is placed on.1548.lsp. 0. The no-code method is to simply set the text style before starting the routine. • The AutoLISP code version is to ask the user for the name of the layer. makes software grow far beyond the size of its basic algorithm.5303. That’s called “feature bloat” and explains why ten years ago AutoCAD used to fit on a single 360KB floppy disk. make those additions to your copy of lable. Tips in Using AutoLISP Here are some tips for helping out when you write your own AutoLISP functions.0000 0. 5.6528.4295. After a while. you might be noticing that our program is starting to look big. Wishlist #6: Text Style To specify the text style. tailoring AutoCAD 2004 chapter 11 autolisp programming • 163 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ .(write-line xyz1 fil) . There are two ways to approach this wishlist item: • The no-code method is to set the layer before starting the AutoLISP function. you can write AutoLISP code similar to the following: (setq tsname (getstring "Label text style: ")) (setvar "TEXTSTYLE" tsname) Once again. add those two line before the line with the ‘Pick point’ prompt.0000 Wishlist #5: Layers Let’s take a moment to go back and revisit our wish list. 6.7688. Otherwise.2752. as follows: (setq lname (getstring "Label layer: ")) (setvar "CLAYER" lname) Add those two line before the line with the ‘Pick point’ prompt.0000 0. More features. Close the file: (close fil) ) Using a text editor. Load it into AutoCAD with the Load function: Command: (load "label") And run the program by typing Label at the ‘Command:’ prompt: Command: label Label precision: 4 Pick point: (Pick a point. You may want to save clip this for reference. the routine labels the picked points but also writes the 3D point data to file. 6. 4. this is what the data file looks something like this: 8.3215. such as Notepad. 8. By now. then use the system variable CLAYER to set it (much easier than using the Layer command). 5.0000 0.

even when the file extension is .lsp extension.shx compiled shape files). then save as a . the code never moves from AutoCAD back to the text editor. or you can drag the . WordPerfect calls it “DOS Text”. No computer programmer ever assumes that the value of SplFrame is going to be zero just because that’s its default value. like this: Command: (defun c:x () (load "points")) Now anytime you need to load the points. you can use the above shortcut method. but not by default. Word processors have a number of different terms for what I mean by “pure ASCII format”. you’ll need to specify the folder name by using either a forward slash or double backslashes — your choice: Command: (load "\\autocad\\points") After you’ve typed this a few times. Toggling System Variables One of the problems in programming is: How to change a value when you don't know what the value is? In AutoCAD. In an increasingly WYSIWYG world. system variable SplFrame is by default 0: when turned off. load is for loading AutoLISP code. and Atlantis calls it “Text Files. Word. WordPad calls it “Text Document”. it is becoming harder to find a true ASCII text editor. which is not to be confused with the Load command (which is for loading a . you use the load command. which you’ll find in the \windows folder. AutoCAD would refuse to load the AutoLISP file.lsp file from the File Manager into AutoCAD.lsp. say. For example. Do not use Write or WordPad supplied with Windows. To solve the problem. There is one pure ASCII text editor supplied free by Microsoft with Windows called Notepad. A toggle system variable has a value of 0 or 1. When AutoCAD cannot find the points. you just type x and press Enter.Use an ASCII Text Editor AutoLISP code must be written in plain ASCII text — no special characters of the sort that all word processors add in. you come across this problem with system variables. indicating that the value is either off (0) or on (1).” Loading LSP Code into AutoCAD To load the AutoLISP code into AutoCAD. If you were to write AutoLISP code with. many of which are toggles.doc file (the default). as follows: Command: x Under Windows.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . splined polylines do not display their frame. you’re bound to forget sometimes and end up frustrated. you’ll find this gets tedious.lsp. Almost any other word processor has an option to save text in plain ASCII. write a one-line AutoLISP routine that reduces the keystrokes. In the case of toggle system variables.lsp routine. Clear? Here’s an example where points. While both of these have an option to save in ASCII. there two solutions: 164 • v2.lsp is the name of the AutoLISP routine: Command: (load "points") You don’t need to type the . Note that the code moves one way: from the text editor to AutoCAD. Word calls it “Text Only”.

Escape codes used in text strings must also remain lowercase. Note that they use backslashes. Here’s how to prevent that nil from appearing: end your routine with a (princ) all by itself. Here's a code fragment that shows this: (setq splvar (getvar "splframe")) . It also strips out all comments. For legibility. When your AutoLISP routine changes values of system variables. respectively. your function names in Mixed Case. your mother told you to always pick up your things. Quotation Marks as Quotation Marks As we have seen. Read-Write-Append File In (almost) all cases. AutoLISP would think you were typing an escape code. there are some conventions. excess white space.• Use the if function to see if the value is 0 or 1. There is an actual reason for nil appearing. restore the saved values at the end of the routine. and return characters. AutoLISP doesn’t care if you use UPPERCASE or lowercase for writing the code. "w". it must always set them back to the way they were before the routine began running. but the reason isn’t good enough for leaving it there. you cannot use a quotation mark as for displaying quotation marks and inches. The open function uses the arguments "r". Remember. Sound complicated? It is. tabs. After carrying out changes. Thus. specifically the octal code equivalent for the ASCII character for the quotation mark. The exception is text in quote marks. AutoLISP uses quotation marks " and " for strings. such as prompts. The workaround is to use the escape codes mentioned above in Tip #6. Be Neat and Tidy. This advice applies to the problem of the settings of system variables. For example. There are two exception where AutoLISP does care: when you are working with file functions and escape codes. such as AutoLISP function names in all lowercase. • Subtract 1. is left as is. and append to a file. (setvar "splframe" splvar) Suppress That nil Any time you run an AutoLISP routine.. tailoring AutoCAD 2004 chapter 11 autolisp programming • 165 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . AutoLISP doesn’t care. Those three characters must be lowercase.. Many programmers write a set of generic functions that save the current settings at the beginning of the routine. such as displaying 25 inches as 25". \e is the escape character (equivalent to ASCII 27) and \t is the tab character. and take the absolute value. and AutoCAD variables and command names in all UPPERCASE. As I said. it is for this reason that you cannot use the backslash for separating folders names back in Tip #2. write from. there is that pesky "nil" appearing as the very last thing displayed. and "a" to read to. and converts everything into uppercase in any case.

Vijay needs to use the \009 metacharacter to space the text in his dialog box. This lets me insert any ASCII character.54" Normally. as follows: (setq disttxt "The length is ") (setq distval 25) (setq qumark "\042") Notice how I assigned octal 042 to variable qumark. Is there any way I can get around this problem?” I recall a similar problem: How to display quotation marks or the inches symbol within a text string? For example. by the way.54"") AutoLISP sees the first quotation mark as the start of the string. in fact. AutoLISP uses the quotation as its string delimiter to mark the beginning and ending of the string. Then concatenate the three strings together with the strcat function: (strcat distxt distval qumark) To produce the prompt: The length is 25" Keep Variables to Six Characters To write the most efficient code. You may have notice that the variables I used above were all six characters or fewer. and quotation marks. AutoLISP uses twice the space to hold the variable name.. I cannot use the quotation ( " ) character in a string.. Octal. The solution is the \nnn metacharacter. Here’s how it works. In the following line of code: (prompt "The diameter is 2. “I want to display strings in it — just like the dialog box displayed by the Layer command. including special characters. such as tab. that worked: “According to what you had told me. \042. since the strings are of different lengths. and the third quotation mark as an error. the second quotation as the end of the string. keep the variable names to a length of six characters or fewer. like this: (prompt "The diameter is 2.But all you need to know is 042. I have a line of AutoLISP code that I want to print out as: The diameter is 2. 16 17 20 ...1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . First. The workaround here is to use the ASCII code for the quotation mark.” 166 • v2. I tried using the tab metacharacter (\t) in the string but it prints the literal '\t' in the list box. I am able to concatenate the values and print the strings but there is no vertical alignment. Tabs and Quotation Marks Vijay Katkar is writing code for a dialog box with a list box. When you go above the six-character length. The backslash tells AutoLISP the numbers following are in octal. And. escape.54\042") Similarly. is half of hexadecimal: 0 1 2 3 4 5 6 7 10 11 12 . He told me. I used the same and it worked. assign the strings to variables.

twelve cad management tailoring autocad 2004 i n this chapter.xtp file format. tailoring AutoCAD 2004 chapter 12 cad management • 167 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . which is ex/imported by the Tool Palettes tab of the Customize dialog box. we look at customizing AutoCAD 2004 through the CAD management tools: • Create and check standards of linetypes. dimension and text styles with the Standards and CheckStandards commands. And we examine the innards of the XML-based . • Manage drawing elements with the ToolPalettes and DesignCenter windows. layers. • Control layers with the LMan and LayTrans commands (see Chapter 2).

2.lin file. Step 1 – Create a drawing with the standards. ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ 168 • v2.CAD Standards You can enforce drawing standards by applying AutoCAD’s Standards command. Or. create layers. See Chapter 6 for creating custom linetypes. Step 3 – Apply the standards to working drawings. TIP You can select more than one linetype at a time: hold down the CTRL key as you pick them. import linetypes.) TIP It is important that you load linetypes before creating layers.dws file. save. From the Format menu. apply. both simple (1D) and complex (2D). and specify text styles. If necessary. (At this time. Step 2 – Save the drawing as a . select Linetype. In the drawing. click the File button to select a different . 2. to select all linetypes. the only standards that AutoCAD checks are for linetypes. That way the linetypes are available for assigning to layers. Start AutoCAD with a new drawing. Linetype Standards Use the Linetype command to load linetypes into the drawing: 1. Tutorial: Create the Standards Drawing 1. 3. Click the Load button. The linetypes are loaded in the drawing. The steps to implement standards work are: create. and then select the linetypes you want part of the standards drawing.1 11 nov 2003 . and check. right-click and click on Select All. setup dimension styles. dimension styles. and text styles. Click OK twice. Step 4 – Check that working drawings conform to standards. layers.

a “ByLayer”). When off. Linetype of individual objects can be overridden by the Change and Properties commands. Layers that are turned off or frozen also do not plot. For each layer. • Plot determines whether the layer is plotted. or regenerated.) Usual setting: ByLayer. but cannot be edited. locked or unlocked. Locked layers are displayed. set the following properties: • On determines the initial visibility and plotability of the layer. Linetype of individual objects can be overridden by the Change and Properties commands. When AutoCAD is in layout mode. the following options are also available in the Layer Properties Manager dialog box: • Current VP Freeze freezes the layer in the current viewport. • Linetype determines the linetype of all objects placed on the layer. on or off.k. overriding the setting of the Plot property (more below). Frozen layers are not displayed and are not plotted. Usual setting: thawed. Usual setting: Continuous. plotted. • New VP Freeze freezes the layer when a new viewport is created. Color of individual objects can be overridden by the Change and Properties commands. see Chapter 2. Layer visibility for individual viewports is controlled by Current VP Freeze (more later). Usual setting: On. color-dependent plot styles. • Lock determines whether the layer can be edited. • Freeze in All VP determines the “existence” of the layer. the layer is not displayed. on or off. rendered.k. • Color determines the color of all objects placed on the layer (a. • Plot Style determines the plot style applied to all objects on the layer (this property is unavailable when system variable PStylePolicy is set to 1. frozen or thawed in all viewports. tailoring AutoCAD 2004 chapter 12 cad management • 169 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . Usual setting: White/black.Layer Standards Use the Layer command to create layers. Usual setting: Default. hidden. Usual setting: on. When frozen. • Lineweight determines the line width of all objects placed on the layer (a. TIPS You can import layer names into a drawing using the LMan command provided with the Express Tools installation. Usual setting: thaw. the layer is not displayed and is not plotted. Usual setting: unlocked. Usual setting: thawed.a “ByLayer”). frozen or thawed.

GB-5 (Chinese standard). Text Style Standards Use the Style command to create text standards. layers.dim files. and xrefs from one drawing to another. text styles. Open to the Text Styles item. however. 170 • v2.Once you close the Layer Properties Manager dialog box.” TIP You can use the DesignCenter to copy blocks. In AutoCAD.dwt DIM . 3.dwt Dimension Style Name Standard (Autodesk’s default settings). layers. TIPS Drawings can have more than one dimension style. 2.dwt Gb .shx fonts. you easily copy text styles between drawings: 1. ISO-25 (international organization of standards). linetypes. You can use PostScript (.ttf) font in a drawing. CAD standards. “Textstyle(s) added. dimension and text styles. Duplicate definitions will be ignored. and select “PostScript Fonts (*.shx format with the Convert command. as well as Autodesk’s own .dim files into other drawings. borrow the dimension styles that Autodesk includes with its international template files: Template Group ANSI . AutoCAD notes. Or. Dimension Style Standards Use the DimStyle command to create dimension standards. layers.pfb) fonts after they have been converted to the . go to the drawing from which you wish to copy text styles.dwt ISO . and dimension styles. Like linetypes. To copy dimension styles from one drawing to another. and then drag the text style into the current drawing. JIS (Japanese industrial standard). In the Folder List.pfb)”. click on Files of type.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . In the Select Shape or Font File dialog box. the settings are saved in the drawing.dwt JIS . checks only for linetypes. You can use any TrueType (. dimension styles. DIN (German industrial standard). DimIn imports the . press CTRL+2 to open the DesignCenter. use these Express Tools: DimEx exports selected dimension styles from the current drawing as . layouts.

Open a working drawing. b.dws standards file to drawings. Enter a name in the File name text box.dws extension.dws)”. but gives it the . In the Standards tab. click the button with the blue + . Use the F4 and F5 keys to move drawings up and down the list. Notice the Select Standards File dialog box. and then click Open. 3. c. you can now save it as a standards drawing: 1. From the Tools menu. select the drive and folder in which to save the standard drawing. 3. Select the . From the File menu. Tutorial: Apply the Standards Now you need to attach the CAD standard to your working drawings: 1.Tutorial: Save Standards Drawings With all the settings in the drawing. 4. Click on the Files of type drop list. TIP You can attach more than one . the Add Standards File button (alternatively. press F3). AutoCAD reads them in priority order. 2. 2. Click Save. AutoCAD saves the drawing in regular . and then select “AutoCAD Drawing Standard (*.dws file you created earlier. In the Save Drawing As dialog box: a. In Save in. top to bottom in the list. Notice the Configure Standards dialog box.dwg format. tailoring AutoCAD 2004 chapter 12 cad management • 171 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . select CAD Standards | Configure. select Save As.

3. With the standards loaded into the working drawing. select CAD Standards | Check.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . Tutorial: Checking Standards To check whether a drawing violates CAD standards. AutoCAD displays them — one at a time — in the dialog box. Click the Fix and Next buttons to work your way through the violations. you can go on to checking for standards violations. When done. If problems are found. From the Tools menu. do this: 1.5. 2. Notice the Check Standards dialog box. click the Plug-ins tab to view the standards that’ll be checked. AutoCAD displays a summary screen: 172 • v2. If you wish.

layers. You access DesignCenter by pressing CTRL+2. and other computers connected via the local area network. linetypes. DesignCenter provides access to content in other drawings and on the Internet. called Content Explorer. DesignCenter DesignCenter provides access to blocks. text styles.Even if you don’t run the Standards command. Curiously. and alert you with a yellow balloon: TIP An alternative is to use the LayTrans command. AutoCAD 2004 can check standards in the background. simply drag it from DesignCenter into your drawing. tailoring AutoCAD 2004 chapter 12 cad management • 173 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . even though they were supported by the DesignCenter’s predecessor. hatch patterns are not supported. Once you locate content you wish to use. Tool Palettes lets you easily place blocks (and drawings) and hatch patterns (and color fills) in the current drawing. Employing DesignCenter and Tool Palettes AutoCAD’s DesignCenter and Tool Palettes work together. layouts. Access to content is provided in different by the four tabs along the top: • Folders provides access to content stored on your computer. which allows you to manually or automatically map layers from one drawing to another. and xrefs located in other drawings. dimension styles (dimstyles).

• History provides quick access to previously accessed files. 174 • v2. • Open Drawings provides access to content in all the drawings currently open in AutoCAD. Although the Load button appears to support IGES files.pat hatch pattern files. I could not drag them into the drawing. You can also drag these items into the drawing.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . including many kinds of raster images. • DC Center provides access to content located on Autodesk’s Web site.TIP The Load button on DesignCenter’s toolbar allows you to open all kinds of nonCAD files. and AutoCAD .

and so on. Instead of rummaging through the DesignCenter... But. I guess the “palettes” refers to the many tabbed parts to the window. (Use the object properties toolbar for access to line weights.) You turn on the tool palettes with CTRL+3: You can perform the following dragging operations: • From DesignCenter into the drawing.Tool Palettes In addition to dragging objects from DesignCenter into drawings. linetypes. even though it is a single window. Maybe next release of AutoCAD. dimension styles. text styles.) The purpose of the palettes is to provide a collection of often-used blocks and hatch/fill patterns. you can also drag them into the Tool Palette(s). The user interface is a bit too subtle for my liking. To customize the tool palettes: ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ tailoring AutoCAD 2004 chapter 12 cad management • 175 . there are options hidden in shortcut menus all over the place. the BHatch dialog box. colors. new to AutoCAD 2004. and the Insert dialog boxes – all of which list all hatches and blocks available. • From DesignCenter into the tool palettes • From the tool palettes into the drawing. nor can you drag from the palettes into DesignCenter. you cannot drag from the drawing into DesignCenter or the palettes. (The name has a plural.

• View Options displays a dialog box that determines the size and look of icons and descriptive text: • Paste pastes data from the Clipboard into the palette. • New Tool Palette creates a new blank palette. This option is available only if the Clipboard contains appropriate data. depending on which tab I right-click. and prompts you to name the tab: 176 • v2.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . because it displays the most options: • Move Up moves up the palette one position (available only for the second and lower tabs). but I get three different shortcut menus. I recommend right-click the tab belonging to the current palette. but not from AutoCAD itself. • Move down moves down the palette by one position (available only for the second last and higher tabs). such as an AutoCAD block. Another bug or feature: I can copy a block in DesignCenter for pasting in the tool palette.Tab Customization I don’t know if this is a bug or a feature.

• Properties displays this dialog box for changing (most) of the properties: Shown above are the properties of hatches.• Delete Tool Palette warns you against deleting it. tailoring AutoCAD 2004 chapter 12 cad management • 177 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . • Delete Tool removes the tool.) • Copy copies the tool to the Clipboard. Any property in white can be changed. (You can then right-click the palette. • Rename renames the tool. and select Paste. • Rename Tool Palette allows you to rename a tab. those in gray cannot be changed. Icon Customization Right-click an icon (called “tools” by Autodesk) to get the following shortcut menu: • Cut removes the tool and places it in the Clipboard. and then does it when you answer OK.

• Delete Tool Palette removes a palette. • Rename Tool Palette changes the name on the tab. • Transparency displays the following dialog box for setting the “see thru-ness” of the tool palette: • View Options displays the same dialog box as does the tab shortcut menu. if one has been copied or cut to the Clipboard. • New Tool Palette adds a new blank palette. • Paste pastes a tool.Palette Customization Right-click anywhere on an unused area of the palette — not on an icon or a tab — to get the following shortcut menu: • Allow Docking toggles whether you want the tool palette to dock against the side of the AutoCAD window. should it get close enough. • Auto-Hide toggles whether the tool palette shrinks to just its title bar when the cursor leaves it.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . • Customize displays the Customize dialog box with the Tool Palettes dialog box: 178 • v2.

or else are self-evident. instead. the New Tool Palette option does not create a new window.Tool palettes showing off its maximum transparency over DesignCenter: Titlebar Customization There is one more shortcut menu that comes up when you right-click the title bar — you actually customize the title bar: Most of the options are repeats from other shortcut menus.” Unlike what you might think. The one interesting option is: • Rename changes the name on the title bar from the default of “Tool Palette. it simple adds another palette and tab to the existing window. tailoring AutoCAD 2004 chapter 12 cad management • 179 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ .

which could be an acronym of either “eXport Tool Palette” or “Xml-format Tool Palette. resides in minor areas of AutoCAD 2004. the feature was removed. which looks something like the code listed below. the tag has the slash character at the end. • Sometimes data is stored inside tags. valueType. • Tags are surrounded by angle brackets. and somewhat less easy to understand. while Space Plan is the data. <DependentFilesPath> is the name of the tag. XML employs a bare minimum of metacharacters: • Tags identify data. Notice that AutoCAD prompts you to save the palette as an .1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . data is not: <DependentFilesPath> Space Plan </DependentFilesPath> Here. and then click the Export button. XML Metacharacters XML is a an easy format to read. no matter if numbers or text. and followed by an ending tag. If you know HTML. however.XTP File Format AutoCAD 2002 introduced a dialect of XML (extended markup language) called DesignXML. To that you can share tool palettes with other users. One example is shown in this section. it is somewhat self-documenting. It is easy to read because it is saved in human-readable ASCII format. such as DependentFilesPath.xtp file. three pieces of data are defined by the tag — unspecified. notice the use of uppercase letters to make clearer compound words. XML still. XML is a snap to understand. The tag is a single word. The ending tag is identified by the slash character immediately following the opening angle bracket. select Customize | Tool Palettes. AutoCAD exports the content of the Tool Palette in a variant of XML with an extension of . for example. Autodesk “hid” the import and export in the Insert and WBlock commands. In the example above. although sometimes it takes some guessing to be clear on the meaning of a parameter. Notice that data is always surrounded by quote marks. 180 • v2. as in <\DependentFilesPath>.xtp. Use a text editor to view the file.” To export the Tool Palette: from the Tools menu. before the closing angle bracket. and value. • Data is often headed by a starting tag. on which XML is based. with AutoCAD 2004. For example: <PropValue unspecified="TRUE" valueType="2" value="0"/> In this case.

xtp file format consists of three major sections: Section 1 – Header introduces the tool palette Section 2 – Tools Data defines the symbols stored in the tool palette.” block shown in the tool palette below.30 x 60 in. Section 3 – Palette Data defines the position and look of the tool palette. The example code is based on the “Desk . XTP Section 1: Header The header section identifies: • File type – ToolPaletteExport • Paths to related files – DependentFilesPath • Date and time of creation – Time <ToolPaletteExport> <DependentFilesPath> Space Plan </DependentFilesPath> <PaletteSets> <PaletteSetData> <PaletteSetContent> <Palettes> <PaletteData> <PaletteContent> <Palette> <ItemID idValue=”{184C56D6-62F7-42FB-9087-28BA130ABFA1}”/> <Properties> <ItemName> Space Plan </ItemName> <Images/> <Time createdUniversalDateTime=”2002-12-04T22:34:02" modifiedUniversalDateTime=”2002-12-04T22:34:02"/> </Properties> <Source/> <Tools> tailoring AutoCAD 2004 chapter 12 cad management • 181 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . I have indented tag sections.xtp format easier to read. and have boldfaced the starting tag.Tool Palettes XTP The . To make the .

XTP Section 2: Tool Data The tool data section describes each item in the palette. • Time and date created – Time. typically a block or hatch pattern. Linetype. • Properties specific to objects – Block and Hatch (drawings are treated as blocks).PNG”/> <Image cx=”64" cy=”64" src=”Images\DESK264. such as “Desk .1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . <Tool> <ItemID idValue=”{67D3B8AB-7D80-4079-A230-B3760B71157D}”/> <Properties> <ItemName> Desk .” – ItemName • Large and small icons in .PNG”/> </Images> <Time createdUniversalDateTime=”2002-12-03T17:53:19" modifiedUniversalDateTime=”2002-12-03T17:53:19"/> </Properties> <Source idValue=”{DB288698-E6B7-4C26-9BB7-8881A36785F2}”/> <StockToolRef idValue=”{C9AB9290-FC5A-458B-AEB4-BDF9BE6A5E55}”/> <Data> <GeneralProperties> <Color> <BasicPropInfo> <PropValue unspecified=”TRUE” valueType=”2" value=”2"/> </BasicPropInfo> </Color> <Layer> <BasicPropInfo> <PropValue unspecified=”TRUE” valueType=”1"/> </BasicPropInfo> </Layer> <Linetype> <BasicPropInfo> <PropValue unspecified=”TRUE” valueType=”1"/> </BasicPropInfo> </Linetype> <LinetypeScale> <BasicPropInfo> <PropValue unspecified=”TRUE” valueType=”3" value=”1"/> </BasicPropInfo> </LinetypeScale> <PlotStyle> <BasicPropInfo> <PropValue unspecified=”TRUE” valueType=”1"/> </BasicPropInfo> </PlotStyle> <LineWeight> <BasicPropInfo> <PropValue unspecified=”TRUE” valueType=”2" value=”0"/> </BasicPropInfo> </LineWeight> </GeneralProperties> 182 • v2.66 x 68 in. The item is defined by: • Name displayed on the tool palette. </ItemName> <Images> <Image cx=”32" cy=”32" src=”Images\DESK232. LinetypeScale. Layer.png format – Image.66 x 68 in. There is one <tool> </tool> section for each item. PlotStyle. and Lineweight. • General properties common to all objects – Color.

which 0 means unexploded – Explode. • Rotation angle of the block. • Whether the pattern is repeated at a 90-degree angle to create a cross-hatch – Double. • Path to the .dwg source file in which the block is stored – SourceFile. • Name of the block – BlockName. • Scale of the pattern. • Angle of the pattern. where 0 means unrotated – Angle. <Block> <BlockType> 1 </BlockType> <BlockName> DESK2 </BlockName> <SourceFile> d:\foldername\NewFeaturesWorkshop\Sample\Office Space Plan.pat source file in which the pattern is defined – SourceFile.00mm – PenWidth. where 100 = 1. where 0 means unrotated – Rotation. • Penwidth of lines for ISO hatch patterns. where 1 means unscaled – Scale. where 1 means unscaled – Scale.Blocks are defined by these tags: • BlockType (value always seems to be 1). • Scale of the block. • Spacing between lines of user-defined hatch patterns – Spacing. • Name of the hatch – PatternName (user-defined hatches are named “_U”).dwg </SourceFile> <Scale> 1 </Scale> <Rotation> 0 </Rotation> <Explode> 0 </Explode> </Block> Hatches are defined by these tags: • HatchType (value always seems to be 1). tailoring AutoCAD 2004 chapter 12 cad management • 183 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . • And whether the block is exploded. • Path to the .

• The position of a docked palette – DockInfo .• BlockExtent (?). either 32 or 64 pixels – Image. • The position of a floating palette – FloatInfo. </Data> </Tool> </Palette> </PaletteContent> <PaletteUI> <CAdUiPalette PaletteStyle=”1"/> <CAcTcUiToolPalette> – 184 • v2.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . • Order in which the tool palettes appear – ToolOrder. • Properties of the palette – CAdUiPaletteSet. • Style (perhaps a bitcode). • Whether the palette is allowed to dock CAdUiDockControlBar. perhaps reserved • Size of the preview image. to have no effect. <Hatch> <HatchType> 1 </HatchType> <PatternName> BRICK </PatternName> <SourceFile> %ProgramName%iso.pat </SourceFile> <Angle> 0 </Angle> <Scale> 1 </Scale> <Spacing> 1 </Spacing> <PenWidth> 100 </PenWidth> <Double> 0 </Double> <BlockExtent> 1 </BlockExtent> </Hatch> XTP Section 3: Palette Data The PaletteUI (user interface) section describes the tool palette itself: • Style of palette (value seems for future use) – CAdUiPalette.

<CatalogView ID=”{184C56D6-62F7-42FB-9087-28BA130ABFA1}”> <ToolSource> <Palette ID=”{184C56D6-62F7-42FB-9087-28BA130ABFA1}”> Space Plan </Palette> </ToolSource> <Image SizeCX=”32" SizeCY=”32"/> <Style> 491522 </Style> <ToolOrder> <Tool ID=”{1541B604-B9D1-4D56-A755-8BF1EF921A9A}”/> <Tool ID=”{67D3B8AB-7D80-4079-A230-B3760B71157D}”/> <Tool ID=”{B8E8FDCD-E0FB-4BDD-9D46-1EFEFE0C1055}”/> <Tool ID=”{D757A727-53A1-4532-A4A5-D7F4AB5F9362}”/> <Tool ID=”{F18F7848-0358-4CDE-B666-7419335215FF}”/> <Tool ID=”{97C2916C-E0E5-4DE0-90DD-92F83BEF2C80}”/> <Tool ID=”{32F72D23-80D9-4819-B1E7-B4D14C230D46}”/> </ToolOrder> </CatalogView> </CAcTcUiToolPalette> </PaletteUI> </PaletteData> </Palettes> </PaletteSetContent> <PaletteSetUI> <CAdUiDockControlBar Orientation=”-1" AllowDocking=”1"> <FloatInfo Left=”49" Top=”96" Width=”231" Height=”493"/> <DockInfo Left=”6120" Top=”576" Width=”262" Height=”552"MRUDockID=”59421"/> </CAdUiDockControlBar> <CAdUiPaletteSet ActivePaletteIndex=”2" TitleBarLocation=”0" AuoRollup=”0" Name=”Tool Palettes” Style=”126" Opacity=”100" Visible=”1"/> </PaletteSetUI> </PaletteSetData> </PaletteSets> </ToolPaletteExport> tailoring AutoCAD 2004 chapter 12 cad management • 185 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ .

com.Copyright Information This book is covered by copyright.com/tailor2004.1 11 nov 2003 ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ ○ . Feedback I welcome your feedback for correcting and improving the text. 186 • v2. Visit the Tailoring AutoCAD 2004 e-book Web site at www.com to purchase additional copies. visit the eBooks. Contact editor@upfrontezine. Ltd. upFront.eZine Publishing. Ltd.upfrontezine.upfrontezine. As the owner of the copyright.com/ebooks. Send your email to editor@upfrontezine.onLine Web site at www. You may not claim authorship or ownership of the text or figures herein.eZine Publishing. does not give you permission to make electronic or print copies. All rights reserved worldwide. For more of our technical e-books. Copyright © 2004 by upFront.

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->