Monday, May 19, 2008


The norms for software documentation are astounding...but don't get me started.

While evaluating ruby and the Sketchup Ruby API, I created* a slightly improved interface to Google's "SketchUp Ruby API Deveoper'sGuide " (sic).

The sidebar shows Class.method and links to the online documentation.
(A dynamically generated imagemap diagram is the obvious answer here. )

Of course, you still need to do detective work to figure out what objects belong to what classes, etc. (sheesh!). Here are a few things I figured out:

Sketchup.active_model.active_entities returns an "Entities" object that has all the goodies in it, and all the methods for adding goodies:

Sketchup.active_model.active_entities.selection #get an array of handles

The .add_... methods return Faces, Edges, Groups, etc. with their own methods (all are derived from the DrawingElement class.). Thus, Face.pushpull 10 turns a face into a volume (see the example below)

Each entity has methods that include .add_observer and .move!

.move and other transformations use the Transformation and Geom classes (still mysterious; help welcome)

Here's a little script:
#Put this in e.g.,
# /Library/Application Support/Google Sketchup 6/SketchUp/Plugins/RubyTests
# load it from the console:
# load 'RubyTests/myTut.rb'

model = Sketchup.active_model
$entities = model.active_entities
#the model has entities.

#let’s make a triangle
point1 = [0, 0, 0] #origin; NB: sketchup Arrays have geometric mojo
point2 = [20, 20, 20]
point3 = [10, 0, 0]
tri = $entities.add_edges point1, point2, point3, point1

#let’s fill it and make a face
$f=$entities.add_face point1, point2, point3, point1

#let’s extend it
$f.pushpull 10

* using python ;->