Adds commands to the AutoCAD built-in command set
Supported Platforms: Windows only
(vlax-add-cmd global-name func-sym [local-name cmd-flags])
Type: String
The global name for the command.
Type: Subroutine or Symbol
A symbol naming an AutoLISP function with zero arguments.
Type: String
A local name for the command (defaults to global-name).
Type: Integer
A numeric value (defaults to ACRX_CMD_MODAL + ACRX_CMD_REDRAW)
The primary flags are
ACRX_CMD_MODAL (0) -- Command cannot be invoked while another command is active.
ACRX_CMD_TRANSPARENT (1) -- Command can be invoked while another command is active.
The secondary flags are
ACRX_CMD_USEPICKSET (2) -- When the pickfirst set is retrieved it is cleared within AutoCAD. Command will be able to retrieve the pickfirst set. Command cannot retrieve or set grips.
ACRX_CMD_REDRAW (4) -- When the pickfirst set or grip set is retrieved, neither will be cleared within AutoCAD. Command can retrieve the pickfirst set and the grip set.
If both ACRX_CMD_USEPICKSET and ACRX_CMD_REDRAW are set, the effect is the same as if just ACRX_CMD_REDRAW is set. For more information about the flags, see the “Command Stack” in the ObjectARX Reference.
Type: String or nil
The global-name argument, if successful. The function returns nil if acedRegCmds->addCommand(...) returns an error condition.
With vlax-add-cmd you can define a function as an AutoCAD command, without using the c: prefix in the function name. You can also define a transparent AutoLISP command, which is not possible with a c: function.
The vlax-add-cmd function makes an AutoLISP function visible as an ObjectARX-style command at the AutoCAD Command prompt during the current AutoCAD session. The function provides access to the ObjectARX acedRegCmds macro, which provides a pointer to the ObjectARX system AcEdCommandStack object.
The vlax-add-cmd function automatically assigns commands to command groups. When issued from a document namespace, vlax-add-cmd adds the command to a group named doc-ID; doc-ID is a hexadecimal value identifying the document. If issued from a separate-namespace VLX, vlax-add-cmd adds the command to a group named VLC-Ddoc-ID:VLX-name, where VLX-name is the name of the application that issued vlax-add-cmd.
It is recommended that you use the vlax-add-cmd function from a separate-namespace VLX. You should then explicitly load the VLX using the AutoCAD APPLOAD command, rather than by placing it in one of the startup LISP files.
The hello-autocad function in the following example has no c: prefix, but vlax-add-cmd makes it visible as an ObjectARX-style command at the AutoCAD Command prompt:
(defun hello-autocad () (princ "hello Visual LISP")) HELLO-AUTOCAD (vlax-add-cmd "hello-autocad" 'hello-autocad) "hello-autocad"