About Command Macros

About Command Macros

Command macros can contain commands, special characters, DIESEL expressions, or AutoLISP
programming code.

You can define and then assign a macro to a command by modifying the Macro property
of a command in the Customize User Interface Editor (Windows) or the Customize dialog
box (Mac OS).

NOTE:AutoLISP is not supported in AutoCAD LT.

Macro Basics

A macro defines the action that should be performed when a user interface element
is used. It can be as simple as a command (such as circle) and include special characters
(such as ^C^C).

For example, the macro ^C^C_.circle 1, draws a circle with a radius of 1 unit. The components that define this macro are
explained in the following table.

Components in CIRCLE macro


Component type



Special control character sequence

Sequence that is similar to pressing the Esc key twice.


Special control character

Indicates the command that follows should use the global command name and not the
localized command name.


Special control character

Indicates the command that follows should use the standard definition of the command,
and not the redefined command that might exist.


Command name

Starts the CIRCLE command.


Special character

A space is like pressing the Spacebar while using a command.

Special control character

Creates a pause for user input; in this example it is a pause for the center point
of the circle.


Input value

Response to the prompt for the radius of the circle; in this example it is a unit
of 1.

Cancel the Active Command

When a button in the user interface is clicked, the macro assigned to it is executed
in the current context of the program. This means that the macro will attempt to provide
responses to the current prompt. If you want to make sure that no command is currently
active when the macro is executed, prefix your macro with the ^C command sequence. Although a single ^C cancels most commands, ^C^C is required to return to the command prompt from a dimensioning command and ^C^C^C is required based on the current option of the -LAYER command. ^C^C handles canceling out of most command sequences and is the recommended sequence to

Verify Macro Characters

Every character in a macro has a significant meaning, even a blank space. When you
place a space at the end of the macro, it is interpreted as if you had pressed the
Spacebar or Enter to complete the command.

Use Standard Commands in Macros

Commands that are part of AutoCAD or AutoCAD-based products should be prefixed with
a period character (.). The period character allows the standard command to be used
even if it has been undefined with the UNDEFINE command. This precaution makes the
macro predicable when it is used on other computers that share the same customization
(CUI/CUIx) file.

NOTE:Commands cannot be undefined in AutoCAD LT.

International Support for Macros

When you first create a macro, you commonly create it using the command names and
option values in the language you are familiar with. Each command and option has a
local and global name to allow your macros to be used on all of the different languages
that AutoCAD supports. Non-English support does not require much additional work on
your part, you precede each command or option with the underscore character (_). The
underscore character signals to AutoCAD that the command name or option value should
be translated before the it is executed.

Use Single Object Selection Mode

Single Object Selection mode cancels the normal repetition of the Select Objects prompt
in editing commands. After you select one object and respond to any other prompts,
the command ends.

Consider the macro in the following example:

^C^C._erase single 

This macro terminates the current command and starts the ERASE command in Single Object
Selection mode. After the macro is started, you can either select a single object,
or click a blank area in the drawing and specify window/crossing selection. Any objects
selected using these methods are erased.

Repeat Commands in Macros

Once you have created a macro, you might want to repeat it several times before moving
to a different command. In a macro, use a leading asterisk (*) to indicate that the
command in a macro should be repeated until you press Esc or start another macro that
begins with ^C.

The macros in the following examples repeat the commands:

*^C^C._move Single 
*^C^C._copy Single 
*^C^C._erase Single 
*^C^C._stretch Single Crossing 
*^C^C._rotate Single 
*^C^C._scale Single 
NOTE:You cannot use this feature to choose options, or for macros in image tile menus.

Terminate Macros

Some macros require special terminators. For example, the TEXT command requires you
to press Enter rather than Spacebar to terminate the command and some commands require
more than one press of the Spacebar or Enter to complete.

Two special conventions resolve these problems.

  • A semicolon (;) in a macro is equivalent to pressing Enter.
  • If a line ends with a control character, a backslash () or a semicolon (;), a blank
    space is not added after it.

Compare the following macros:

ucs ;

The first example starts the UCS command and, because the line ends with a space,
the pressing of the Spacebar is simulated. The following prompt is displayed:

Specify origin of UCS or [Face/NAmed/OBject/Previous/View/World/X/Y/Z/ZAxis] <World:

The second example starts the UCS command, simulates the pressing of the Spacebar,
and then a press of the Enter is simulated which accepts the default value (World).

Suppress Echoes and Prompts in Macros

Characters in a macro appear at the Command prompt as though you had typed the characters
from the keyboard. This display duplication is called echoing. You can suppress macro echoing with the MENUECHO system variable. If echoes and
prompts from item input are turned on, a ^P in front of the macro will temporarily turn them off. You can also use ^Q in a macro to suppresses the display of all prompts and input from the Command Line

Learning AutoCad

>Command macros can contain commands, special characters, DIESEL expressions, or AutoLISP programming code. You can define and then assign a macro to …commands and options into repeatable macros that perform complex … This handout involves a lot of command-line input, so it's important to  …Macro Commands Equivalent to clicking with the wand tool at location x,y . The outline was successfully created if GetRoi …command macros. They are evaluated when the macro is executed. A command function included in a macro increases the …Macros. One of the main features that make Nagios so flexible is the ability to use macros in command defintions. Macros allow you to reference information from …command requires two arguments: the name of the … macros — invalid characters will error out at compile-time.command has this macro: "^C^C_copy 0,0 0,0" "^C" is cancel or the equivalent of pressing the Esc key. Always start your command with two …command history, macro functionality, and improved editing features to the command line …commands available for use in the WoW chat window, and as WoW macro commands in a macro. This list …commands and syntax can be used in macros or typed directly into the command window. Use with caution – some commands are better left out of …