A script can add one or more items to the EPLAN ribbon. The convenient place to add these items is a function with [DeclareRegister] attribute, then the items are registered until the script is unloaded:
Removing a ribbon tab also removes its command groups and commands. Similarly, removing a command group also removes its commands.
A ribbon command is always connected with an action, which is called when the command is clicked. This means that either the script registers an additional action, or the command is assigned to an already existing action.
Please mind that users may start EPLAN in QUIET mode using W3u.exe /Quiet or the API could be initialized by an offline program. Because of this, it is not recommended to show .NET dialogs in the method marked by [DeclareRegister]. Please use Eplan.EplApi.Base.Decider class instead. If you encounter some problem during registering or initializing of a script, just create and throw a BaseException or use BaseException.FixMessage(...) to add the message to the system messages list.
The [DeclareRegister] attribute calls the function buttonWithAction() when the script is loaded. The function creates a new ribbon command "MyMenuText" and binds the action "HelloWorldAction" to it.
Possible problems with flickering and how to avoid them
When loading or unloading a script in which many ribbon items (tabs, command groups and commands) are added, a temporary flickering of the page navigator and other parts of the GUI may occur. The following procedure reduces this flickering to a minimum:
First, create a new RibbonBar object using the constructor that takes the boolean executeApplyAfterChanges parameter and set this parameter to "true".
Then, add all of your custom tabs, command groups and commands to this RibbonBar object, as in the following example: