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 ?
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
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)
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
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.
Ok here’s my script, with an example template : rui-generator.zip (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 rui-generator.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.
Alexandre
@dale Yes. Where’s the FullBitmap variable defined and what’s its type? I don’t understand from the snippet how the bitmap for the toolbar icons is actually created. It appears that FullBitmap.Save(...) is used for saving a toolbar icon in the correct format, but I don’t understand what it’s type is so I could use it myself.
The macro bitmap is stored in the bitmap grid located in the appropriate section of the RUI file. The raw 32 bit uncompressed PNG is encoded and stored in the section for each of the three bitmaps.
FullBitmap is created internal as FullBitmap = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format32bppPArgb);