Exploring AutoCAD CUI: Creating a command in tab (part 2)

In previous tutorial, we explore the CUI dialog interface and create our own customization file. Let’s go further.

Let’s see what we will do:

  1. We will use our own cui file. So create it first before you follow this tutorial. We did it on the last tutorial.
  2. We will create custom commands. Later, we will combine them with existing AutoCAD command  to our panel.
  3. We will create a panel and a ribbon tab.
  4. We will define in which workspace the panel should appear.

Change your active customization file

In your CUI dialog, select your custom CUI you created before. If you miss the first step, you can check it in this first tutorial. I named it CAD-NOTES, but you may use your own name.

active cui

You should see your cuix file here. The command list is still empty, and there is no toolbar, menu or ribbon defined yet.

Create a new command

Let’s try to create a ribbon panel version of Paul Munford’s killer macro. There are few default AutoCAD command, but we also need to create the commands. So I guess this is a good exercise.

First, we need to create a command. In command list area, click create a new command.

create new command

Now you should see a command is listed here. The default name is Command1. Notice that the source is CAD-NOTES. It means the command is defined in that file. Select it.

new command

The properties on the right pane is now showing the command’s properties.

Configuring your command

Change the properties as shown below:

custom command setting

Here are some considerations:

  1. You should give the command a unique name, so you can find it easily.
  2. You need to define the macro that will be executed when this command is active.
  3. Optionally, you may add information to description and other fields. You can also define the icon image. You can create 32×32 pixel image for large icon and 16×16 pixel for small icon. Or just pick one from available icons.

You may create as many tools as you want. In Paul’s article, you can find very useful custom tools. Read it, you may find some custom tools that you want.

But remember, if it’s already a default AutoCAD command, you can just use it. You don’t need to create a new one.

Placing your command

You already have your custom command. You can define it to execute macro like we did above, or run an AutoLISP program.

But you haven’t place it to a toolbar, menu or ribbon panel. AutoCAD doesn’t know where you want to place it. Yet. We must tell AutoCAD where it should be.

We’re still working on our custom CUI file. For this exercise, let’s work with ribbon. You may try to place it on menu or toolbar later, but this time just ribbon.

Where do you can find a command? In a ribbon panel. So now we must create a ribbon panel for our command.

Remember: If you decide to add this command to existing panel, you don’t need to create a new one.

Creating a panel

In customization tree, expand ribbon. You will see panels category there, but there is no panel defined yet. Remember, we are working on a new customization file.

Right click above the panels category and choose new panel from contextual menu.

create new panel

Give your panel a name. I named mine viewport tools.

Now we have a panel, but it’s still empty. How can I add my command to this panel? By drag it from command list and drop it under the panel.

drag command to panel

We will fine tune the appearance later. Just drag your command there now.

Creating a ribbon tab

Now AutoCAD knows on which panel the command should appear. But where the panel should be? Is it at home tab? annotation tab? We also need to define this.

Because we want to place all of our custom command to a separate tab, we need to create a new ribbon tab. Again, if you just want to add that panel to existing tab, you don’t have to create a new tab.

Right click above tab category, then choose new tab from context menu. Give the new tab a name.

Because we want our panel before to appear on this tab, drag that panel here.

placing panel to ribbon

The last thing: Define the workspace

Are we done yet? Unfortunately no. There is one last thing we have to define. In which workspace it should appear.

Follow these steps to place our tab to workspace ribbon.

  1. Change the customization file to ‘all customization files’ (1).
  2. Select drafting & annotation default (2). You should see the right pane is now showing the workspace contents (3).
  3. In customization files tree, expand partial customization files> your customization file> ribbon (4).
  4. Find your custom tab then drag it to ribbon tabs category.

placing tab to workspace

We are done! Click OK to accept all changes and close CUI dialog.

You should see your tab now. Click that tab to activate it. Your panel and command is now there!

custom ribbon tab appearance

If you don’t see it, make sure you use drafting and annotation workspace! You  can change it from quick access toolbar.

drafting and annotation workspace

Try the command to make sure it works.

Isn’t that cool? We will add more commands next, and how to arrange the commands in our panel.

Comments

    Leave a Reply

    Your email address will not be published. Required fields are marked *

  1. says

    And without any doubt we can say that only experienced Magento developers have these unlimited creativity
    skills. For many years, residual incomes where traditionally only achievable by people in the
    entertainment business but the development of a digital marketplace has
    put a residual income within reach of almost anyone who is willing
    to do the work necessary to succeed. The executive committee is asked to sign off on the matrix and the design document is written.

  2. JJ717 says

    Are there any ways to activate these commands using the keyboard similarly to how i would press ”c” for ”circle”?

  3. m4rtymcf1y says

    Hi there,i get as far as creating a new command but the command list is already full of many commands,are these just default commands and you`re just adding a few new user friendly tabs/panels?.Im using ACAD2011