Examples
To execute the following examples you must enable the developer tools. For more information, see Developer Tools.
You can add and validate your customizations in the following sequence:
Create a custom_ribbon.xml
Add the XML fragments below in your custom_ribbon.xml
Run the Validate Definition or Customization tool on the modified custom_ribbon.xml.
Open Creo Element/Direct Model Manager and select custom_ribbon.xml in the Select Configuration box.
Removing elements from the ribbon
Elements to be removed are referenced by a path identifier.
To determine the paths of all elements, in Creo Elements/Direct Model Manager, click Ribbon Customization and then, in the Definition group, click Display Current Ribbon Structure. The XML description of all the user interface including both statically and dynamically defined elements is displayed.
Add the following in the custom_ribbon.xml file.
<Ribbon>
<Customize>
<Remove path="/TaskAgentTab" />
<Remove path="/StructureTab/StructureModifyGroup" />
<Remove path="/HomeTab/EditGroup/ChangeStateMenu" />
<Remove path="/ApplicationMenu/SendToPrimary" />
</Customize>
</Ribbon>
The first entry removes an entire tab, the second one removes a group and the third one removes the Change State button from the Home tab. The fourth entry removes the Send To option from the file menu.
Adding a button
The most important constituent of a button definition is the underlying action. This action must be a WMAbstractAction. You can either implement a new WMAbstractAction or reuse an existing one.
<Ribbon>
<Customize>
<Tabs>
<Tab ref="HomeTab">
<Group ref="EditGroup">
<Button id="MyHelloWorldButton" weight="1.5">
<Action>com.osm.action.HelloWorldAction</Action>
</Button>
<Button id="MyHelloCreatorButton" weight="1.6">
<Action isContext="true">com.osm.action.HelloCreatorAction</Action>
</Button>
</Group>
</Tab>
</Tabs>

<ApplicationMenu>
<Primary id="NewWorkspacePrimary" weight="1.5">
<DisplayName>New Workspace</DisplayName>
<Action>com.osm.datamgmt.action.NewWorkspaceAction</Action>
</Primary>
</ApplicationMenu>

</Customize>
</Ribbon>
The first entry adds a new button to the Edit group in the Home tab. Note that the tab and group are referenced by a ref attribute since we’re modifying existing elements here. The button is a new element and thus marked with an id attribute. The button definition does not specify an icon or display name so it inherits these values from the WMAbstractAction.
The action in MyHelloWorldButton is context-free, that is, the action is not applied to a real data element. Most actions in Creo Elements/Direct Model Manager, however, are context actions and are applied to selected elements.
The second entry adds an action that can be executed on 3D models. To make a button context-sensitive, you need to do the following two things:
1. The action class must be derived from WMAbstractAction and implement the isApplicable member. This implementation determines whether a button becomes active when a particular element is selected in Model Manager’s structure view.
2. The action must be marked with the XML attribute isContext=”true”.
The third example shows how to add an entry to the first level in the application menu. It also reuses an existing action but specifies a different display name. The weight attribute specifies the location where buttons are inserted. For example, the MyHelloWorldButton is inserted between the DB Properties (weight 1.0) and the “Change State” (weight 2.0) button. If no weight is specified, a ribbon element is added at the end of its parent container.
Adding a menu button
Menu buttons can be configured by adding a <Popup> element to the button definition.
<Ribbon>
<Customize>
<Tabs>
<Tab ref="HomeTab">
<Group ref="CollaborateGroup">
<Button id="MyReserveMenuButton">
<DisplayName>My Reserve Menu</DisplayName>
<Popup>
<Button ref="ReserveButton"/>
<Button ref="UnreserveButton" />
</Popup>
</Button>
</Group>
</Tab>
</Tabs>
</Customize>
</Ribbon>
* 
The button appears as first element in the Collaborate group. This is because the button is shown with a large icon and large buttons are always shown in front of medium or small size buttons. For more information, see priority (attribute).
Adding groups and tabs
Other ribbon elements can be created analogous to buttons by using the same syntax as in RibbonDefinition.xml.
<Ribbon>
<Customize>
<Tabs>
<Tab id="MyTab">
<DisplayName>My Tab</DisplayName>
<Group id="MyFirstGroup">
<DisplayName>1st Group</DisplayName>
<Button ref="ReserveButton"/>
</Group>
<Group id="MySecondGroup">
<DisplayName>2nd Group</DisplayName>
<Button ref="UnreserveButton" />
</Group>
</Tab>
</Tabs>
</Customize>
</Ribbon>
Modifying elements
An element is modified by overwriting the respective XML element. The example below changes the name of the Home tab and displays the Add New button in the Edit group with a large icon.
<Ribbon>
<Customize>
<Tabs>
<Tab ref="HomeTab">
<DisplayName>Home Sweet Home</DisplayName>
<Group ref="EditGroup">
<Button ref="AddNewMenu" priority="top" />
</Group>
</Tab>
</Tabs>
</Customize>
</Ribbon>
Was this helpful?