Thursday, May 9, 2013

Create a custom ribbon tab using the custom CUI

In a post last week we looked at reasons the custom.cui can be a great spot for users to create their own custom AutoCAD content. After some feedback I am realizing it would be helpful to walk through creating a custom element from scratch and having that load from the custom.cui.

As mentioned, the custom.cui is partially loaded into the acad.cui by default.
Creating CUI elements in here is the same process as in the acad.cui. Expand the Custom CUI node and locate the type of element you want to add. For this example we will:
  • Create a new Ribbon Tab
  • Create a new Ribbon Panel
  • Create a custom command to add to the Panel
  • Make sure the new Ribbon Tab is available in your AutoCAD environment
Create a new Ribbon Tab by right clicking on the Tabs element and select New Tab.
 
Give the new tab a name and it will now be displayed in Custom, Ribbon, Tabs.
Next, create a new Panel that will be added to the tab. Remember, a Tab can host multiple panels. We will just create one panel for this exercise. To create the new Panel, right click on the Panels element and select New Panel.
Give the new panel a name and it will now be displayed in Custom, Ribbon, Panels.
Let's define a custom command that we can add to our new panel. Click the Create a new command button and a new command will be added to the Command List pane in the CUI Editor. Give the new command a name.
Once the command is created we can define what the command should do. This example is a custom command that is defined in an external file (either Lisp or dll). As long as this file is loaded through the custom.mnl then it will be loaded in the drawing.
Now that our command is created we can add it to our custom panel. To do this drag the command up to the panel location where the command should be. Note: if you drag the command to the left (off the CUI dialog) then move your mouse up to where the panel is before bringing the mouse back over the CUI dialog this will prevent any scrolling that can happen if you try to drag the command straight up.
After adding the command to the Ribbon Panel there are some properties that you may want to adjust for how it displays on the actual panel. This gets into the layout of the CUI Ribbon Elements but for this example I am selecting the large icon with text option.
Now that we have a custom command and a custom ribbon panel, we need to add the panel to the custom Ribbon Tab. To do this just drag the panel onto the tab.
Lastly, we need to make this Ribbon Tab available in AutoCAD. If the custom Ribbon Tab that was created does not automatically show up in AutoCAD this will be controlled by the active workspace. To turn the custom Ribbon Tab on in the active workspace click Customize Workspace (in the CUI dialog)
 
then scroll down to the Partial Customization Files and locate the Custom Ribbon Tab. Check the box next to this element.
Click Done to finish Customizing the workspace and then Apply the CUI changes.
The new tab, panel, and command should now be available in AutoCAD.
 
You will also notice after doing this that the custom command now exists in the Custom menu source in the CUI Command List.
 
By creating this structure this allows users to create multiple custom commands and panels and easily transport them to a new workstation or a new version of AutoCAD just by bringing the custom.cuix file (and associated mnl, lisps, dll's, etc.) along with it.
 
One approach could be to create a Custom subfolder in the same folder where the custom.cuix and custom.mnl are located. Custom code can be stored in this folder as well as the icons for the ribbon panels.


 

 


 

 

 


 
 

 

No comments:

Post a Comment