1 / 59

API for CUIx Files And Runtime Ribbon in AutoCAD 2010

API for CUIx Files And Runtime Ribbon in AutoCAD 2010. Wayne Brill API Consultant - Autodesk. About the Presenter. Wayne Brill Developer Technical Services Americas (resides in the Seattle area)

sani
Télécharger la présentation

API for CUIx Files And Runtime Ribbon in AutoCAD 2010

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. API for CUIx Files And Runtime Ribbon in AutoCAD 2010 Wayne Brill API Consultant - Autodesk

  2. About the Presenter • Wayne Brill • Developer Technical Services • Americas (resides in the Seattle area) • Wayne has been a member of Autodesk Developer Technical services supporting ADN (Autodesk Developer Network) for nine years. Currently, Wayne provides API support for Autodesk Inventor®, AutoCAD, AutoCAD® Mechanical, AutoCAD OEM, and RealDWG™.

  3. Areas of focus • Introduction to UI Customization & CUIx files • API to create/edit CUIx files - ribbon elements • Ribbon runtime API (non – CUIx files) • Deployment / Known issues

  4. Introduction to UI Customization & CUIx Files

  5. CUIx files • CUI - Customize User Interface • Contains User Interface elements such as pulldown menus, toolbars, keyboard shortcuts, & ribbon tabs • X is the standard suffix for zipped, package formats (like dwfx, pptx, docx) • Now in AutoCAD 2010 the menu files are packages • Main CUIx contains the Workspaces which allow users to easily switch available UI elements • XML files (editing the xml directly is unsupported) • Not backward compatible

  6. CUIx types & related files • Main CUIx – • acad.CUIX by default, Setting for this on files tab in Options, Profiles control which CUIx is the main CUIx • Partial CUIx • Use CUILOAD command, • Elements in Partial CUIx can be added to workspaces in main CUIx • Enterprise CUIx • Read Only • Ribbon tabs not automatically added to workspaces like partial cuix files • MNL • AutoLISP related functions loaded automatically when CUI with same name is loaded • Resource only DLL (still supported) • Contains icons for toolbars

  7. CUIx file contents • CUIx file is a container – similar to a zip file • Contains CUI files • BMP files • XML files • Direct manipulation of the CUIx file is not supported • WinZip can unzip CUIx but may be unable to zip it correctly • BMP files are packaged in the CUIx file using the CUI command

  8. Workspaces • The term “current workspace” can be misleading • Current workspace is only current until a change in the UI is made • WSSETTINGS • can set changes to be saved automatically when switching workspaces Registry key WSAUTOSAVE added to registry when AutoCAD is closed.(this is the setting on the WSSETTINGS dialog) • HKEY_CURRENT_USER\Software\Autodesk\AutoCAD\R18.0\ACAD-8005:409\Profiles\<<unnamed profile>>\General

  9. Workspaces & CUILOAD command • Workspaces provide the way to have Ribbon Tabs on the ribbon bar • Partial CUIx with Ribbon Tabs & CUILOAD • Ribbon Tab settings for loading behavior • Other UI elements such toolbars

  10. CUI Demo Run CUI dialog Run WSSETTINGS Switch workspaces

  11. API to create/edit CUIx files - ribbon elements

  12. Introduction to CUIx API • .NET CUI API – First available in AutoCAD 2007 • AutoCAD 2010 introduces CUIx files • API can be used without running AutoCAD • AutoCAD needs to be installed on the system however • AcCui.dll • Reference from acad.exe directory or in ObjectARX/inc-win32 or inc-x64 • Autodesk.AutoCAD.Customization namespace • UI elements displayed in AutoCAD not directly created

  13. API saving and loading CUIx files • Use CustomizationSection.Save method after adding or changing UI elements in CUIx file • Commands to see changes to CUIx file in AutoCAD • CUIUNLOAD, CUILOAD, WSCURRENT, -WSSAVE • SendStringToExecute, acedCmd with p/Invoke ads_queueexpr (p/Invoke) to run CUIx related commands at startup • Useful AutoCAD commands and Variables • MENUNAME, ENTERPRISEMENU, RIBBONDOCKEDHEIGHT • RIBBON, RIBBONSTATE,RIBBONCLOSE, MENUBAR

  14. Partial CUIx files • Add partial CUIx files to Main CUIx • Use addPartialCUI(csPartial) – Merges UI elements • PartialCuiFiles.Add(strPartialCuiFile) – just adds partial to list • For a new CUI file that does not exist instantiate a new CustomizationSection without any arguments • CustomizationSection csNew = new CustomizationSection(); • csNew.SaveAs(strCuiFile); • .

  15. Top Level classes • CustomizationSection • Top level class representing the CUIx file • Types of files - Main CUIx file, Partial CUIx files, Enterprise CUIx file • CUIFileBaseName – returns path and name of cuix file • MenuGroup • Property of the CustomizationSection • WorkspaceCollection – Only Main CUIx file

  16. CUIx Element Identifiers • ElementID • Used for finding elements, csPartial.getToolbar(tbElementID); • Used to set macro (macroID property) of an element to a MenuMacro • Unique in the MenuGroup • MacroID • returns the MenuMacro used by the MenuItem • UID • Panel.UID • ID • Used for Ribbon Controls

  17. MenuMacro • MenuMacro • macGroup.CreateMenuMacro() • MacroType enum • Filters commands in the CUI dialog • MacroGroup • MenuGroup has a MacroGroups Collection

  18. CUIx API Demo 1 Use the API to create a new CUIx file with one MenuMacro

  19. API Object Model for Ribbon Elements

  20. Top Level & Base Ribbon Classes • RibbonRoot • Instantiate - CustomizationSection.MenuGroup.RibbonRoot • Parameter for several constructors • RibbonTabSourceCollection (ribbonRoot.RibbonTabSources) • FindTab • RibbonItem • Base Class • RibbonItemCollection • Collection of RibbonItem

  21. Ribbon Element Classes • RibbonCommandButton • MacroID - Takes a MenuMacro.ElementID • Constructor takes the parent (RibbonRow); • Executes a Macro • RibbonSplitButton • Constructor takes the parent (RibbonRow) • ribSplitButton.Items.Add(ribCmdButton);

  22. More on RibbonSplitButton • RibbonSplitButton • RibbonSplitButtonBehavior • ribSplitButton.Behavior = rsbehavior; • RibbonSplitButtonListStyle • RibbonButtonStyle

  23. Ribbon Element Classes • RibbonControl • Id - use the identifier for the control (string) • Constructor takes the parent (RibbonRow); • RibbonRow • Use the Items.Add to add buttons

  24. Ribbon Panel Classes • RibbonPanelSourceCollection • Constructor takes a RibbonRoot - new RibbonPanelSource(ribbonRoot); • Use the Add method to add RibbonPanelSource • RibbonPanelSource • contains the panel definition • can be shared and displayed by one or more RibbonPanel controls. • Use the Items.Add method to add a RibbonRow

  25. Ribbon Tab Classes • RibbonTabSourceCollection • Instantiate with RibbonRoot.RibbonTabSources • tabs.Add(tabSrc); • contains a collection of RibbonTabSource • RibbonTabSource • Constructor takes a RibbonRoot • Contains panels for the ribbon tab (RibbonPanelSourceReference)

  26. Ribbon Panel References • RibbonPanelSourceReference • Not directly seen in the User Interface • Constructor takes a RibbonTabSource to which the item belongs • PanelId takes the ElementID of RibbonPanelSource • RibbonPanelSourceReferenceCollection • Not directly seen in the User Interface • Contains a collection of RibbonPanelSourceReference

  27. Steps to add a new panel & tab with the API • Get the RibbonRoot from the MenuGroup of the CustomizationSection • Create a RibbonPanelSource. Create a RibbonRow and add elements. Add the RibbonRow to the RibbonPanelSource • Add the RibbonPanelSource to the RibbonPanelSourceCollection. • Create a RibbonTabSource and add it to the RibbonTabSourceCollection.. • Create a RibbonPanelSourceReference (not seen in the UI), associate it to the RibbonPanelSource (use the PanelId property) created in step 2 • Add the RibbonPanelSourceReference to the RibbonTabSource created in step 4.

  28. CUIx API Ribbon Elements Demo Demo the API that creates a new Panel and Tab

  29. API Object Model for Tabs & Workspaces

  30. Workspace Tab Classes • WorkspaceCollection • CustomizationSection Workspaces - cs.Workspaces • WSRibbonRoot • Contains ribbon settings and the collection of WSRibbonTabSourceReference • Instantiate with WorkspaceRibbonRoot of a Workspace • WorkspaceTabs collection of WSRibbonTabSourceReference • WSRibbonRoot.FindTabReference

  31. More Workspace Tab Classes • WorkspaceRibbonTabCollection • This is a collection of WSRibbonTabSourceReference • WSRibbonTabSourceReference • Instantiate with the Create method • Set the parent and use the Add method of the WorkspaceRibbonTabCollection

  32. Steps to add a new panel & tab with the API • Create a WorkSpace - constructor takes CustomizationSection and name of Workspace • Get the WSRibbonRoot from the WorkSpace. (Use WorkSpace.WorkspaceRibbonRoot ) • Create a WSRibbonTabSourceReference. • Need to get a RibbonTabSource • Use the WSRibbonTabSourceReference.Create method. (takes the RibbonTabSource) • Use the SetParent method. The argument for this is the WSRibbonRoot of the workspace • Add the WSRibbonTabSourceReference to the WorkspaceRibbonTabCollection. Get to the WorkspaceRibbonTabCollection using the WorkSpaceRibbonRoot.WorkspaceTabs property

  33. CUIx API Workspace Tab Demo Add the tab shown in the previous demo to an existing workspace

  34. Ribbon runtime API (non – CUIx files)

  35. Required references for runtime Ribbon API • AdWindows • Autodesk.Windows namespace • AcWindows • Autodesk.AutoCAD.Ribbon namespace • PresentationCore • System.Windows.Media.Imaging • Needs a reference to the WindowsBase assembly • PresentationFrameWork • Needed for Autodesk.Windows.RibbonControl, • Set Copy local to false for these DLLS when debugging • AcWindows System.Exception: The component 'Autodesk.AutoCAD.AcInfoCenterConn.MyAutoCADBalloon' does not have a resource identified by the URI Error can occur

  36. API Object Model for runtime Ribbon

  37. Top Level runtime Ribbon Classes • The AutoCAD Ribbon is a RibbonControl • Access with the ComponentManager • You can also access the ribbon using: Autodesk.AutoCAD.Ribbon.RibbonServices.RibbonPaletteSet.RibbonControl • (note: RibbonControl class is also in Customization namespace) • RibbonTab • Represents a Tab in the Ribbon

  38. Runtime RibbonPanel Classes • RibbonPanel • Represents a panel in the RibbonTab • RibbonPanelSource • Contains the panel definition for the panels displayed in ribbon • Single RibbonPanelSource can be shared by Multiple RibbonPanels

  39. Runtime RibbonItem & RibbonRowPanel • RibbonItem • Represents some item in the Ribbon • Class with same name also in the Customization namespace • RibbonRowPanel • Represents a sub panel • Class with same name also in the Customization namespace

  40. Runtime RibbonItem & RibbonRowPanel • RibbonSplitButton • Collection of RibbonItems • Class with same name also in the Customization namespace • RibbonCommandButton • Represents command buttons • Class with same name also in the Customization namespace

  41. Steps to add a Runtime tab with the API • Get the Ribbon – You can use: Autodesk.AutoCAD.Ribbon.RibbonServices.RibbonPaletteSet.RibbonControl to instantiate • Create a RibbonTab and set the properties for it such as the Title and ID. (The Id is required to avoid a “Value cannot be null exception”). • Add the RibbonTab created in step 2 to the Ribbon using the RibbonControl.Tabs.Add(). (RibbonControl in this case is the Ribbon) • Create an Autodesk.Windows.RibbonPanelSource. • Create a RibbonPanel and make its Source Property equal to the RibbonPanelSource • Add the RibbonPanel created in step 5 to the RibbonTab created in step 2 • Create controls such as Autodesk.Windows.RibbonButton and add them to the RibbonPanelSource created in step 4. Use the RibbonPanelSource.Items.Add()

  42. Runtime Ribbon API Demo Discuss command that changes the icon of a button in the ribbon Discuss a project that creates a new tab on the ribbon

  43. Deployment / Known issues

  44. CUIx Ribbon UI Element Deployment • Add your buttons to an existing AutoCAD Panel/Tab? • If they are similar in functionality to existing ribbon elements • The user would expect them to be grouped together • Create a new panel/tab? • If they are different in functionality • User would expect them to be grouped separately

  45. Install Partial CUIx files • Decision Criteria: • User will likely be using partial CUIx files and customizing the UI • The application is more like an “Add-In” than a full application • Advantages • User is able to have more flexibility in his customization • Using a different partial CUIx for different modules in the application • Settings for tabs need to be set to the behavior you want • In the UI or API

  46. Install a Main CUIx file • Decision Criteria: • User will likely not be using partial CUIx files and customizing the UI • The application is a full application • Advantages: • Workspaces and ribbon tabs will be available by default • Can use a profile to control which main CUIx file is loaded • Can Include an arg file, and use a /p switch on an icon to launch AutoCAD with a particular profile active • Disadvantages: • Less flexibility for the user when customizing user interface • May need to add AutoCAD UI elements to your CUIx file

  47. Install a .NET dll that will add application UI elements to the main CUIx file • Decision Criteria: • User customizes UI and uses partial CUIx files and you would rather not ship a partial CUIx file • Advantages: • Could create the UI elements based on certain user parameters • Disadvantages: • Could cause some Product Support issues if the elements are not created correctly

  48. Install a .NET dll that will create the CUIx file • Decision Criteria: • User experience will depend on how the CUIx file is used (Partial or Main) • Advantages: • Could create the CUIx file based on certain user parameters • Disadvantages: • Could cause some Product Support issues if the CUIx file was not created correctly

  49. Known issues 1 • CUIUNLOAD with FILEDIA = 0 does not remove custom Ribbon Tab and may crash AutoCAD • Logged Change Request • Work around is to unload and reload the main CUIx. • Fixed in the next release of AutoCAD • No Ribbons after acad.exe /b Script • Logged Change request. Active workspace when AutoCAD last closed is not restored as it should be. • The easiest workaround is to append two more lines at the end of the script to restore the workspace • A second workaround is to use /w switch and specify the name of the workspace you want to load (that implies you know it in advance).

  50. Known issues 2 • References to Partial CUIx files saved in MAIN CUIx • Can get unreferenced items when search path is unavailable because of profile change, can happen even when workspace not saved • Transparent background for icons • Use RGB 192, 192, 192 • Unable to Disable or Enable menus in MenuBar using menucmd or (acedMenuCmd) • One suggestion is to use the ActiveX interface and remove the pull down menu • Tooltip Property of Macro class unavailable • Reported to engineering

More Related