Toggle Toolbar visibility programmatically?

is there a possibility to toggle the visibility of a toolbar .rui file from the SDK?
I’m aware of the toolbar handling in principle (like described here: Rhino - Creating and Deploying Plugin Toolbars)

So I can distribute successfully a toolbar with my PlugIn installation. What I want now is to deploy more than one toolbar with my PlugIn (so I cannot follow the convention to have a toolbar named like my PlugIn followed by .rui extension). And depending my GUI and probably a license code I would like to switch visibility of my toolbars.

I tried several things using CRhinoFileUtilities::XXX() functionality (copying different toolbars to be the default toolbar in my install folder or/and the APPDATA folder) but in this case I may have permission problems there if the user executing the PlugIn has no admin privileges.

So the best way seems to be to deploy several toolbars with my PlugIn and make them optionally appear/disappear. Since Rhino can do this in commands like _showtoolbar I would assume there are some SDK calls for this?

Many thanks

Hi Peter,

The toolbars in Rhino 7 are .NET-based. Thus, the SDK support for them is somewhat limited.

The Rhino C++ SDK has a CRhinoUiFile class, which contains a number of static functions, that should give you most of what you need.

Let me know if you have any questions.

– Dale


Hi Dale,
thanks for the quick answer.
I looked into CRhinoUiFile, but it looks as if I can find out some information about toolbars (like number of toolbars, ID etc.) but cannot change anything.

Since I can drag and drop a .rui file to Rhino which loads it and makes it visible I was assuming there must be some code doing this.

Or should I look to the group access methods in CRhinoUiFile?

  • Peter

Hello Peter,

Under the hood Rhino copies plug-in associated RUI files to a directory located int %APPDATA%\McNeel\Rhinoceros\<rhino version>\UI\Plug-ins then loads the copied file. This allows changes to the file to be written when Rhino closes. You can use CRhinoUiFile::FileOpen() to load a RUI file in your CRhinoPlugIn::OnLoadPlugIn override.

Tool-bars represent the tabs that are displayed in a tool-bar group, a group is the container that is displayed and contains references to one or more tool-bar objects. You can use CRhinoUiFile::GroupIsVisible to see if a group is visible and CRhinoUiFile::GroupShow to show or hide a specific group when your plug-in loads.

The problem you may encounter is that if you plug-in is loaded at start up your OnLoadPlugIn will be called prior to Rhino’s UI restoration code. The net result is your plug-in’s OnLoad will display/hide a group but the restoration code will then return the group to the visibility state the users chose when Rhion last closed. This means if the user chose to hide the group it will be hidden for the user next time Rhino starts.

Hi John,
thanks a lot, this seems to work!
I added a toggle in my GUI which switches a toolbar successfully on and off.
I’ll look, how I embed it into my PlugIn init.