Trying to open a toolbar through python and making sure it is visible.I have found some examples using C# but am having trouble with Python.
I can open it with Rhino.RhinoApp.ToolbarFiles.Open(Path) and I can find it with Rhino.RhinoApp.ToolbarFiles.FindByName(Name), but I am having trouble with making it visible.
After talking to the bot for a while, this is what I arrived at. It seems to find the group and the toolbar, but nothing is being turned on.
import Rhino
import scriptcontext as sc
import os
import rhinoscriptsyntax as rs
# Define the file path to your toolbar file
file_path = "path to RUI" # Ensure the path is correct
Rhino.RhinoApp.ToolbarFiles.Open(file_path)
# Get the list of toolbar collection names
toolbar_names = rs.ToolbarCollectionNames()
# Define the target group and toolbar names
target_group = "group"
target_toolbar = "name of toolbar"
# Check if the target group exists in the collection
if target_group in toolbar_names:
print(f"The group '{target_group}' is found in the toolbar collection.")
# Get the list of toolbars in the target group
toolbars = rs.ToolbarNames(target_group)
# Check if the target toolbar exists in the list of toolbars
if target_toolbar in toolbars:
print(f"The toolbar '{target_toolbar}' is found in the group '{target_group}'.")
# Make the target toolbar visible
rs.ShowToolbar(target_group, target_toolbar)
print(f"The toolbar '{target_toolbar}' has been made visible.")
else:
print(f"The toolbar '{target_toolbar}' is NOT found in the group '{target_group}'.")
else:
print(f"The group '{target_group}' is NOT found in the toolbar collection.")