Executes an AutoCAD command
Arguments
(vl-cmdf [arguments] ...)
vl-cmdf function is similar to the command function, but differs from command in the way it evaluates the arguments passed to it. The vl-cmdf function evaluates all the supplied arguments before executing the AutoCAD command, and will not execute the AutoCAD command if it detects an error during argument evaluation. In contrast, the command function passes each argument in turn to AutoCAD, so the command may be partially executed before an error is detected.
Thevl-cmdf executes the call before it executes your command, while command executes the call after it begins executing your command.
If your command call includes a call to another function,vl-cmdf, while failing when invoked through command. The vl-cmdf function mainly overcomes the limitation of not being able to use get.xxx functions inside command.
Some AutoCAD commands may work correctly when invoked throughArguments
AutoCAD commands and their options.
vl-cmdf 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 vl-cmdf with no argument is equivalent to pressing ESC and cancels most AutoCAD commands.
The arguments to theReturn Values
T
vl-cmdf from Visual LISP, focus does not change to the AutoCAD window. If the command requires user input, you'll see the return value (T) 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 issueExamples
command and vl-cmdf are easier to see if you enter the following calls at the AutoCAD Command prompt, rather than the VLISP Console prompt:
The differences betweenCommand: (command "line" (getpoint "point?") '(0 0) "")
line Specify first point: point?
Specify next point or [Undo]:
Command: nil
command, the LINE command executes first; then the getpoint function is called.
UsingCommand: (VL-CMDF "line" (getpoint "point?") '(0 0) "")
point?line Specify first point:
Specify next point or [Undo]:
Command: T
vl-cmdf, the getpoint function is called first (notice the “point?” prompt from getpoint); then the LINE command executes.
UsingThe following examples show the same commands, but pass an invalid point list argument to the LINE command. Notice how the results differ:
Command: (command "line" (getpoint "point?") '(0) "")
line Specify first point: point?
Specify next point or [Undo]:
Command: ERASE nil
Select objects: Specify opposite corner: *Cancel*
0 found
command function passes each argument in turn to AutoCAD, without evaluating the argument, so the invalid point list is undetected.
TheCommand: (VL-CMDF "line" (getpoint "point?") '(0) "")
point?Application ERROR: Invalid entity/point list.
nil
vl-cmdf evaluates each argument before passing the command to AutoCAD, the invalid point list is detected and the command is not executed.
Becausecommand function.
The