Defining Command Aliases In the last few tips sheets, I discussed how to create toolbars and toolbar buttons. For users who to use the keyboard, I will outline the steps needed to create Command Aliases. A Command Alias is an abbreviation of an AutoCAD command. For instance, E is the abbreviation for Erase.
Command Aliases are defined in the AutoCAD Program Parameter file (ACAD.PGP). When you enter a command that isn't a normal command, AutoCAD searches the ACAD.PGP file. The ACAD.PGP file is normally found in the AutoCAD Support folder.
The ACAD.PGP file is divided into two sections. The first defines external commands, the second the command aliases. An example of an external command is Explorer, this command would begin Windows Explorer.
If you're not sure where AutoCAD is loaded, then the easiest way to locate it is to go to the Windows 'Start' button then to 'Find' (or 'Search') and 'Files or Folders'. In the 'Named:' area type ACAD.PGP and click the 'Find Now' button. Make sure to search the entire drive containing the AutoCAD program.
Once you've located the ACAD.PGP file, simply double-click on the file. This will launch Notepad and open the ACAD.PGP for editing. (Note: It would probably be a good idea to make a back up of the file before making changes).
The format of a command alias is <Alias>,*<Full command name>. Below, you'll see a few of the aliases already defined in the ACAD.PGP file.
- (Hyphen): Uses the command line version of the command. ; (Semicolon): Comment, not evaluated by AutoCAD.
If you can use a command transparently (zoom), you can use an alias transparently by preceding the alias with an apostrophe. Example 'LT will execute the Linetype command transparently.
You cannot include command options in an alias. For example, you can not make an alias for Zoom Previous.
External Commands In addition to defining Command Aliases, you can use the ACAD.PGP file to define External Commands. An External Command can be a Windows system command (like DIR), an application (like NOTEPAD) or a user define program (like a BATCH file).
Similar to defining a Command Alias, you must supply a command name to be used at the Command prompt. The format of an External Command is <Command name>,[<Executable>],<Bit flag>,[*]<Prompt>.
Command - Name entered at AutoCAD command line. Executable - The command sent to the operating system (OS). This can be any command that you can use at the OS prompt and can include switches and parameters. Flags - A required parameter. The integer values can be added together to achieve the desired result.
0 Start the application and wait for it to finish. 1 Don't wait for the application to finish. 2 Run the application minimized. 4 Run the application "hidden." 8 Put the argument string in quotes.
Prompt - This optional field specified the prompt to display on the AutoCAD command line. If the first character is an asterisk (*), the user response can contain spaces.
Below are the external commands for the command window.
CATALOG, DIR /W, 8,File specification: , DEL, DEL, 8,File to delete: , DIR, DIR, 8,File specification: , EDIT, START EDIT, 9,File to edit: , SH, , 1,*OS Command: , SHELL, , 1,*OS Command: , START, START, 1,*Application to start: , TYPE, TYPE, 8,File to list: ,
The code below illustrates external commands for windows. EXPLORER, START EXPLORER, 1,, NOTEPAD, START NOTEPAD, 1,*File to edit: , PBRUSH, START PBRUSH, 1,,
If you wanted to add an external command to edit the ACAD.PGP file, you could add something like this…
This code string would start Notepad and open the ACAD.PGP file.
If you modify the ACAD.PGP file while AutoCAD is open, you will need to use the Reinit to reinitialize the file. It is only initialized when AutoCAD is started. Hint: Create a custom toolbar button that calls the PGP command followed by the Reinit command.