The user interface and workspace data of a CUIx file can be accessed using the CUI managed API.
There are two specific objects in the CUI managed API that are used to access the customization sections of a CUIx file: MenuGroup and Workspaces. The MenuGroup object contains the menu and interface data used to manipulate the AutoCAD drawing environment, while the Workspaces object is used to control the display of elements in the user interface. Workspace information can be stored in any CUIx file, but is only accessible from a CUIx file that is loaded as a main or enterprise customization file.
The individual elements—for example toolbars, pop menus, and shortcuts—can be accessed through collections under the MenuGroup collection object. Collections have no public constructor and are initialized when the CUIx file is parsed in the customization section constructor.
The following objects are part of the MenuGroup collection object:
Customization sections contain a collection of workspaces, which can be accessed by index entry or by specifying the workspace name using the IndexOfWorkspaceName() method. A workspace consists of a Quick Access toolbar, classic toolbars, pop menus, dockable windows, and ribbon tabs and panels which are organized using the following objects and collections:
You can reference a element in a workspace by using one of the following methods:
Toolbars, pop menus, and ribbon tabs created in the main CUIx file, need to be added to a workspace before they will display in the AutoCAD user interface. New elements added to a toolbar, pop menu, or ribbon panel already displayed in a workspace will be shown automatically when that workspace is reloaded.
The following code demonstrates how to add a toolbar to a workspace:
Dim someToolbar As Toolbar = CustomizationSection.MenuGroup.Toolbars(4) Dim wkToolbar As WorkspaceToolbar = New WorkspaceToolbar(parentWorksapce, someToolbar)
Toolbar someToolbar = CustomizationSection.MenuGroup.Toolbars[4]; WorkspaceToolbar wkToolbar = new WorkspaceToolbar(parentWorksapce, someToolbar);
Set the Display property of the toolbar to True (or 1) to show it in the workspace.
The collection of dockable windows is accessed from CustomizationSection.Workspaces.DockableWindows. Use the DockFloat and Orientation properties to dock or float a window.
Changes to a workspace will only come into effect after the workspace is reloaded in the application. Restarting the application does not reload the workspace. This must be done using the WSCURRENT system variable or by re-selecting the workspace from the Workspace Switching icon on the status bar.