Procedurally generate Toolbars




I’m trying to generate a toolbar without using Rhino.
I designed a python script around a bit of retro engineering and a lot of empirical tests.
Having a toolbar with correct macros is done and working, but the bitmap (icons) part is still problematic

I’m not sure if the issue is with the image generation or the GUID system of Rhino.

For each icon size, the script takes all the icons needed and makes a ‘big one’, resulting in a column of icons. Then the image is translated to base64 format
Rhino doesn’t reconize these images ; they are not displayed, and upon saving the toolbar, all the previous icon data is replaced with a blank image. Something is definitely not working there …

Has somebody managed to do that before, or has an idea of what’s going wrong ?

Thank you

(Dale Fugier) #2

@JohnM, is this something you can help with?

– Dale

(Dale Fugier) #3

Hi @Alexandre_Beaudet,

Does this help?

– Dale


Oh thanks !

It does help !
Nice to know you’re wrapping at 250 images
However the only thing that differs from my code is the line break handling in base64 encoding …
I’ll check if my issue comes from there

Thank you again !


Ok big step forward, most of the icons are now displayed !
I missed the <bitmap>...</bitmap> tags around the actual base64 data !

So I said “most of the icons” …
I’ve got 3 images for my macros, and only the 2 first are displayed.
The base64 data seems correct (as seen through a base64 decoder)

I tried to create my file using Rhino and then make a diff between mine and Rhino’s and the only differences seem to be the guid values (and toolbar positioning) :frowning:



So I still have no idea why the third image is not displayed in my toolbar in Rhinoceros 5, but I just checked and I can tell you it works fine with Rhinoceros WIP :wink:


(Dale Fugier) #7

Hi @Alexandre_Beaudet,

You have not provided us enough details to help. If this is important to you, we will need some sample code that we can run here and that reproduces the behavior you’re describing.


– Dale


Ok here’s my script, with an example template : (32.7 KB)

  • The template.xml file describes an empty RUI file with @VARIABLES@ placed at strategic positions
  • The foo.json and bar.json are macro definition files. Multiple macros can be defined, each with a left/right click script, and an attached bitmap file (*.png file)
  • In the icons directory are the icons that will be embedded in the RUI. You can see they are of various sizes ; they will be resized to 32x32, 24x24 and 16x16 when serialized

To run :
py template.xml autogen.rui --macros foo.json bar.json

In this example, when loading the RUI with Rhino, the icon of the third macro still doesn’t show up

Tell me if you need more information on this.