2

What I need to accomplish is basically a cylinder whose walls have zero thickness. Now if you need to understand better what I mean by this, imagine manually drawing a circle, then using the pushpull tool to make it a cylinder, after which you delete the top and bottom faces. At first, I used the method suggested in this post:

Punching a hole through a cylinder using Sketchup Ruby API

where the outer and inner radii had a difference of about 1e-02 meters, but now I realize it actually has to be an infinitesimal thickness, one where no matter how far you zoom-in, all you see is a line.

I went about trying to accomplish this with the following basic snippet of code:

entities = Sketchup.active_model.active_entities

circle = entities.add_circle(Geom::Point3d.new(0,0,0), Geom::Vector3d.new(0,0,1), 20)
face = entities.add_face(circle)
face.pushpull(-10, true)

# now from here, it can be either pushpulled downwards by the same amount (10 in this case
# leaving only a bottom face)
# or the entity 'face' can be erased (leaving only a top face) as in the following

entities.erase_entities(face)

so my question is, how do I remove both faces so as to leave only the cylinder?

Thank you.

Community
  • 1
  • 1
knotwhirl
  • 21
  • 3
  • Dyounis, you might consider also asking at Sketchucation.com and the Google Sketchup API group. Learning that API is on my todo list. I'd appreciate any advice you could offer on the best way of going about that. If you'd prefer to email, my address is in my profile. – Cary Swoveland Jul 09 '14 at 07:20
  • Thanks, and I'm only about 4 weeks into SketchUp itself, but the path I followed began with the Developer Docs: http://www.sketchup.com/intl/en/developer/index unfortunately there are few actual tutorials and from then on it's all documentation. Familiarity with ruby isn't important, there's more of a focus on the methods specific to the API and object creation. So experiment and jump right into the project you had in mind, researching as you go along. This is actually a small component of my current project (which will probably be my only project with the Ruby API, unfortunately). – knotwhirl Jul 09 '14 at 12:05
  • You could check the normals of the faces in the entities and erase the ones that aren't vertical. Saves you from doing two push pull operations. – thomthom Jul 10 '14 at 07:56

1 Answers1

0

I found the answer, the solution is to do both. That is, pushpull inwards the same amount, then delete the face with: entities.erase_entities(face).

entities = Sketchup.active_model.active_entities

circle = entities.add_circle(Geom::Point3d.new(0,0,0), Geom::Vector3d.new(0,0,1), 20)
face = entities.add_face(circle)

face.pushpull(-10, true)
face.pushpull(10, true)

entities.erase_entities(face)
knotwhirl
  • 21
  • 3