Create a cone frustum in Sketchup using Ruby

I need to create a conic frustum in Ruby in SketchUp.

By hand in the GUI, this is easily accomplished by creating a circle, doing a push-pull to get a cylinder, and then choosing a point on the top of the cylinder and "move"ing it along the X-axis to adjust the top circular face radius.

Using the Ruby API, I can’t quite figure out how to grab the point on the top circular face and move it along the X-axis.

Here’s my code so far:

#Create cylinder
pt1 =, 0, heightToLayerBottom)
vt1 =, 0, 1)
model.start_operation “Cylinder”
numSides = 96
edges = entities.add_circle(pt1, vt1, bottomRadius, numSides)
face = entities.add_face edges
layerHeight = -layerHeight if( < 0 ) #Guarantees this goes “up” the Z-axis
face.pushpull layerHeight

Now, however, I don’t know how to proceed. I need to get the top face, get the point on this face that intersects with the X-axis, and then move this point along the X-axis a predetermined distance to change the diameter of the top face.

For this case, I will always have a bottom and top face circle centered at (0,0) for X and Y, with a vertical (Z) push-pull cylinder.

Can anyone help?

Go to the Extension Warehouse and install the SketchUp Team’s example Shapes extension. Look at how they create a Cone.

I’m not a great Ruby programmer, but I think that if you can identify the top face in Ruby, you could use a Scale transform to scale the top face uniformly about its centre, in the x - y plane.

See API docs for Geom::Transformation.scaling

Yes that could work, as well as drawing a half section profile, and a reference circle, calling the followme method.

finding the top face is trivial if you know the context and you know the height…

you do if you made them, but make everything in a group to guarantee context …

top_face = cyl_grp_ents.grep(Sketchup::Face) { |f| f if == height }.compact!

# possibly even 
 top_face = cyl_grp_ents.grep(Sketchup::Face)[-1]