Here is a simple command example that prompts for a tool bar group name, iterates the open RUI file list and closes the first group found in a file.
public class CloseToolBarGroupExampleCommand : Command
{
public CloseToolBarGroupExampleCommand()
{
// Rhino only creates one instance of each command class defined in a
// plug-in, so it is safe to store a refence in a static property.
Instance = this;
}
///<summary>The only instance of this command.</summary>
public static CloseToolBarGroupExampleCommand Instance
{
get; private set;
}
///<returns>The command name as it appears on the Rhino command line.</returns>
public override string EnglishName
{
get { return "CloseToolBarGroupExampleCommand"; }
}
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
var tool_bar_to_close = m_tool_bar_to_close;
var success = RhinoGet.GetString("ToolBar group to close", !string.IsNullOrEmpty((m_tool_bar_to_close)), ref tool_bar_to_close);
if (success != Result.Success)
return success;
if (string.IsNullOrWhiteSpace(tool_bar_to_close))
{
RhinoApp.WriteLine("Tool bar group name can't be empty");
return Result.Failure;
}
foreach (var file in RhinoApp.ToolbarFiles)
{
var group = file.GetGroup(tool_bar_to_close);
if (group == null)
continue;
group.Visible = false;
m_tool_bar_to_close = tool_bar_to_close;
RhinoApp.WriteLine($"Group '{group.Name}' hidden in file '{file.Name}'");
return Result.Success;
}
RhinoApp.WriteLine($"Can't find tool bar named '{tool_bar_to_close}' in any currently open RUI file.");
return Result.Failure;
}
private string m_tool_bar_to_close;
}
Thanks for the answer. From digging around it was also what I was kind of expecting.
I guess the Rhino.UI.Toolbar needs an Visible boolean.
Is there any information or examples on how the terminology in Rhino (and in the Workspace Editor, thinking stuff like Toolbar, Groups, Tabs, etc.) translates into RhinoCommen (Toolbar, ToolbarFile, ToolbarGroup, etc.)? It would be much appreciated.
As our users move the toolsbar-tab around we will rename the tab to include the version of the plugin as a workaround.
There is some basic tool bar information available in this help topic. Tool bars, macros, menus and such are defined and saved in a Rhino RUI file, the following is a description of the different RUI sections and what they represent:
Macros
Macros contain executable script and visual style information. Following are some of the macro properties:
Script
Bitmap Id (used when referenced by a menu or tool bar item)
Menu text
Tool bar button text
Bitmaps
Small (menu)
Normal (default toolbar button size)
Large (used for high DPI settings)
Tool bars
A tool bar is visually represented as a tab that may appear in one or more tool bar groups. A tool bar definition contains:
A name or title that appears as tab text.
Bitmap which may appear next to or instead of the tab text.
A collection of tool bar items which contain left and right macro macro Id’s.
Tool bar group
A tool bar group is a collection of tabs gathered in a container that may be either docked or floating. A tool bar group definition contains:
Name which appears at the top of the floating container when a group is floating and not docked.
Some style options regarding how to display the tabs which can contain text, a bitmap or both.
Ordered list of tool bar group items which contain tool bar id’s to be displayed as tabs in the group.
The active tool bar tab.
Menus
Menus get inserted to the left of the standard Rhino Help menu and contain a list of macros and submenus to be added to the standard Rhino menu bar. There is a special menu section used to define where it insert or extend the standard Rhino menus.