Pause for User Input in Macros (Concept)

AutoCAD

 
Pause for User Input in Macros
Concept Quick Reference
 
 
 

To accept input from the keyboard or pointing device in the middle of a command, place a backslash (\) in the macro at the point where you want input.

circle \1 

In the circle example, \1 pauses for the user to specify the center point and then reads a radius of 1. Note that there is no space after the backslash.

-layer off \; 

In this example, the macro starts LAYER at the command prompt (-layer), enters the Off option (off), and then pauses for the user to enter a layer name (\). The macro then turns that layer off and exits the LAYER command (;).

NoteLAYER normally prompts for another operation and exits only if you press SPACEBAR or ENTER. In the macro, the semicolon (;) is the equivalent of pressing ENTER.

A macro typically resumes after one user input, such as a single point location. Therefore, you cannot construct a macro that accepts a variable number of inputs (as in object selection) and then continues. However, an exception is made for SELECT: a backslash (\) suspends the SELECT command until object selection has been completed. Consider the following example:

select \change previous ;properties color red ; 

In this macro, SELECT creates a selection set of one or more objects (select \). The macro then starts CHANGE (change), references the selection set using the Previous option (previous;), and changes the color of all selected objects to red (properties color red ;).

NoteThe backslash character (\) causes a macro to pause for user input. You cannot use a backslash for any other purpose in a macro. When you need to specify a file directory path, use a forward slash (/) as the path delimiter: for example, /direct/file.

The following circumstances delay resumption of a macro after a pause:

  • If input of a point location is expected, object snap modes may be used before the point is specified.
  • If X/Y/Z point filters are used, the command remains suspended until the entire point has been accumulated.
  • For SELECT only, the macro does not resume until object selection has been completed.
  • If the user responds with a transparent command, the suspended macro remains suspended until the transparent command is completed and the originally requested input is received.
  • If the user responds by choosing another command (to supply options or to execute a transparent command), the original macro is suspended, and the newly selected item is processed to completion. Then, the suspended macro is resumed.
NoteWhen command input comes from a command, the settings of the PICKADD and PICKAUTO system variables are assumed to be 1 and 0, respectively. This preserves compatibility with previous releases of AutoCAD and makes customization easier because you are not required to check the settings of these variables.