How to draw a circle and pull as a cylinder then scale the top face inside by 0.1?


Here is my code:

edges = entities.add_circle [0,0,0], [1,0,0], 100
face_bottom = entities.add_face edges
face_bottom.pushpull 200

but I don’t know how to get the top face and scale it?


To find the face try this:

top_face = { |e| e.is_a?(Sketchup::Face) && e.normal.samedirection(Z_AXIS)  }

To scale it around its own center, try this:

transformation = Geom::Transformation.scaling(, 0.1)
entities.transform_entities(transformation, [top_face])

I haven’t tested the code so there can be spelling errors and such, but hopefully it should get you in the right direction.


it works, thanks for the help!


@xiaowang - please make sure to format code examples in code blocks. That makes it a lot easier to read.

You can use the toolbar in the editor after selecting your code block:

Or you can wrap them up manually by using three backticks: ``` before and after the code.