Download as pdf or txt
Download as pdf or txt
You are on page 1of 65

Top AutoCAD Customization Tips

Top
Customization Tips Every
AutoCAD User Should Know

By Ellen Finkelstein

www.ellenfinkelstein.com

1
Top AutoCAD Customization Tips

Ellen Finkelstein’s Top Customization Tips Every AutoCAD


User Should Know

Published by Rainbow Resources


2010 Coral Lane, Fairfield, IA 52556, USA

Copyright 2014 For information, e-mail contact@ellenfinkelstein.com

Manufactured in the United States of America


No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means,
electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the
1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through
payment of the appropriate per-copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923,
(978) 750-8400, fax (978) 646-8600. Requests to the Publisher for permission should be addressed to
contact@ellenfinkelstein.com or Ellen Finkelstein, Rainbow Resources Publishing, at the above address, or 641-472-1832.

Limit of liability/disclaimer of warranty: the publisher and the author make no Representations or warranties with
respect to the accuracy or completeness of the Contents of this work and specifically disclaim all warranties, including
without Limitation warranties of fitness for a particular purpose. No warranty may be created or extended by sales or
promotional materials. The advice and strategies contained herein may not be suitable for every situation. This work
is sold with the understanding that the publisher is not engaged in rendering legal, accounting, or other professional
services. Neither the publisher nor the author shall be liable for damages arising herefrom. The fact that an
organization or website is referred to in this work as a citation and/or a potential source of further information does
not mean that the author or the publisher endorses the information the organization or website may provide or
recommendations it may make. Further, readers should be aware that Internet websites listed in this work may have
changed or disappeared between the time this work was written and when it is read.

For general information on our other products and services, please go to www.ellenfinkelstein.com. This book is published in
both electronic and print format.

2
Top AutoCAD Customization Tips

About the Author


Ellen Finkelstein has been using AutoCAD since 1986, teaching it since
1989 and writing about it since 1992. She is the author of the best-
selling AutoCAD & AutoCAD LT Bible, which started with Release 14
and has been updated many times since then.

Ellen has written extensively on AutoCAD, including articles for


Autodesk's website and features for AutoCAD's Help system. Ellen's
first book was AutoCAD For Dummies Quick Reference. Since then,
she has written books on PowerPoint, Flash (including Flash CS5 For
Dummies), and Web technologies (Syndicating Web Sites with RSS
Feeds For Dummies).

Her well-known website, EllenFinkelstein.com, and blog, AutoCAD Tips


Blog, are very popular among AutoCAD users. You can join thousands
of other AutoCAD users and subscribe to her free AutoCAD Tips
Newsletter.

3
Top AutoCAD Customization Tips

Acknowledgments & Dedication


I’d like to thank my husband, Evan, for supporting me in my work,
and my two children, who are the joys of my life. While most of the
tips are mine, there are also contributions from my readers and I
want to thank them for sharing their knowledge.

***
To MMY, for teaching me that the Unified Field and the spirit of God
are one and the same, and that anyone can experience it as bliss
consciousness.

***

4
Top AutoCAD Customization Tips

Introduction
AutoCAD users are always looking for ways to be more productive.
That’s why they love tips! AutoCAD is meant to be customized, but
customization is one of the most complex features of AutoCAD. I’ve
been writing tips for years, so I thought I would compile some favorite
customization tips so everyone can easily use them.

One reason that I love writing AutoCAD tips is that people are so
appreciative. They really want to learn more about this huge program.
AutoCAD is not only useful – it’s fun! I hope that this e-book will help
you become more productive, less stressed, and more knowledgeable.

5
Top AutoCAD Customization Tips

Contents
About the Author 3

Acknowledgments & Dedication 4

Introduction 5

Chapter 1 Automation 7
1. Create a command alias (keyboard shortcut) 7
2. Automate tasks with a script file 12
3. Record macros with the Action Recorder 14
4. Use the command line to launch programs 22
5. Create a custom command 22
6. Create a custom keyboard shortcut 26

Chapter 2 User Interface 29


7. Add a button to the ribbon in AutoCAD 29
8. Make the command line work the way you want it to 33
9. Change the color of almost any AutoCAD screen feature 38

Chapter 3 Linetypes and hatches 41


10. Create a custom simple linetype 41
11. Creating custom hatch patterns 44

Chapter 4 AutoLISP 50
12. Get all of your AutoLISP routines to load themselves 50
13. Create a custom command for AutoCAD using AutoLISP 51

Chapter 5 Miscellaneous 56
14. Create a custom function in AutoCAD’s calculator 56
15. Easily share tool palettes with colleagues 61

Sign up to get the free AutoCAD Tips Newsletter! 64


Don’t miss! 64

6
Top AutoCAD Customization Tips

Chapter 1
Automation
One of the main reasons for customizing AutoCAD is to speed up your
work. In this section, I cover
 Command aliases
 Script files
 Recording macros
 Launching programs from the command line
 Custom commands
 Keyboard shortcuts

1. Create a command alias (keyboard shortcut)


Many people like to use the keyboard to enter commands, but
some of the commands are long, hard to type, or difficult to
remember. You can create keyboard shortcuts for commands, such as
DL for DIMLINEAR or RVC for REVCLOUD.

AutoCAD comes with a large number of aliases already made for


you. You edit the acad.pgp file to add to these, or change them.

The acad.pgp file is a text file and you can edit it directly, but the
easiest way is to use the Express Tools ALIASEDIT command.

Follow these steps:

1. Choose Express > Tools > Command Alias Editor.

7
Top AutoCAD Customization Tips

2. After deciding the command and alias you want, check to


see if the command already has an alias. Click
the AutoCAD Command column to alphabetize the list by
commands. Scroll to look for the command.

3. If it doesn’t have an alias, check to see if the alias is


already in use. To do so, click the Alias column to
alphabetize that column. Click any alias, and type the first
letter of the alias to jump to aliases starting with that
letter. Look for the alias.

4. If your command isn’t listed and your alias isn’t being


used, click Add.

8
Top AutoCAD Customization Tips

5. Type the alias in the Alias text box and


the AutoCAD command below it. All the commands are
on the list, and as you start to type, the command
appears on the list. You can click it as soon as you see it,
or type the entire command. For example, I added rvc for
REVCLOUD. Click OK.

6. If your command is on the list, but your alias isn’t, you


can add the alias for the command. As before, click Add,
enter the alias, and specify the command. A command
can have more than one alias. I added dl for DIMLINEAR,
even though there were other aliases for that command.

7. If your alias is being used, you can delete or change it.


Then you can use it for a different command. For
example, rc is the alias for RENDERCROP, which you might
rarely use. By deleting it, you could use rc for RECTANG.

9
Top AutoCAD Customization Tips

To delete an alias, select it and click Remove, then click


Yes to confirm.

8. You can change an existing alias. For example, you might


want to change the alias for RENDERCROP to rencr,
instead of deleting it. To do so, choose the alias, and click
Edit. In the Edit Command Alias dialog box (which looks
just like the New Command Alias dialog box), enter the
new alias and click OK.

Note: You might be surprised to see some aliases on the


list that are longer than their commands! Or completely
different. AutoCAD uses this to map one command to another or to
include command names that don’t exist, but that people might still
use. For example, the RECTANG command has an alias of rectangle.

Tip: To print the alias list, choose File > Print from
the AutoCAD Alias Editor’s menu.

9. When you’re done, click OK. If the Confirm Changes dialog


box is checked, you get a message asking you to confirm
that you want to replace the configuration file (acad.pgp).
Click Yes.

10
Top AutoCAD Customization Tips

10. AutoCAD doesn’t recognize the change right away,


because it doesn’t re-check the acad.pgp file during a
session. You could close and re-open AutoCAD, but there’s
an easier way. On the command line, enter reinit.

11. Check the PGP File check box and click OK. Now
your new aliases will work. Try them out!

Note: You can edit the acad.pgp file directly. It’s in the Support
folder. To find that folder, choose Tools > Options and click the Files
tab. Double-click the Support File Search Path item and look at the
first item. This file contains a User Defined Command Aliases section
at the end where you can add your own aliases; these aliases override
those in the main section. Use the same format as you see in the file,

11
Top AutoCAD Customization Tips

which is Shortcut,*Full_command_name. Save the file and use the


REINIT command as just described.

2. Automate tasks with a script file


A script is a macro, a list of commands that you can run all at
once, and as many times as necessary, allowing you to automate
tasks that would take a long time if you did them manually.
Scripts can be very powerful and you can run them on objects in one
drawing, or on many drawings. Scripts have been around for many
years and many people have a library of scripts that they use.

Here are 3 important points that you need to know about


scripts:
1. Scripts are text-only (ASCII) files. You usually create them
in Notepad.
2. They have an SCR filename extension, so be sure to save
them that way.
3. Scripts use command-line syntax only. They can’t access
dialog boxes, toolbar buttons, etc.

Follow these steps to create a script file:

1. Set the FILEDIA system variable to 0, to stop dialog boxes


that access files from opening.

2. Run through the steps that you want to automate, using


the command line only. Write down (or type in Notepad)
the steps. You can copy your command line entry directly

12
Top AutoCAD Customization Tips

to Notepad. Press F2 to open the AutoCAD Text Window


for that purpose.

3. Press Enter at the end of each command or use a blank


space, which is the equivalent of pressing Enter. The
script reads every space, so you need to get it exactly
right! The script is easier to read if you put each command
on its own line.

4. Enclose layer names or files names (and file paths) that


contain spaces in quotation marks.

5. Insert comments periodically for explanation. To insert a


comment, precede the text with a semicolon.

6. Save the file with an SCR filename extension, by


typing .scr after the file name.

7. Set FILEDIA back to 1.

To run and test the script file from within a drawing, use the
SCRIPT command. A dialog box opens, where you can choose
your script file. Click Open and the script runs.

Let’s say that you want to run a script file on more than one
drawing. You can use the OPEN, CLOSE, and QSAVE commands to
open drawings, run some commands, save the drawings, and then
close them. You can still start the script from within the 1st drawing,
but you can also start a script file as you open AutoCAD.
13
Top AutoCAD Customization Tips

To do so, you change the expression that Windows uses to


open AutoCAD. The best way to do this is to use the shortcut on
your Desktop. Follow these steps:

1. Right-click the shortcut and choose Properties.

2. Click the Shortcut tab.

3. At the end of the existing expression (which reads


something like C:\Program Files\AutoCAD 2015\acad.exe)
add a space and then the following:

/b script_name

4. Click OK.

5. Double-click the shortcut to open AutoCAD and run the


script.

I've also tried Hurricane, which automates the process of


creating and running script files on multiple drawings. It
comes with many existing script files and offers lots of
flexibility.

3. Record macros with the Action Recorder


Since AutoCAD 2009, you can record macros for later use. You
can include requests for user input and messages to make the macro
work interactively.

14
Top AutoCAD Customization Tips

When you save a macro, it has an ACTM filename extension.


You’ll find it in your Support\Actions folder of your AutoCAD
installation. You can share ACTM files with others.

Start by thinking about the conditions that you’ll need when you
run the macro. Will you be in model space or paper space? The macro
doesn’t keep track of all of the current settings. If a certain setting is
necessary, use the system variable or the SETVAR command while
recording the macro to make sure that you have the setup you’ll need
at playback time.

Action Recorder macros have some limitations:

 You can’t open files

 You can’t grip edit or use PRESSPULL

 You can’t load VBA files

Macros also don’t record changes to a dialog box, which means


that you may need to use the command line version of a command. If
you’ve worked with scripts, you’re familiar with this type of
functioning.

You may find other limitations.

The Action Recorder feature is on the Tools tab, in the Action


Recorder panel.

15
Top AutoCAD Customization Tips

Here’s an example of how you would create a macro to change


all objects to the default 0.25mm lineweight. You might get drawings
from a company that adds lineweights to objects. Moreover, their
default might be different. So this macro sets the default to 0.25,
turns on the display of lineweights, and then uses the CHPROP
command to change the lineweight of selected objects to the default.
At the end, the macro turns off lineweight display.

Figuring out which commands to use often involves some


research. For example, I knew that I could turn the lineweight display
off and on using the button on the status bar, but I couldn’t do that in

16
Top AutoCAD Customization Tips

the macro, since I didn’t know which way the display would be when I
played back the macro. If I wanted to turn the display on, and it was
already on, clicking the button would turn it off! So I needed to find
the system variable involved, which was LWDEFAULT. Then, it was
easy to turn it on and off as needed.

When you’ve figured out the steps that you want to take, and
tried them out a couple of times in different situations, you’re ready
to record.

Choose Tools tab> Action Recorder panel> Record. Your cursor


now has a red dot, to show you that you’re recording.

Go through the steps that you practiced. When you’re done.


click the Stop button that has replaced the Record button. You now
have the opportunity to name and save the macro, as well as choose
a few options.

17
Top AutoCAD Customization Tips

Here is the command line that I created as I recorded:

18
Top AutoCAD Customization Tips

Because I specified all at the Select objects: prompt, the


macro will always select all objects. I tested that by adding more
objects with a non-default lineweight; they were also changed.

Here’s what the macro looks like in the Action Recorder drop-
down window:

19
Top AutoCAD Customization Tips

I might want to be able to select individual objects. Letting the


user select objects makes the macro interactive, and it’s a very
helpful feature.

To do this, I reorganized the macro and used the SELECT


command before the CHPROP command. While recording, I simply
picked any objects. For the CHPROP command, I then used
the p (Previous) option at the Select objects: prompt. When I was
done, the macro looked like this:

20
Top AutoCAD Customization Tips

Then I right-clicked the Select Objects item, and chose Request


User Input, as shown below:

When I ran the macro, I got a dialog box asking if I wanted to


provide user input. By accepting that option, I was able to either
select objects, or enter all.

21
Top AutoCAD Customization Tips

4. Use the command line to launch programs


You may know that you can start certain Windows
programs from the command line. These programs are in the acad.pgp
file that defines aliases for commands. The first section has aliases for
Windows commands.

To edit this file and add more commands, choose Tools >
Customize > Edit Program Parameters. Notepad opens the acad.pgp
file. Scroll down until you see the following:

Therefore, if you type explorer on the command line, Windows


Explorer opens. To open a new file in Notepad, type notepad and press
Enter at the prompt that appears.

If you add commands, use the same format. The text before
these commands explains the meaning of the 1 and the general
format. Then save the file. Back in AutoCAD, type reinit to reinitialize
acad.pgp and you’ll be able to use your changes.

5. Create a custom command


If you find yourself using the same combination of commands
and options over and over, you can easily create a custom command

22
Top AutoCAD Customization Tips

that executes the combination with a click of a button or a menu item.


In this tutorial, I explain the basics of AutoCAD’s menu syntax so that
you can create your own commands. No programming required!

Enter cui at the command line/dynamic tooltip to open the


Customize User Interface dialog box.

In the Command List pane, click New (Create a New Command).

In the Properties pane, enter a name for the command in the


Name text box. Also enter a description in the Description text box.

If you think your command will be long or need more than one
line, click in the Macro text box and then click the Ellipsis button that
appears on the right. Then enter your macro in the Long String Editor
dialog box. Otherwise, enter the macro in the Macro text box. Start by
writing out the combination of commands and options as you would
enter them on the command line or in a script. Then add any
necessary special characters.

Below are the special characters you need to know for menu
macros:

Character Description

Equivalent to pressing Enter except when


Space
entering text to create a text object that

23
Top AutoCAD Customization Tips

contains spaces (between words). Use


between the command and its options.

Equivalent to pressing Enter. The end of a


line in a menu macro is also equivalent to
pressing Enter. More helpful than using a
; (semi-
space when you need to press Enter twice,
colon)
because it shows the number of Enters
more clearly. Also helpful at the end of the
macro.

Pauses for user input, such as picking a


\
point or entering a value.

At the end of a macro line, continues the


+
macro to the next line

At the beginning of a macro, before


* ^C^C, repeats the macro until you press
Esc or choose another menu item.

Toggles the display of the menu macro on


^P the command line; makes the macro look
neater when you use it.

24
Top AutoCAD Customization Tips

From the Command List Categories drop-down list, choose


Custom Commands to easily find your command. Select it and drag it
to the desired tab at the top of the Customize User Interface dialog
box.

You can use the Button Editor to give it an image. Usually, you
choose an existing button to start with, click Edit, and modify it. Then
click the Save As button to save the icon image.

Click OK and try out your new command!

25
Top AutoCAD Customization Tips

6. Create a custom keyboard shortcut


Would you like to create a keyboard shortcut to your favorite
command-option combination? For example, I would like a version
of the COPY command that doesn’t repeat, that is, that ends after one
copy operation. Here are the steps:

Enter cui to open the Customize User Interface dialog box.

In the Command List pane, click the New button.

In the Properties pane, you can now specify your new command.
Enter a name and a macro. If the macro is long, click the Ellipsis
button at the right side of the Macro text box to open the Long String
Editor. My macro was^C^C_select;\_copy;_previous;;\\;;

26
Top AutoCAD Customization Tips

In the Customizations In All Files pane at the top, expand Partial


CUI Files, then Custom, then Keyboard Shortcuts, so you can
see the Shortcut Keys item.

Find your new command in the Command List pane (it’s listed
under the name you gave it and a tip is to choose Custom Commands
from the drop-down list in that pane) and drag it to the Shortcut Keys
item in the top pane.

27
Top AutoCAD Customization Tips

Click the command where it appears in the top pane. Its


Properties pane now shows a Key(s) item. Click that item and then
click its Ellipsis button. The Shortcut Keys dialog box opens.

Press the shortcut key combination you want to use and you can
see if it’s unassigned — or assigned to something you never use.
Generally, it has to start with Ctrl, Ctrl+Shift, or Shift. Click OK.

Click OK to close the Customize User Interface dialog box.

Try out your new shortcut!

28
Top AutoCAD Customization Tips

Chapter 2
User Interface
AutoCAD's user interface is completely customizable and you should
certainly take advantage of this fact to organize the ribbon to make
your work go more quickly and make the user interface look the way
you want it to.

In this chapter I cover how to:


 Add a button to the ribbon
 Make the command line work the way you want it to
 Change the color of almost any AutoCAD screen feature

7. Add a button to the ribbon in AutoCAD


If you’re interested in creating custom commands, also see
“Tutorial: Create a custom command.” This tutorial builds on those
skills, but is complete in itself.

Choose Tools tab> Customization panel> User Interface, or just


type cui on the command line.

Tip: If you display the tab you want to work on and type cui on
the command line, you can see that tab as you work– just move the
Customize User Interface dialog box. In fact, if you click the title of
the panel you want to work on and click the Pin icon, you can keep
even the bottom section open as you work. (Unfortunately, the
bottom section collapses when you click Apply.)

In the Customization in All CUI Files pane, expand the Ribbon


Panels item.

29
Top AutoCAD Customization Tips

Expand the panel where you want to add your command. You’ll
see several rows. Expand one or more rows that you might want to
look at. Here you see the Draw-2D panel open with several of its
rows. To the left, you can see the expanded panel itself.

Note: Sub-panels are a way of compartmentalizing commands


for layout purposes. On the Draw-2D panel, there’s a sub-panel after
the LINE command to separate that command from the rest. Also,
each panel comes with a panel separator. Rows below the panel
separator don’t show until you click the panel name; they’re in the
lower, expanded section.

30
Top AutoCAD Customization Tips

Caution: Remember to back up your original menu file in case


you make a mistake! The file is acad.cui or acad.cuix (depending on
which release of AutoCAD you’re using). The location may vary, so use
the OPTIONS command and click the Files tab. Open the
Customization Files item to find the location. When you find the file,
use Windows Explorer to back it up. Another option is to use Windows
Explorer to make a copy first, rename the copy, and load the copy.
Use the CUILOAD command to first unload the main acad.cui file, then
browse to your copy and load that.

Decide which changes you want to make. I added a custom


command and moved existing commands around to better suit how
often I use them. Don’t make the panel too wide, because you need
to leave room for the rest of the panels. If you make a panel too wide,
others will be condensed and you won’t see all of their contents.

To move existing commands, drag them from one location to


another. (Sometimes this doesn’t always seem to work on the first
try; try another location, or delete the command and drag it from the
Command List to the new location.) To delete a command, right-click
and choose Remove.

To add a different or custom command, locate it in the


Command List at the lower-left corner of the dialog box. Then drag it
to the desired location.

31
Top AutoCAD Customization Tips

To delete a sub-panel, drag its contents to another location,


right-click it, and choose Delete. Sub-panels do a nice job of setting
off buttons, but they create blank space that you might want to use.

When you’ve made a few changes and want to see how they
look, click the Apply button and wait while AutoCAD reloads the menu.

Note: The panel preview at the upper-left corner of the dialog


box isn’t completely accurate, so don’t rely on it completely. For
example, my preview showed the LINE command with a large icon,
but it shows as a standard-sized icon on my ribbon. You can set the
size in the Properties panel.

When you’re done, click OK. Here you can see my new menu.
I’ve added a custom 1LINE command (line \\;) which ends the LINE
command after one line. I’ve also moved the existing buttons around
and banished some to below the panel separator.

32
Top AutoCAD Customization Tips

(Originally done in AutoCAD 2009.)

8. Make the command line work the way you want it to


The command line is an essential component of drawing
in AutoCAD. Even if you don’t type commands there, you need to look
at it for prompts and you probably use it to specify options.

The command line is actually a palette window.

See more of the command line

The command line palette shows 2 - 3 lines of text depending


on your release of AutoCAD. You can drag the upper edge of the
palette to show more lines.

33
Top AutoCAD Customization Tips

To display the entire history of the command line, press F2 to


open the AutoCAD Text Window or expand the command line window.

34
Top AutoCAD Customization Tips

See less of the command line

On the other hand, if you think that the command line takes up
too much space you can hide it or collapse it.

To hide the command line, pres CTrl + 9. So you don’t do this


by accident without knowing how to get the command line back, you
see this message:

Check the Always Close the Command Line Window check box
to avoid seeing this message the next time. Then click Yes. Now, you
can easily toggle the command line to display and hide it.

To collapse the command line (like other palettes such as the


Properties window or the Tool Palettes), first undock if necessary it by
dragging its gray title or grab bar at the left.

35
Top AutoCAD Customization Tips

Then right-click the gray title bar and choose Auto-Hide. The
command line palette collapses to a small gray bar. That’s pretty
small! But as soon as you hover your cursor over the bar, the
command line expands.

Let AutoCAD help you

Starting with AutoCAD 2012, when you start to type a


command, AutoCAD auto-completes. If you pause, you see all
36
Top AutoCAD Customization Tips

commands starting with the letters you typed and you can choose the
desired command.

You can do minor editing as you type, in case you make a


mistake (before pressing Enter):
 Home: Moves the cursor to the beginning of the line
 End: Moves the cursor to the end of the line
 Left arrow: Moves the cursor to the left
 Right arrow: Moves the cursor to the right
 Backspace: Deletes the character to the left of the cursor
 Delete: Deletes the character to the right of the cursor

You can also use Ctrl+V to paste text from the Windows
clipboard.

More command line tricks & tips

Here are some more ways to make using the command line
easier:
 Repeat the last line you entered: Press the Up arrow
and press Enter.
37
Top AutoCAD Customization Tips

 Copy a previous command from the Text


Window: Press F2 to open the Text Window or expand the
command panel, highlight the item you want, right-click,
and choose Paste To CmdLine.
 Repeat a recent command: In the Text Window, right-
click and choose Recent Commands. Then choose the
command you want.

9. Change the color of almost any AutoCAD screen feature


A reader told me he was having
problems with his 3DCLIP command after
upgrading to AutoCAD 2013. It turned out
that it was an issue with the color of the
clipping plane. That rang a bell. Here’s what I
told him to do:

Start the OPTIONS command. You can


right-click almost anywhere and choose
Options.

The Options dialog box opens. Click the


Display tab.

Click the Colors button to open the Drawing Window Colors


dialog box. Here, you can alter the color of almost any interface item
in the AutoCAD window — making AutoCAD the most customizable

38
Top AutoCAD Customization Tips

interface I know of. The most common item to change here is the
drawing background, but you’ll find a lot more options here.

In this case, I said to choose 3D Parallel Projection (and repeat


with 3D Perspective Projection) in the Context list. Don’t forget to
choose the appropriate item in the Context box before going on.

Scroll down to the Camera Clipping Planes item. Or choose the


item you want to change.

Click the Color drop-down list and choose a color. You can
choose a standard color or click Select Color to specify any color you
want.

Click Apply & Close.

Click OK to return to your drawing.

39
Top AutoCAD Customization Tips

40
Top AutoCAD Customization Tips

Chapter 3
Linetypes and hatches

Hatches and linetypes are a hallmark of technical drawings. In this


chapter, I show you how to create custom linetypes and hatches.

10. Create a custom simple linetype


AutoCAD comes with a number of linetypes: continuous, dashed
(various lengths), dotted, dash-dot, border, center, and so on. But
you can make your own. A simple linetype is just a pattern of dashes,
dots, and spaces. (A complex linetype can include text and shapes,
but that’s another tutorial.)

To create your own simple linetype, follow these steps:

Open Notepad. A linetype file is a text file. Usually you


use Notepad to edit it.

Navigate to acad.lin. This is the default file for linetypes. By


default, you can find it the Support folder for your installation of
AutoCAD.

Choose File > Save As and save it under another name, but in
the same folder, such as mylinetypes.lin. You can edit acad.lin
directly, but be sure to back it up first.

Acad.lin looks like this:

41
Top AutoCAD Customization Tips

Scroll down to the User Defined Linetypes section at the end


of the file. After the comments, enter your linetype definition. Here is
the syntax:

A linetype has two lines of text. The first line’s syntax looks like
this:

*linetype name[, description]

42
Top AutoCAD Customization Tips

That means that the first line always starts with an asterisk (*).
Then you add the name, which can’t have spaces. The description is
optional and limited to 47 characters. If you add a description,
precede it with a comma. For example:

*proposed border,3 dashes and a dot – - – .

The second line, which defines the linetype, starts with the letter
A. You separate each item with a comma, but no spaces. The
maximum length for the second line is 80 characters. Here are your
options:

 A dash: use a positive number, indicating the length in


units

 A dot: use a 0 (zero)

 A space: use a negative number, indicating the length in


units

Press Enter after the second line and save the file. Here’s an
example:

Go back to your drawing and open the Layer Properties


Manager.

43
Top AutoCAD Customization Tips

Click the New Layer icon and name the new layer anything you
want. Assign it any color you want.

Click Continuous in the Linetype column. In the Select


Linetype dialog box, click Load.

In the Load or Reload Linetypes dialog


box, click File. Select mylinetypes.lin (or
whatever you named your file) and click
Open.

In the Load or Reload Linetypes dialog


box, choose your linetype and click OK.

In the Select Linetype dialog box,


choose your linetype and click OK to assign it
to the new layer.

Click Set Current and click OK.

Start the LINE command and use your


new linetype!

11. Creating custom hatch patterns


While AutoCAD comes with a large variety of hatch patterns, you
can also create your own. This feature has been around for many
years.

44
Top AutoCAD Customization Tips

Hatch patterns are stored in files with a file extension of .pat.


You can add your hatch to the default acad.pat or create your own
.pat file. As always, don’t forget to make a copy of acad.pat or
acadlt.pat before you edit it.

If you create your own .pat file, here are some points to
remember:
 If you aren’t adding patterns to acad.pat or acadlt.pat,
you can put only one hatch pattern in a custom .pat file;
the filename and pattern name must be the same
 You can insert comments in your .pat file after a
semicolon
 You must press Enter after the end of the last line of the
hatch definition

Note: To find the location of acad.pat or acadlt.pat, right-click


the drawing area and choose Options; then click the Files tab. Double-
click the Support File Search Path item to display the location of the
support files.

The syntax for hatch patterns is as follows:

*pattern-name[, description]

angle, x-origin,y-origin, delta-x,delta-y [, dash1, dash2, ...]

Hatch-pattern definitions have a few rules:

45
Top AutoCAD Customization Tips

 The description is optional; if you include one, precede it


with a comma.

 Add the dash specifications only for noncontinuous lines.

 You can have more than one definition line (the second
line in the syntax I just showed), creating sets of hatch
definitions that combine to create the hatch pattern.

 Each definition line can be no more than 80 characters.

 You can include a maximum of six dash specifications


(which include spaces and dots).

 You can add spaces in the definition lines for readability.

This following explains the meaning of the terms in the


definition:

Angle: Defines the angle of the lines in the hatch pattern. If


you also specify an angle in the Boundary Hatch and Gradient dialog
box when you place the hatch, AutoCAD adds the two angles.

X-origin: Specifies the X coordinate of the base point of the


hatch pattern. Your hatch probably won’t go through 0,0; however,
this point lines up sets of lines in hatch patterns, as well as aligning
hatch patterns in different areas. Because all hatch patterns are
calculated from the base point, they’re always aligned, no matter
where they actually appear in the drawing.

46
Top AutoCAD Customization Tips

Y-origin: Specifies the Y coordinate of the base point of the


hatch pattern.

Delta-x: Specifies the offset of successive lines. This applies


only to dashed lines and is measured along the direction of the lines.
Specifying a delta-x staggers each successive line by the amount that
you specify so that the dashes don’t line up.

Delta-y: Specifies the distance between lines, measured


perpendicular to the direction of the lines. This applies to both
continuous and dashed lines.

Dash: Defines a non-continuous line using the same system as


linetype definitions: positive for a dash, negative for a space, and 0
for a dot.

Let’s look at a couple of examples.

*ftrailer, proposed future trailers


105, 0,0, 0,0.5, .5,–.25,0,–.1,0,–.25

This hatch has an angle of 105 degrees, an origin of 0,0, a


delta-x of 0, a delta-y of 0.5 (the spacing between lines), and then
defines a non-continuous linetype (dash, space, dot, space, dot,
space)

47
Top AutoCAD Customization Tips

Here’s a more complex example:

*trail, whole trailers-proposed


0, 0,0, 0,2, .5,–1
90, 0,0, 0,1.5, .5,–.25,0,–.25,.5,–.5
90, .5,0, 0,1.5, .5,–.25,0,–.25,.5,–.5
0, 0,1.5, 0,2, .5,–1

This hatch pattern has 4 lines. Two are at 0 degrees, and two
are at 90 degrees. This creates the rectangular shape. The difference
between the two lines that start at 0 degrees is their origin. The
second one starts at 0,1.5. The 90-degree lines also have different
origins. The linetype for the 90-degree lines is dash, space, dot,
space, dash, space.

48
Top AutoCAD Customization Tips

See how the effect of trailers is created?

49
Top AutoCAD Customization Tips

Chapter 4
AutoLISP
AutoLISP was the original programming language that allowed you to
program AutoCAD and it's still widely used, even though there are
other options. In this chapter, I explain how to:

 Automatically load your AutoLISP routines


 Create a custom command with AutoLISP

12. Get all of your AutoLISP routines to load themselves


An easy way is to type the AutoLISP routines in a file and save it
as anything.lsp. Then choose Tools> AutoLISP> Load Application.
Browse to anything.lsp and drag it to the Startup Suite, which has an
icon of a suitcase. Then it will load whenever you start AutoCAD.

50
Top AutoCAD Customization Tips

13. Create a custom command for AutoCAD using AutoLISP


AutoLISP offers powerful programming capabilities to AutoCAD,
but you don’t need to be a programmer to use it. You can fairly easily
create a simple custom command that can make your work go more
quickly. In this tutorial, you’ll create a custom command that draws
a red circle in any location and with any radius. You could use it to
encircle areas where corrections need to be made.

Open Notepad.

Type the following:

(defun c:redcircle (/ center pt-on-circumference)


(terpri)
(setq center (getpoint “Specify center of red circle:”))
(terpri)
(setq pt-on-circumference (getpoint center “Pick a point on the
circumference:”))
(command “_circle” center pt-on-circumference)
(command “_chprop” “_last” “” “_color” “red” “”)
)

Save the file in a folder that is in your support file search path.
Name it redcircle.lsp (not .txt, the default for Notepad).

51
Top AutoCAD Customization Tips

In AutoCAD, choose
Manage tab> Applications
panel> Load Application (the
APPLOAD command) to open
the Load/Unload Applications
dialog box.

Choose redcircle.lsp and


click Load. You should see the
message redcirle.lsp
successfully loaded at the
bottom of the dialog box.

Click Close.

On the command line, type redcircle and press Enter.

At the Specify center of red circle: prompt, specify the


circle’s center.

At the Pick a point on the circumference: prompt, pick a


point on the desired circumference to specify the radius.

AutoCAD draws the circle and immediately makes it red.

52
Top AutoCAD Customization Tips

How does it work?

Here’s a line-by-line explanation:

(defun c:redcircle (/ center pt-on-


circumference): Everything in AutoLISP is enclosed in parentheses,
so you start with an open parenthesis. (You’ll close it at the very end
of the routine.) defun followed by c: creates a custom command.
Then add the name of the command. The parentheses after the
command name are for variables that you’ll define. In this case, they
are center and pt-on-circumference. The forward slash and space
just have to be there.

53
Top AutoCAD Customization Tips

(terpri): This function makes the upcoming prompt go on a


new line so it’s easy to read.

(setq center (getpoint “Specify center of red


circle:”)): The setq function means you’re defining a variable. Its
name is center. Then you need another open parenthesis for
getpoint which lets the user specify a point. After that is the prompt
in quotation marks. You can put anything you want; it should be self-
explanatory to the user. After that, you need to close both sets of
parentheses.

(setq pt-on-circumference (getpoint center “Pick a point


on the circumference:”)): Here again, you’re defining a variable,
pt-on-circumference, and getting the point from the user. The only
part that isn’t obvious is putting the center variable after getpoint. But
you need to do this to create the rubberband line from the center;
this is how AutoCAD measures the radius.

(command “_circle” center pt-on-circumference): Using


the command function accesses AutoCAD’s regular commands. The
underscore before circle allows for translation; it isn’t necessary. You
put the command name in quotation marks. Then you give AutoCAD
the information it needs to create the circle, namely the center and
radius (specified by a point on the circumference). The AutoLISP
routine applies the values you gave the variables when you picked the
2 points.

54
Top AutoCAD Customization Tips

(command “_chprop” “_last” “” “_color” “red” “”): We


now use the CHPROP command to make the circle red. The CHPROP
command is just perfect for AutoLISP routines where you want
everything to be on the command line, rather than on the ribbon or in
a dialog box. Then, you specify the last object created; this is applied
to the Select objects: prompt. The 2 empty quotation marks end
selection. Then you use the Color option and specify read as the color.
All the options go in quotation marks. The final empty quotation
marks end the command.

): This closes the first open parenthesis and ends the routine.

How do you use the routine?

Save the file with a filename extension of .lsp in a folder that’s


in AutoCAD’s support file search path. If you don’t know how to load
an AutoLISP file, see “How to load an AutoLISP program” and
“How to load an AutoLISP program quickly.” Then just type the
name of the command you created (in this example it’s REDCIRCLE)
on the command line.

What else can you create? Try using what you just learned to
create an AutoLISP routine that draws a blue line.

55
Top AutoCAD Customization Tips

Chapter 5
Miscellaneous
Some aspects of customization are not easily categorized. In this
chapter, I explain how to:
 Create a custom function in the calculator
 Share tool palettes with colleagues

14. Create a custom function in AutoCAD’s calculator


AutoCAD calculator (the QUICKCALC command) is a great
feature for both simple and complex calculations. One of the great
features is the ability to calculate coordinates.

QuickCalc has variables (or functions) that are shortcuts to


some of the more complex coordinate calculations. To use these
functions, follow these steps:

1. Start a command.

2. At the prompt where you need the function,


type ‘quickcalc (or ‘qc). The QuickCalc window opens.

3. From the Variables list, double-click the function that you


want to place it in the Input box of the QuickCalc window.

4. Press Enter. You return to your drawing and see a pickbox


cursor.

5. Pick the required points, most commonly by object


snaps. The QuickCalc window returns, and you see an
absolute coordinate in theInput box.
56
Top AutoCAD Customization Tips

6. Click the Apply button.

7. Continue the command.

For example, let’s say I have a rectangle and I want to start a


line at its center, defined as the intersection of the two diagonal lines
drawn from opposite corners. Here’s one way to do that:

1. Start the LINE command.

2. At the Specify first point: prompt, type ‘qc.

3. From the Variables list (you might have to


expand the QuickCalc window to see it; then
expand the Variables category), double-click ille.

4. Press Enter. You return to your drawing with a large


pickbox.

5. Pick the first set of diagonal points, such as the upper-left,


then the lower-right corners of the rectangle.

6. Pick the second set of diagonal points, such as the upper-


right, then the lower-left corners of the rectangle.

7. Click the Apply button in the QuickCalc window.

Your line’s start point is now set at the center of the rectangle
and you can continue the command.

57
Top AutoCAD Customization Tips

Create a custom function

When you click a function, you see a tooltip giving you the full
format of the function. You can use this format to create your
own functions. For example, mee (midpoint between two endpoints)
is (end+end)/2. So, to find the midpoint between two nodes (rather
than two endpoints), you would use (nod+nod)/2.

58
Top AutoCAD Customization Tips

To save your custom function, click the New Variable button


at the top of the Variables section. The Variable Definition dialog box
opens, where you can define and save the variable.

Then, your custom variable appears on the list and you can use
it like one of the variables that come with AutoCAD. You can
see mnn at the very bottom of the list.

59
Top AutoCAD Customization Tips

How cool is that? (Done in AutoCAD 2011)

60
Top AutoCAD Customization Tips

15. Easily share tool palettes with colleagues


Tool palettes can be a great place to store blocks, custom
commands, and more. For example, in this post, I explain how to
use tool palettes for blocks. And here I explain how to use tool
palettes for user-defined hatches.

But what if you want to share them with others? You can share
tool palettes by exporting them to a file. Then others import the same
file to access the tool palettes.

Export a tool palette or group to a file

Follow these steps to export a tool palette (or group) to a file:

61
Top AutoCAD Customization Tips

Choose Manage tab> Customization panel> Tool Palettes (the


CUSTOMIZE command) to open the Customize dialog box. Note that
each tab in the Tool Palettes window is a separate tool palette.

Right click a tool palette or group and choose Export from the
menu. To export all palette groups, right-click a palette group and
choose Export All.

In the Export Palette or Export Group dialog box, choose a


location for the file. A tool palette will be an XTP file and a palette
group will be an XPG file.

Click Save.

Import a tool palette or group from a file

If someone gives you a tool


palette file (XTP or XPG), here
are the steps to import it:

Choose Manage tab>


Customization panel> Tool Palettes
(the CUSTOMIZE command) to
open the Customize dialog box.

Right-click any palette from


the left side of the dialog box and
choose Import.

62
Top AutoCAD Customization Tips

Select the XTP or XPG file and choose


Open to display the tool palette.

Here you see the custom tool palette that I


imported.

Note: There’s more important information


on the next page!

63
Top AutoCAD Customization Tips

Sign up to get the free AutoCAD Tips Newsletter!


Stay informed and get a free tutorial on dynamic blocks.

SUBSCRIBE

Don’t miss!
Top 25 Productivity Tips Every AutoCAD
User Should Know

This 50+ page e-book will make your drawing


and editing go more smoothly and quickly.
Learn from AutoCAD expert Ellen Finkelstein,
with the help of submitted tips from many
others around the world.

Some examples:

 The 4 ways to import text


 Find a list of all named objects in your
drawing
 Print a list of text styles
 Secret MText options
 And much more!

Only $9.95!

GET IT NOW!

64

You might also like