Polyhedra and Ruby script

I didn’t know whether to categorise this post as Extensions or Ruby API, so I just put it in Pro as a catch-all.
I was browsing around for freebie generators in connection with this thread and I came across this rather nice program.
http://gsolaar.sourceforge.net/

It will create all kinds of polyhedra, either by specifying the number of sides, or by entering the requisite Wythoff symbol (which in the case of the truncated icosahedron is 2 5|3…it seems there are several possible polyhedra with 34 faces.)

Anyhow, the program seems to export either as a pattern for a paper model…or as a SketchUp Ruby script. The only problem is that the script isn’t working on V2016. I’m not sure whether it’s syntax errors or just old Ruby 1. Certainly, the UI part of the code seems to be looking for the Plugins menu, suggesting it’s a little old.
Any gurus out there want to take a look at this. I figured it might be quite useful if a workflow could be established. Here’s the script for the illustrated figure.
IcosahedralConvexIsogonalPolyhedron.rb (12.2 KB)

Okay, sorted…kind of. It actually is the “Plugins” anachronism that seems to be causing the problem. Simply open the exported .rb in Notepad and edit it to “Extensions” then copy it into the Ruby console and you’ll find the script in the GSolaar sub-menu. I guess it would be possible to compile dozens of these scripts into an off-the-peg folder.

trunc_icos.skp (53.1 KB)

1 Like

It’s an interesting approach … generating the node information and then exporting it as a Ruby plugin for SketchUp. Since the scripts use fixed coordinate data, I assume you plan to have a number of them for each type of polyhedron you’ve created? Another approach would be to run the plugins once each and then save the result as a component. This provides a more standard library of shapes than a collection of scripts.

The sample script you posted created a 38.6KB file which is about 3 times the size of the script itself. However, as you accumulate more and more scripts, they can slow down the initial launch time for SketchUp.

Neat software :slight_smile:
polyhedron1.skp (38.6 KB)

Yes, compiling a component collection would probably be a better way to go…especially as there are no parametrics involved in running the Ruby script. You just get what you’re given (which appears to be about 10 metres in diameter for the ones I’ve measured.) Maybe components of 1 ft / 30 cm might be better. Easy enough to size to suit.

UI.menu('Plugins') should work in SU2016 as well. It is the recommended string to use if you want to make it copatible with post and pre SU2016. Maybe because it says PlugIns instead of Plugins? (Thought I though it was case-insensitive.)

Thom, you’re absolutely right on both counts. The scripts do in fact work straight out of Solaar. I don’t know how I missed the new menu entry the first time around.

It is currently an external utility, so it goes in Extensions. (Moved it.) It is okay to have a little Ruby talk in this category, since dealing with extensions requires it.

Any really heavy discussion of porting this to an internal SketchUp extension would be best done in a “sister” topic in the Ruby category. A notice post for cross-reference can be added here in this thread (for courtesy sake.)

@AlanF, did you try the importer that seems to avoid the need for the ruby scripts?

it’s a .rbz extension and quite recent…

john

I haven’t tried that, John. Thanks for the heads up. The usual way I install a simple .rb file is to zip it then change the file extension to rbz and go through Preferences.
It also occurred to me that as people probably don’t need to use these very often, you could load a few of the more useful ones then turn them on and off with the Sketchucation Plugin Manager, as needed.