Create Your Own AutoCAD Commands (Circles and Lines AutoCAD Tutorial)

1 Mar, 2008 By: Lynn Allen

Customizing commands in AutoCAD helps to reduce tedious repetition.

Sitting on a plane on my way to a presentation on "60 AutoCAD Tips in 60 Minutes," I found myself once again focused on the topic of customization. We all have different likes and dislikes -- things we love about AutoCAD and things we loathe. Above all, I believe it is important to learn to customize your AutoCAD environment to suit your particular needs. You don't have to be Einstein to customize AutoCAD. You just have to find some spare time. (For some of us, it would be easier to become Einstein.)

This much I promise you: If you spend the time customizing your system up front, you will be richly rewarded with time on your hands later! So, yes, you will need to sacrifice some time to reap the rewards. And I'm not just talking about saved time here; I'm talking about removing the tedium in your everyday drawing life, which leads to less stress, which leads to living happily ever after. (OK, that's a bit of a stretch.)

This month I'm going to expand on what I've covered so far in the customizable user interface (CUI) by describing how to create custom commands. You can use these commands in your pull-down menus, toolbars, and dashboard -- you name it! You don't have to be a programmer to write your own commands; you just need to know the top-secret codes. And although I don't have a decoder ring I can mail to you, this article contains most of what you need to become a customization guru and delight your coworkers with custom commands. What I need from you is simple -- you need to know what you need. What would really save you time? What commands are you using over and over throughout the day, with specific options and with specific values? What drives you crazy in AutoCAD? You can't solve your customization needs unless you know what those needs are! So take a minute, sit back, think, and write a list of repetitive things you are currently doing in AutoCAD that you wish you could automate.

Now onto the details.

The lower left corner of the CUI command contains the Command List section. Here you will find the new Create a New Command button.

Select the Create a New Command button to create a custom command.

After selecting this button, click on Properties in the lower right side of the CUI dialog box.

Use the Properties panel in the CUI to configure the command name, description, and macro.

You can input the name of your new custom command, a description (the tooltip), and the macro you want to assign to the command. You can also indicate the small and large images you would like to assign to your new command. (I wrote about images in last month's column.) In my example, I called my new command A Bad Day, gave it the tooltip of "Use when things go terribly wrong," and a macro that performs an Erase All.

I doubt that you will have any problems assigning a command name or an appropriate description (tooltip), but creating a macro can be a bit tricky. Here you will need to learn some of the codes necessary to create awesome macros.

You will see the following code at the beginning of most existing AutoCAD macros:


Each ^C stands for Cancel, and it is equivalent to hitting the Escape key one time. You know how important it is to be at the Command prompt before executing an AutoCAD command, so consequently you find yourself hitting the Escape key at least once (probably twice for good measure). When creating your own custom commands, you need to follow the same process. The ^C^C is equivalent to hitting the Escape key two times to make absolutely sure you are out of any commands and ready to go. Incidentally, some commands require two Escapes to get completely out, and that's why we use two. I've even seen some over-the-top customizers use three (which is definitely not necessary).

After the ^C^C you'll input the name of the command you want to execute.


would cancel you out of any existing command and then execute the Line command


would cancel you out of any existing command and then execute the Circle command.

The case doesn't matter -- you can use either upper case or lower case for any of the characters.

The next code you need to know about is the semicolon. In a macro the semicolon (;) is used to do an Enter.



is equal to Escape, Escape, Circle, Enter, 3P.

My macro of


is equal to Escape, Escape, Erase, Enter, All, Enter, Enter.

Since I needed to force two Enters at the end of my macro to get completely out of the Erase command, I spelled them out with two semicolons.

Note: AutoCAD will automatically do an Enter at the end of any macro that doesn't end in \ or ;

The last of the crucial codes to know is the backslash. You will use this when you want to pause for user input. You might choose to pause for user input to allow the selection of a point on the screen, height, rotation angle, block name, etc.


This would execute the Insert command, Enter, Pulley (for block name), pause (for insertion point), 2 (x scale factor of 2), 2 (y scale factor of 2), and pause for rotation angle.

That is a pretty complex one; if you followed that at all, you are getting it!

Note: When creating macros you often need to force the Command prompt interface for a command rather than the dialog box. This is done by putting a dash in front of the command like –Insert or –Layer.

Let's look at a command that draws a square.


This would run as Escape, Escape, Polygon command, Enter, 4 (number of sides), Enter, E (for Edge), pause, pause.

If the command is a transparent command such as Zoom or Pan, you won't need to start the command with a ^C^C. You'll want to use an apostrophe just like you would while drawing in AutoCAD.


You can use many more codes in your macros, but these are the key ones to know. One of my favorite codes is the *. If you place this in front of your macro, it will repeat your macro over and over (including all the options) until you Escape to terminate it. For example, you could draw a dozen of 2P circles of varying sizes quickly and easily. If you want to learn more about the various macro codes, you can find them in the AutoCAD Customization Guide, part of the online Help system.

After you've written a few custom commands, you then can drag them to the Dashboard, to a pull-down menu, a toolbar, a key on your keyboard, etc. The possibilities are endless! So think about those tasks you are doing over and over again throughout your day and set your sights on automating them. Not only will you save yourself time, you will eliminate those mundane and tedious tasks we all dislike doing in AutoCAD.

Until next month, happy AutoCADing!

AutoCAD Tips!

Lynn Allen

Autodesk Technical Evangelist Lynn Allen guides you through a different AutoCAD feature in every edition of her popular "Circles and Lines" tutorial series. For even more AutoCAD how-to, check out Lynn's quick tips in the Cadalyst Video Gallery. Subscribe to Cadalyst's free Tips & Tools Weekly e-newsletter and we'll notify you every time a new video tip is published. All exclusively from Cadalyst!
Follow Lynn on Twitter Follow Lynn on Twitter

At your company, who has the most say in CAD-related software purchasing?
CAD manager
CAD users
IT personnel
vice-president/department manager
CEO/company owner
Submit Vote