AutoCAD has provided the Ribbon UI for some time and also provided the CUI .NET API for us to manipulate the modern UI elements including Ribbon Tab, Ribbon Panel and various Ribbon Buttons.
We created Ribbon Panels and Ribbon Tabs from scratch before. We also created various Ribbon Buttons and added them into new or existing Ribbon Panels.
In this post, let’s print out some information about CUI file, Workspaces, Ribbon Tabs, and Ribbon Panels in the current AutoCAD session.
Here is the code and command.
[CommandMethod("ListRibbonInfo")]
public static void ListRibbonInfo_Method()
{
Editor ed = MgdAcApplication.DocumentManager.MdiActiveDocument.Editor;
try
{
using (StreamWriter sw = new StreamWriter("c:\\temp\\AcadRibbonInfo.txt"))
{
string cuiFile = (string)MgdAcApplication.GetSystemVariable("MENUNAME");
sw.WriteLine(string.Format("CUI File: {0}", Path.GetFileName(cuiFile)));
string curWorkspace = (string)MgdAcApplication.GetSystemVariable("WSCURRENT");
sw.WriteLine(string.Format("Current Workspace: {0}", curWorkspace));
CustomizationSection cs = new CustomizationSection(cuiFile);
RibbonRoot root = cs.MenuGroup.RibbonRoot;
foreach (Workspace ws in cs.Workspaces)
{
sw.WriteLine();
sw.WriteLine(string.Format("\tWorkspace: {0}", ws.Name));
foreach (WSRibbonTabSourceReference wsTabSourceRef in ws.WorkspaceRibbonRoot.WorkspaceTabs)
{
RibbonTabSource tabSource = root.FindTab(wsTabSourceRef.TabId);
if (tabSource == null) continue;
sw.WriteLine(string.Format("\t\tRibbon Tab: {0}", tabSource.Text));
foreach (RibbonPanelSourceReference panelSourceRef in tabSource.Items)
{
RibbonPanelSource panelSource = root.FindPanel(panelSourceRef.PanelId);
if (panelSource == null) continue;
sw.WriteLine(string.Format("\t\t\tRibbon Panel: {0}", panelSource.Text));
}
}
}
}
}
catch (System.Exception ex)
{
ed.WriteMessage(Environment.NewLine + ex.Message);
}
}
After the F5 button is pressed, the assembly loaded into AutoCAD, and the test command run, a text file will be created into the C:\TEMP temporary folder. By the way, if the AutoCAD .NET Addin Wizard (AcadNetAddinWizard) is used to create and debug the project, pressing the F5 can make all these done automatically.
The text file may contain some information as follows: (of course, the real content depends on the CUI file and the current workspace and ribbon settings.)
CUI File: acad
Current Workspace: Drafting & Annotation
Workspace: Drafting & Annotation
Ribbon Tab: Home
Ribbon Panel: Create
Ribbon Panel: Edit
Ribbon Panel: Draw
Ribbon Panel: Modify
Ribbon Panel: Selection
Ribbon Panel: Coordinates
Ribbon Panel: Layers & View
Ribbon Panel: Section
Ribbon Tab: Render
Ribbon Panel: Lights
Ribbon Panel: Sun & Location
Ribbon Panel: Materials
Ribbon Panel: Render
Ribbon Tab: Insert
Ribbon Panel: Block
Ribbon Panel: Reference
Ribbon Panel: Import
Ribbon Tab: Manage
Ribbon Panel: Action Recorder
Ribbon Panel: Customization
Ribbon Panel: Applications
Ribbon Panel: CAD Standards
Ribbon Tab: Output
Ribbon Panel: Plot
Ribbon Panel: Export to DWF/PDF
Ribbon Panel: 3D Print
Ribbon Tab: Plug-ins
Ribbon Tab: ANAW
Ribbon Panel: AcadNetAddinWizard
Ribbon Panel: AcadNetAddinWizard1
Ribbon Panel: AcadNetAddinWizard2
Workspace: 3D Modeling
Ribbon Tab: Home
Ribbon Panel: Modeling
Ribbon Panel: Mesh
Ribbon Panel: Solid Editing
Ribbon Panel: Draw
Ribbon Panel: Modify
Ribbon Panel: Section
Ribbon Panel: Coordinates
Ribbon Panel: View
Ribbon Panel: Selection
Ribbon Panel: Groups
Ribbon Panel: Layers
Ribbon Tab: Solid
Ribbon Panel: Primitive
Ribbon Panel: Solid
Ribbon Panel: Boolean
Ribbon Panel: Solid Editing
Ribbon Panel: Section
Ribbon Panel: Selection
Ribbon Tab: Surface
Ribbon Panel: Create
Ribbon Panel: Edit
Ribbon Panel: Control Vertices
Ribbon Panel: Curves
Ribbon Panel: Project Geometry
Ribbon Panel: Analysis
Ribbon Tab: Mesh
Ribbon Panel: Primitives
Ribbon Panel: Mesh
Ribbon Panel: Mesh Edit
Ribbon Panel: Convert Mesh
Ribbon Panel: Section
Ribbon Panel: Selection
Ribbon Tab: Render
Ribbon Panel: Lights
Ribbon Panel: Sun & Location
Ribbon Panel: Materials
Ribbon Panel: Camera
Ribbon Panel: Animations
Ribbon Panel: Render
Ribbon Tab: Parametric
Ribbon Panel: Geometric
Ribbon Panel: Dimensional
Ribbon Panel: Manage
Ribbon Tab: Insert
Ribbon Panel: Point Cloud
Ribbon Panel: Reference
Ribbon Panel: Block
Ribbon Panel: Block Definition
Ribbon Panel: Import
Ribbon Panel: Data
Ribbon Panel: Linking & Extraction
Ribbon Tab: Annotate
Ribbon Panel: Text
Ribbon Panel: Dimensions
Ribbon Panel: Leaders
Ribbon Panel: Tables
Ribbon Panel: Markup
Ribbon Panel: Annotation Scaling
Ribbon Tab: View
Ribbon Panel: Navigate
Ribbon Panel: Views
Ribbon Panel: Coordinates
Ribbon Panel: Visual Styles
Ribbon Panel: Viewports
Ribbon Panel: Palettes
Ribbon Panel: Windows
Ribbon Tab: Manage
Ribbon Panel: Action Recorder
Ribbon Panel: Customization
Ribbon Panel: Applications
Ribbon Panel: CAD Standards
Ribbon Tab: Output
Ribbon Panel: Plot
Ribbon Panel: Export to DWF/PDF
Ribbon Panel: 3D Print
Ribbon Tab: Plug-ins
Workspace: 3D Basics
Ribbon Tab: Home
Ribbon Panel: Create
Ribbon Panel: Edit
Ribbon Panel: Draw
Ribbon Panel: Modify
Ribbon Panel: Selection
Ribbon Panel: Coordinates
Ribbon Panel: Layers & View
Ribbon Panel: Section
Ribbon Tab: Render
Ribbon Panel: Lights
Ribbon Panel: Sun & Location
Ribbon Panel: Materials
Ribbon Panel: Render
Ribbon Tab: Insert
Ribbon Panel: Block
Ribbon Panel: Reference
Ribbon Panel: Import
Ribbon Tab: Manage
Ribbon Panel: Action Recorder
Ribbon Panel: Customization
Ribbon Panel: Applications
Ribbon Panel: CAD Standards
Ribbon Tab: Output
Ribbon Panel: Plot
Ribbon Panel: Export to DWF/PDF
Ribbon Panel: 3D Print
Ribbon Tab: Plug-ins
Workspace: AutoCAD Classic
Ribbon Tab: Home
Ribbon Panel: Create
Ribbon Panel: Edit
Ribbon Panel: Draw
Ribbon Panel: Modify
Ribbon Panel: Selection
Ribbon Panel: Coordinates
Ribbon Panel: Layers & View
Ribbon Panel: Section
Ribbon Tab: Render
Ribbon Panel: Lights
Ribbon Panel: Sun & Location
Ribbon Panel: Materials
Ribbon Panel: Render
Ribbon Tab: Insert
Ribbon Panel: Block
Ribbon Panel: Reference
Ribbon Panel: Import
Ribbon Tab: Manage
Ribbon Panel: Action Recorder
Ribbon Panel: Customization
Ribbon Panel: Applications
Ribbon Panel: CAD Standards
Ribbon Tab: Output
Ribbon Panel: Plot
Ribbon Panel: Export to DWF/PDF
Ribbon Panel: 3D Print
Ribbon Tab: Plug-ins
The leading edge AutoCAD .NET Addin Wizard (AcadNetAddinWizard) provides various project wizards, item wizards, coders including a Ribbon Creator, and widgets to help program AutoCAD .NET addins.
Hello from France, is it possible to create a new workspace by copying an existing one.
I'm a beginner with dotnet (I'm using vb.Net).
Thank you.
Posted by: Patrick | 07/26/2013 at 11:55 AM
It should be possible but we don't have code handy at this moment. When possible, we will explore on this. Thanks for the good question.
Posted by: Spiderinnet1 | 07/29/2013 at 12:50 AM
Thank you, and this blog is a great source of informations.
Congratulations for the job.
Posted by: Patrick | 07/30/2013 at 04:16 AM
Patrick, you are very welcome. Thanks for the nice words.
Posted by: Spiderinnet1 | 07/30/2013 at 11:18 PM
Hi,
is the latest download compatible with AutoCAD 2014, I have downloaded and installed but after launching VS2010 there is nothing in the Dialog box for AutoCAD Versions? I have 2013 and 2014 installed both from the Product design suite and standalone
Posted by: Ian Cross | 08/06/2013 at 08:29 PM
Ian, yes, the latest build is supposed to work with AutoCAD 2013/2014 and their flavors. Maybe the Product design suite matters here. We are going to have a look in detail and get back to you soon. Meanwhile, if details about the suite could be provided, it would be more helpful.
Posted by: Spiderinnet1 | 08/07/2013 at 10:15 PM
I have not messed with developing for 2014 and have 2014 design suite(which ever one you have to get to include Revit).
I un-installed add-in and downloaded it again to make sure I had the latest and noticed it only found 2013, including ACA 2013, & MEP 2013.
I remember noticing that installing the products through design suite install vs installing them separately with their individual installers creates a different folder structure where it places installation files..
Not sure how you check registry, or files, but if you need to me to provide values for registry keys or info on locations would be no problem.
Posted by: JeffH | 08/08/2013 at 02:59 AM
Jeff, thanks a lot for the hints and the kind offer. The Design Suite does matter then. We are going to try it and see what's going on. Will get you updated.
Posted by: Spiderinnet1 | 08/08/2013 at 09:13 PM
Hi,
I installed the standalone version of AutoCAD 2014 and still the dialog box is blank, possible its getting confused from the design suite, I will knock up a VM with a standalone version with no Product design suite installed and see what it brings up
Posted by: Ian Cross | 08/08/2013 at 09:28 PM
Ian, thanks for the update. We are going do the same.
Posted by: Spiderinnet1 | 08/12/2013 at 04:01 AM
Ian again, please try the latest build #0.7.6.0 and see how it works on your computers or VMs for AutoCAD 2014 and its flavors such as ACA, AME, ACADM and ACADE. The previous build has an issue regarding this, and the latest one has got it addressed. Sorry for the mix-up. Welcome any further feedback.
Posted by: Spiderinnet1 | 08/12/2013 at 08:56 PM
Awesome that works perfectly, thanks for all your help. do you know when the Revit 2014 one will be available, i'm updating all out Autodesk Apps to the new release.
Posted by: Ian Cross | 08/13/2013 at 12:54 AM
Hi SpiderinNet1,
Tried new install and it did not match what I thought I had installed because your add-in made me realize that I guess 2014 suite comes with Raster Design, because I checked and its there. So far as I can tell your add-in is knows more than I do of what I have installed.
Also do you have a donation link or anything similar?
Wish Autodesk took the same attitude toward customer support as you do.
Posted by: JeffH | 08/13/2013 at 08:46 PM
Jeff, thanks for the nice words. Computers are good at some tedious details, as we know. In terms of donation link, we don't have one at this moment. Will let you know when we do. Thanks a lot for the kind offer anyway.
Ian, glad to hear the new build works well for you now. In terms of the Revit 2014 support in the RevitAddinWizard, it will come out soon. Please stay tuned.
Posted by: Spiderinnet1 | 08/13/2013 at 11:08 PM
Ian, the Revit 2014 support for the RevitAddinWizard has been added. The latest post on the blog has the link to the latest build:
http://spiderinnet.typepad.com/
Posted by: Spiderinnet1 | 08/14/2013 at 10:41 PM