|
|
|
If you want to change or extend the behavior of a standard AutoCAD command, you can use several methods. Let's take an example of UNISOLATEOBJECTS (unisolate objects). We want AutoCAD to regenerate the active viewport after the isolation is lifted. We can use one of the following methods:
- Menu editing.
If you usually invoke the command from menu or from a ribbon or via a keyboard shortcut, just modify its definition in the menu (the CUI command) - e.g., instead of calling ^C^C_unisolateobjects here, use and save the user menu macro ^C^C_unisolateobjects;_regen
- Redefinition.
Using the _UNDEFINE command, you can "unlearn" an internal AutoCAD command and replace its behavior with a custom command definition of the same name. You can provide the redefinition using, for example, a LISP macro. Add a command redefinition function to an automatically loaded .LSP file (e.g. ACADDOC.LSP):
(command "_UNDEFINE" "_UNISOLATEOBJECTS")
(defun C:UNISOLATEOBJECTS()
(command "._UNISOLATEOBJECTS")
(princ " and regen")
(command "_REGEN")
(princ)
)
- Reactor.
A reactor is a way to add automatic responses to an event in AutoCAD. This can be, for example, a command completion event (commandEnded). Again, add the following reactor definition to any .LSP file you load automatically:
(vl-load-com)
(defun MY_Unisolate (reac com)
(if (wcmatch (strcase (car com)) "UNISOLATE*")
(vla-regen (vla-get-activedocument (vlax-get-acad-object)) acActiveViewport)
)
)
(setq *UNISOReactor
(vlr-command-reactor
"Unisolate reactor"
'((:vlr-commandEnded . MY_Unisolate)))
)
)
You can also use the first option in AutoCAD LT. The second one can be used also in AutoCAD Web.
|
|
ACADACLTADTACADMPlantMapCivil3D
|
* CAD
|
8.11.2022
25125×
|
|
|