Creating toolbars from a spreadsheet
Besides using the Customize dialog box, you can create toolbars in a CUI file, which is a plain XML file.
XML files can be edited manually or generated from another source, such as a spreadsheet. Using a spreadsheet can simplify the creation and maintenance of XML data by generating the required XML code automatically.
This method requires the following:
- A spreadsheet program that supports the IFS function to generate the XML code.
- A text editor for XML files to paste the generated code into a CUI file.
- (Optional) 16x16 and 32x32 pixel PNG images for icons, compressed as a RESZ file.
The following procedure describes how to create a partial CUI file that contains one floating toolbar with two buttons, a separator, a flyout and a control. You can extend the spreadsheet table to add additional buttons and toolbars.
Setting up the spreadsheet
Set up the spreadsheet with the following values to define the toolbar:
| Row | A | B | C | D | E | F | G |
|---|---|---|---|---|---|---|---|
| 1 | - | - | - | - | - | - | - |
| 2 | - | - | - | - | - | - | - |
| 3 | BCDrawLine | Draw line | ^C^C_LINE | - | - | - | - |
| 4 | BCDrawCircle | Draw circle | ^C^C_CIRCLE | - | - | - | - |
| 5 | BCArc | Arc | ^C^C_ARC | - | - | - | - |
| 6 | BCFitArc | Fit Arc | ^C^C_FITARC | - | - | - | - |
| 7 | ToolBars | - | - | - | - | - | - |
| 8 | bar | BCADTools | floating | show | 1 | 200 | 200 |
| 9 | button | =A3 | =B3 | - | - | - | - |
| 10 | button | =A4 | =C4 | - | - | - | - |
| 11 | spacer | - | - | - | - | - | - |
| 12 | Arcs | =A5 | - | - | - | - | - |
| 13 | control | WorkspaceControl | - | - | - | - | - |
| 14 | bar | Arcs | floating | hide | 1 | 0 | 0 |
| 15 | button | =A5 | =B5 | - | - | - | - |
| 16 | button | =A6 | =B6 | - | - | - | - |
Using this spreadsheet structure, you can add and define additional elements to further customize the toolbar. The following table describes the available elements and their properties:
| Column A (Type) | Use | Column B | Column C | Column D | Column E | Column F | Column G |
|---|---|---|---|---|---|---|---|
| bar | Inserts a toolbar. | The name of the toolbar. | The position of the toolbar (floating, top, left, right, bottom). | The visibility of the toolbar (show, hide). | The number of rows. | The X position in pixels of the toolbar. | The Y position in pixels of the toolbar. |
| button | Defines a button that runs a macro. | The unique identifier (UID) of the macro assigned to the button. | The name of the button. | - | - | - | - |
| spacer | Inserts a separator line between buttons. | - | - | - | - | - | - |
| flyout | Defines a button that displays a flyout menu when pressed and held. | The name of the toolbar used as flyout. | The unique identifier (UID) of the flyout toolbar. | - | - | - | - |
| control | Inserts a built-in control into the toolbar, such as the LayerControl or WorkspaceControl. | The name of the control. | - | - | - | - | - |
Adding the XML code
Column H generates the XML code for each row. Enter the following values to complete the spreadsheet:
Cell H1 (plain text):
<?xml version="1.0" encoding="UTF-8" standalone="no" ?><CustSection xml:lang="en-US"><Header><WorkspaceRoot><Workspace DefaultWorkspace="true" ScrollBars="ignore"><Name>Drafting</Name><WSPopRoot/><WSToolbarRoot/></Workspace><WorkspaceConfigRoot><WorkspaceConfig Display="true"><Name>Drafting</Name></WorkspaceConfig></WorkspaceConfigRoot></WorkspaceRoot></Header>
Cell H2 (plain text):
<MenuGroup Name="BCADTools"><MacroGroup Name="BCADToolsMacros">
Cell H3, filled down to H6:
="<MenuMacro UID="""&A3&"""><Macro><Name>"&B3&"</Name><Command>"&C3&"</Command><SmallImage Name="""&A3&"_16.png""/><LargeImage Name="""&A3&"_32.png""/></Macro></MenuMacro>"
Cell H7 (plain text):
</MacroGroup><MenuRoot><AcceleratorRoot/><MouseButtonRoot/><DigitizerButtonRoot/><PopMenuRoot/><ToolbarRoot>
Cell H8, filled down to H16:.
=IFS(A8="bar",IF(A7="ToolBars","","</Toolbar>")&"<Toolbar ToolbarOrient="""&C8&""" ToolbarVisible="""&D8&""" UID="""&B8&""" rows="""&E8&""" xval="""&F8&""" yval="""&G8&"""><Alias>"&B8&"</Alias><Name>"&B8&"</Name>",A8="button","<ToolbarButton><Name>"&C8&"</Name><MenuItem><MacroRef MenuMacroID="""&B8&"""/></MenuItem>"&IF(D8="","","<State>"&D8&"</State>")&"</ToolbarButton>",A8="spacer","<ToolbarButton IsSeparator=""true""/>",A8="flyout","<ToolbarFlyout UID="""&B8&""" UseOwnIcon=""false"" pTargetAlias="""&B8&"""><FlyoutName>"&B8&"</FlyoutName><SmallImage Name="""&C8&"_16.png""/><LargeImage Name="""&C8&"_32.png""/></ToolbarFlyout>",A8="control","<ToolbarControl Control="""&B8&"""/>")
Cell H17 (plain text):
</Toolbar>
Cell H18 (plain text):
</ToolbarRoot><ImageMenuRoot/><TabletMenuRoot/><RibbonRoot><RibbonTabSourceCollection/><RibbonPanelSourceCollection/><RibbonTabSelectors/></RibbonRoot><DoubleClickRoot/><QuadRoot><QuadTabs/></QuadRoot></MenuRoot></MenuGroup></CustSection>
Creating the CUI file
To create the CUI file, use the following steps:
- In the spreadsheet, select and copy cells I1 through I8.
- Paste the copied cells into a new file in an XML text editor. Each cell is pasted on a separate line.
- Save the file as BCADTools.cui with UTF-8 encoding in a folder, such as: C:\BCADTools.
Adding the button images
To add images to the buttons, use the following steps:
- Create two PNG files for each macro: one at 16 × 16 pixels and one at 32 × 32 pixels, and name them using the following structure:
- <UID>_16.png
- <UID>_32.png
For example, create BCDrawLine_16.png and BCDrawLine_32.png.
- Add the images to a ZIP archive.
- Save the ZIP archive as a RESZ file with the same name as the CUI file, for example BCADTools.resz, in the same folder as the CUI file.
- The 16 × 16 pixels PNG files are used for Small icons, while the 32 × 32 pixels PNG files are used if the Toolbar size is set to Large icons.
- When adding the images to a ZIP archive, do not use subfolders or compression.
- If no images are included, the buttons display a blank icon.
Loading the CUI file
To load the newly created partial CUI file, use the following steps:
- Add the folder that contains BCADTools.cui and BCADTools.resz to the support file search path using the SRCHPATH system variable.
- Run the CUILOAD command to open the Customization Groups dialog box.
- Click Browse (
) to open the Choose a Customization File dialog box. - Select the CUI file and click the Load button.
The toolbar BCADTools appears with two buttons, a separator, a flyout and a control.
