Adds commands to the AutoCAD built-in command set
(vlax-add-cmd global-name func-sym [local-name cmd-flags])
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.
Withvlax-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.
Thevlax-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.
Thevlax-add-cmd function from a separate-namespace VLX. You should then explicitly load the VLX using the APPLOAD command, rather than by placing it in one of the startup LISP files.
It is recommended that you use theArguments
A string.
A symbol naming an AutoLISP function with zero arguments.
A string (defaults to global-name).
An integer (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.
Return Values
nil if acedRegCmds->addCommand(...) returns an error condition.
The global-name argument, if successful. The function returnsExamples
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:
The_$ (defun hello-autocad () (princ "hello Visual LISP"))
HELLO-AUTOCAD
_$ (vlax-add-cmd "hello-autocad" 'hello-autocad)
"hello-autocad"
vlax-remove-cmd function.
The