Hyperboloid Ruby Script



This is the result of my first Ruby Script for Sketchup. I had never used Ruby before, it is very easy to pick up. Getting a hang of the Sketchup API was quite a challenge. I was going nowhere for a few days, then, something clicked and everything started to work.

Ruby is quite loose on data types and that led me to serious problems with the API. The API accepts triplets (arrays) for 3d points and vectors, but if you haven't declared a variable with a Geom::Point3d.new method, you will run into trouble! Another obvious newbie mistake is to ignore type definition within a formula, Ruby assumes the variable is an integer, you may think otherwise...

The shape generated is an Hyperboloid of Revolution. It is a ruled surface, which means it can be generated from straight lines. This property makes these surfaces easy to produce in real life. They are used in civil engineering, for instance for cooling towers of power stations.

You can download the script here. After installing, the script will create a "Hyperboloid" entry in the Plugins menu.

No comments: