Executes an AutoCAD command
(command [arguments] ...)
Arguments
AutoCAD commands and their options.
command function can be strings, reals, integers, or points, as expected by the prompt sequence of the executed command. A null string ("") is equivalent to pressing ENTER on the keyboard. Invoking command with no argument is equivalent to pressing ESC and cancels most AutoCAD commands.
The arguments to thecommand function evaluates each argument and sends it to AutoCAD in response to successive prompts. It submits command names and options as strings, 2D points as lists of two reals, and 3D points as lists of three reals. AutoCAD recognizes command names only when it issues a Command prompt.
Thecommand from Visual LISP, focus does not change to the AutoCAD window. If the command requires user input, you'll see the return value (nil) in the Console window, but AutoCAD will be waiting for input. You must manually activate the AutoCAD window and respond to the prompts. Until you do so, any subsequent commands will fail.
Note that if you issueReturn Values
nil
Examples
pt1 and pt2 equal to two point values 1,1 and 1,5. It then uses the command function to issue the LINE command in the Command Reference and pass the two point values.
The following example sets two variablesCommand: (setq pt1 '(1 1) pt2 '(1 5))
(1 5)
Command: (command "line" pt1 pt2 "")
line From point:
To point:
To point:
Command: nil
Restrictions and Notes
command function. If the SCRIPT command is used with the command function, it should be the last function call in the AutoLISP routine.
The AutoCAD SKETCH command in the Command Reference reads the digitizer directly and therefore cannot be used with the AutoLISPcommand function in an acad.lsp or .mnl file, it should be called only from within a defun statement. Use the S::STARTUP function to define commands that need to be issued immediately when you begin a drawing session.
Also, if you use theentsel instead of a point to select the object. For examples, see Passing Pick Points to AutoCAD Commands in the AutoLISP Developer's Guide.
For AutoCAD commands that require the selection of an object (like the BREAK and TRIM commands in the Command Reference), you can supply a list obtained withcommand function are not echoed to the command line if the CMDECHO system variable (accessible from setvar and getvar) is set to 0.
Commands executed from thevl-cmdf function. The Command Submission in the AutoLISP Developer's Guide.
The