vlax-add-cmd
 
 
 

Adds commands to the AutoCAD built-in command set

(vlax-add-cmd global-name func-sym [local-name cmd-flags])

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.

WarningYou cannot use the command function call in a transparently defined vlax-add-cmd function. Doing so can cause AutoCAD to close unexpectedly.

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 APPLOAD command, rather than by placing it in one of the startup LISP files.

NoteYou cannot use vlax-add-cmd to expose functions that create reactor objects or serve as reactor callbacks.

Arguments

global-name

A string.

func-sym

A symbol naming an AutoLISP function with zero arguments.

local-name

A string (defaults to global-name).

cmd-flags

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

The global-name argument, if successful. The function returns nil if acedRegCmds->addCommand(...) returns an error condition.

Examples

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"
See Also