Customization > Extensibility Through Profiles, Stereotypes, Tag Definitions and Scripts > Advanced extensibility through stereotype scripts and script items > Extending diagram toolbars through stereotypes and scripts > Creating a toolbar button through a script
  
Creating a toolbar button through a script
Typically, you will want to create Scripts within a profile Package.
If you apply a Script to a diagram type, you will not be able to use that diagram type's standard diagram toolbar with any diagrams of that type. If this is a problem, use a Stereotype to apply the toolbar button to specific diagrams. See Creating a toolbar button through a stereotype.
To create a toolbar button through a script:
1. Right-click the profile Package, point to New, point to UML, point to Profiles, and then click Script.
2. Type a name for the Script, and then press the Enter key.
3. Open the Script's Property Pages, and then click the Items tab.
4. Click the Link button, select the diagram types to which you want to apply the customized toolbar button, and then click OK.
5. Click the Settings tab.
6. In the Script Type list, select Toolbar Command.
7. In the Command list, select the diagram toolbar button on which you want to base the new customized toolbar button.
A diagram button is valid only for the diagram type it specifies. Toolbar buttons that do not include a diagram name are valid for all diagram types.
If you want only to add a standard toolbar button to a customized diagram toolbar, you can ignore the steps that follow.
8. If you want the customized toolbar button to be part of a group of toolbar buttons, type the value of the group in the Group box. All toolbar buttons that appear on the toolbar and have the same group value will appear as buttons of the same split button, such as, the Dependency buttons on the Class Diagram toolbar.
9. In the ToolTip box, type the text of the button's ToolTip. If you want to use the ToolTip of the toolbar button on which the customized toolbar button is based, leave the ToolTip box blank.
10. In the Status Bar Text box, type the text you want to appear in the status bar when you rest the mouse pointer over the button. If you want to use the status bar text of the toolbar button on which the customized toolbar button is based, leave the Status Bar Text box blank.
11. If you want the customized toolbar button to use an icon that is different from that of the toolbar button on which it is based, click the Edit button, and then select the icon you want to use.
12. If you want the customized toolbar button to be added to the target diagram's toolbar buttons, rather than replacing all the target toolbar's buttons, select the Additive check box.
13. If you want the customized toolbar button to have a separator to its left, select the Separator Before check box.
14. Click the Script tab.
15. In the box, type the script you want to run after the toolbar button has been used to add an item to a diagram.
If you want to change the text in a larger window with the Text Format Toolbar available, click the Editor button.
Write the script within the available functions for a ToolbarCommand script. For more information about working with scripts, see:
Script functions, attributes and objects - diagram toolbar button script for adding links
Script functions, attributes and objects - diagram toolbar button script for adding nodes
Script functions, attributes and objects - overview
Script template for diagram toolbar button scripts for links
Script template for diagram toolbar button scripts for nodes
16. If you want to group the toolbar button with other Script applied toolbar buttons and specify which order those buttons appear, see Ordering script applied buttons on a customized diagram toolbar.
The customized toolbar button will be used by valid diagrams next time they are opened.