Executes an AutoCAD command
(command [arguments ...])
The arguments to the 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 command 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.
Note that if you issue command from Visual LISP on Windows, 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.
The AutoCAD SKETCH command reads the digitizer directly and therefore cannot be used with the AutoLISP command function. If the AutoCAD SCRIPT command is used with the command function, it should be the last function call in the AutoLISP routine.
Also, if you use the command function in an .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.
With the introduction of the Action Recorder in AutoCAD 2009, commands were given versions. Commands used at the Command prompt always use the latest version of the specific command. However, commands used in AutoLISP and command macros might work differently. The initcommandversion function is used to determine the version of the next command to be executed.