Make Your Own Commands In AutoCAD

In AutoCAD Tips, command alias, macro, pgp by Mark

While nearly all AutoCAD functions are easily accessible by mouse, a lot of people prefer using keyboard commands as they find them quicker. Unfortunately most keyboard commands are quite long and / or not that memorable. You can however create shortcuts for commands like AS for Add Selected, SS for Select Similar or any other command you use frequently. We will be discussing two different ways of making custom commands. Use whichever you find more convenient for you.

Add command aliases in ACAD.PGP / ACADLT.PGP* file

*acadlt.pgp is for AutoCAD LT versions

1.    Go to the Manage tab in ribbon.

2.    In the Customization section, select Edit Aliases or use command “AI_EDITCUSTFILE”, write “acad.pgp” / “acadlt.pgp” and press enter

AutoCAD edit aliases

3.    This should open up your acad.pgp / acadlt.pgp file in a text editor which by default in most cases is Notepad:

AutoCAD pgp in text editor

4.    Scroll down the text editor and you’ll see a complete list of existing command aliases. All the ones you see are those set by default and most are very useful and will help speed things up. So before you go about making custom command aliases, browse the list and you may find what you need already exists.

It is highly recommended you do not make any changes to this default list. Doing so will make upgrading to newer versions of AutoCAD very problematic.

5.    Instead scroll down to User Defined Command Aliases section and here you can create new aliases of your choice. If a command alias appears twice in this file then the one in the User Defined section takes precedence over the other. Which means any alias you enter for any command will override the default set alias.

User Defined AutoCAD command aliases

6.    To add a new command simply enter the command alias in a new line followed by a [,], space(s) and then [*] and the command name. See image below:

image

7.    To confirm changes, save your acad.pgp file and close it.

8.    You will need to restart AutoCAD before the changes take effect or you can use “REINT” command to reload acad.pgp / acadlt.pgp without restarting AutoCAD.

Alternatively, if you’ve had express tools installed you can use the tool Command Alias Editor to directly make changes to the acad.pgp / acadlt.pgp file without having to open it.

1.    Go to Express Tools ribbon and then select Command Aliases. See image below:

Command Aliases in Express Tools

This’ll open a window where you can edit or add command aliases:

Add command in Command Aliases Tool

2.    Scroll the list and search for the command you want an alias for. If the command isn’t listed look for the alias you wish to make.

3.    If neither is listed then select Add. This will open up a new window:

image

4.    Here type in the alias of your choice. Scroll the list to find the command you want or type it in the box. Typing part of the name will automatically reduce the list for you, allowing you to choose the command.

5.    Your new command will now be a part of the original list once you press OK:

image

You can also use the Edit button to change an existing command in the same way but this is not recommended due to the upgrade issues mentioned earlier.

6.    Once you hit Apply the changes will be saved. You may have to restart AutoCAD before changes take effect or you can use “REINT” command to reload acad.pgp without restarting AutoCAD.

image

7.    Now that your new commands are ready, go ahead and try them out in the command line.

Create command using AutoCAD CUI (AutoCAD Custom User Interface)

Customized User Interface” dialogue box can be opened by three methods:

  • Type CUI at the command line window
  • In the Ribbon go to Manage and then User Interface
  • In the Quick Access toolbar click on the Customize Option

image

1.    Once CUI editor is displayed. Right click on the command list and select “New command”:

image

2.    This will open another window ‘Customize User Interface’:

image

3.    In the properties pane, the first line is the command. You can give it a memorable name here. This is the title which will be used whenever you want to apply this command.

4.    Add a simple description for future reference.

5.    Now go to the “Macro” Box. A Macro is a list of instructions for AutoCAD to follow. It is basically the information required for the customised command to execute. Here you are telling the CUI what your new command will do. Macros are entered in the Macro Text Box like a simple command line or script. In cases where the command is very large the Long String Editor can be used.

Macros:
Creating a new Macro is a bit tricky. Let’s see how to create awesome macros.

A good practice is to start your macros with “^C^C” which is equivalent to hitting the escape key twice. This makes absolutely sure that you are out of any commands and it only desired command will be executed. Following “^C^C” is the new command. For example “^C^C Line” will eliminate any previous commands and then execute the Line Command. Some characters have specific meanings:

Character    Description
Space Adds space between text objects
; (Semi Colon) Equivalent to pressing enter
Pauses for user input
+ Continues the Macro to the next line

By using these characters and pre-defined existing commands you can create your own customized commands.

At the bottom of properties pane there is an option to add an image. You can choose to add an icon for your command.

Now you can put those commands to good use. You can drag them to your dashboard, to a menu, to a toolbar or even to a key in your keyboard. Go to the Command List Categories drop-down list. In custom commands option, look for your customized command by name. Select it and drag it anywhere in this customized interface.

Click Ok and try your new Command.

This is going to save a lot of your time and also help to minimize errors.

More resources

You can read these articles to learn about this topic further:

How to automate AutoCAD with command macro.

5 articles to learn about AutoCAD CUI.

About Anne Carrew

Anne is the Manager for Acuity Training Surrey, UK. We run all type of courses from AutoCAD, MS Office and Adobe courses to Leadership, Time Management and Digital Photography. We pride ourselves in having small class sizes with individual attention for all who attend. All of our trainers are highly experienced in their areas.

Source: AutoCAD tips by CAD Notes