Maybe that explains not being able to get the toolbars list as well?
Seems like these methods were created before the major V5 toolbars overhaul and never caught up with current toolbars implementation?
I just posted about trying to get all available toolbars list in a separate thread.
Yep. And there really is an good way to “catch up”, as the organization of toolbars, groups, etc., is quite different than in older Rhino’s. Your best option is to use RhinoCommon and Python. The ToolbarCollection class has all the information. You can get the one and only version of this using RhinoApp.ToolbarFiles.
Hi @dale, would you have any sample of how to get a list the toolbar names via RhinoCommon?
I can get the collection but not sure how to get it into an array of strings of toolbar names.
import Rhino
for rui in Rhino.RhinoApp.ToolbarFiles:
print rui.Path
for i in range(0, rui.ToolbarCount - 1):
tb = rui.GetToolbar(i)
print rui.Name + '.' + tb.Name
Thanks @Dale. Any ideas why some of the toolbars would not be listed? It lists the path correctly but does not list the toolbar names… Are there different versions or rui file, or some special way to deal with the legacy toolbars in case that is the issue?
The missing items are both Group and Toolbars.
I tried:
import Rhino
for rui in Rhino.RhinoApp.ToolbarFiles:
print rui.Path
for i in range(0, rui.GroupCount - 1):
gr = rui.GetGroup(i)
print gr.Name
but still don’t get many of them listed; I need a list that has them all, like the Middle Mouse button popup list nicely showing all of them to pick from.
I’d need to make this work if we can figure out why this doesnt work either
Here are 4 toolbars - from these, only Paneling Tools lists the toolbar names correctly with your script.
The other 3 just list the path, but no names. Some more toolbars here like default one work OK, btw, I am sending a sample problematic 3 + a working one… JB_toolbars.zip (229.5 KB)
This was a bug in the script sample, the range should be range(0, rui.ToolbarCount) instead of range(0, rui.ToolbarCount - 1). I used the following script to test:
import Rhino
print "Toolbars"
print "================================================================================"
for rui in Rhino.RhinoApp.ToolbarFiles:
print rui.Path
for i in range(0, rui.ToolbarCount):
tb = rui.GetToolbar(i)
print i, "->", rui.Name + '.' + tb.Name
print "Toolbar groups"
print "================================================================================"
for rui in Rhino.RhinoApp.ToolbarFiles:
print rui.Path
for i in range(0, rui.GroupCount):
gr = rui.GetGroup(i)
print i, "->", gr.Name
The above scripts reports the following with the four RUI files you provided: