Ruby

In the course of assisting someone on the FlightGear forums with a problem, I sort of volunteered to write a custom exporter for SketchUp – using its Ruby API. Writing a 3D exporter isn’t quite the typical first project in a language, but it’s not exactly unfamiliar territory for me either. 

Overall, Ruby is what I expected – very similar to Python, with some syntactic niceties and some oddities, and of course without the scoping-via-indentation that causes such ire. The standard library has some odd gaps (or perhaps I overlooked the classes I was supposed to use) but manipulating maps and arrays of mesh data is easy and tidy. There’s also a nice syntax for expanding variables in strings, which makes writing out text files pretty clean.

The SketchUp API itself is pretty reasonable, though there’s some weak points in the documentation. Fortunately other people have figured out the hidden secrets, making my life easier. Best thing so far – one call which supposedly takes zero args, actually takes a magic integer argument (in reality a bit-field I think) which controls which data is produced. This shows up as ‘7’ or ‘5’ in the .X and OGRE exporters I was learning from.

Posted Saturday, September 6th, 2008 under 3d, code.

2 comments

  1. I’ve been playing around with Ruby on Rails recently, and have been very impressed. Compared to JSP/servlets, which I’d done a little of before, it is embarrassingly easy to get a basic webapp set up.

  2. Cynically, I’d say that’s more about how tedious JSP is than Ruby’s simplicity. It’s certainly nice, but I don’t (so far) perceive any large difference between it and PHP or Python for web use.

Leave a Reply