Using AutoLISP, external commands, and the alias feature, you can define your own AutoCAD commands. You can use the UNDEFINE command to redefine a built-in AutoCAD command with a user-defined command of the same name. To restore the built-in definition of a command, use the REDEFINE command. The UNDEFINE command is in effect for the current editing session only.
command function.
You can always activate an undefined command by specifying its true name, which is the command name prefixed by a period. For example, if you undefine QUIT, you can still access the command by entering .quit at the AutoCAD Command prompt. This is also the syntax that should be used within the AutoLISPC:LINE to substitute for the normalLINEcommand as follows:
Consider the following example. Whenever you use the LINE command, you want AutoCAD to remind you about using the PLINE command. You can define the AutoLISP function_$ (defun C:LINE ( )
(_> (princ "Shouldn't you be using PLINE?\n")
(_> (command ".LINE") (princ) )
C:LINE
C:LINE is designed to issue its message and then to execute the normal LINE command (using its true name, .LINE). Before AutoCAD will use your new definition for the LINE command, you must undefine the built-in LINE command. Enter the following to undefine the built-in LINE command:
In this example, the function_$ (command "undefine" "line")
C:LINE AutoLISP function:
Now, if you enter line at the AutoCAD Command prompt, AutoCAD uses theCommand: line
Shouldn't you be using PLINE?
.LINE Specify first point: Specify first point:
command function call. The following code uses the CMDECHO system variable to prevent the LINE command prompt from repeating:
The previous code example assumes the CMDECHO system variable is set to 1 (On). If CMDECHO is set to 0 (Off), AutoCAD does not echo prompts during a_$ (defun C:LINE ( / cmdsave )
(_> (setq cmdsave (getvar "cmdecho"))
(_> (setvar "cmdecho" 0)
(_> (princ "Shouldn't you be using PLINE?\n")
(_> (command ".LINE")
(_> (setvar "cmdecho" cmdsave)
(_> (princ) )
C:LINE
line at the AutoCAD Command prompt, the following text is displayed:
Now if you enterShouldn't you be using PLINE?
Specify first point:
You can use this feature in a drawing management system, for example. You can redefine the NEW, OPEN, and QUIT commands to write billing information to a log file before you terminate the editing session.
It is recommended that you protect your menus, scripts, and AutoLISP programs by using the period-prefixed forms of all commands. This ensures that your applications use the built-in command definitions rather than a redefined command.
See the Overview of File Organization topic in the AutoCAD Customization Guide for a description of the steps AutoCAD takes to evaluate command names.