Creating a "Donut" Face

I’ve been working with the API for some time now and whenever I need to create a hollow tube or some other similar type of geometry I typically use the followme or pushpull method after I’ve defined the face which dictates the OD and ID of the tube, which is all fine and good.

The dissatisfaction is with the way in which I generate the initial “donut” face that I will extrude. It always comes to some sort of convoluted creation of two circles and then deleting a face and then trying to find the remaining face so that I can utilize its handle. I can do it but it feels like such a hack.

Does anyone have or know of a more concise and direct approach to this problem?

Basically I’m just trying to create this simple geometry within the API:

1 Like

This is the best I can do:

innercircle = entitiestb1.add_circle centercircle, xaxis, inner_radius, @Numsegs_pipe_db
inner_face = entitiestb1.add_face(innercircle)
topcircle = entitiestb1.add_circle centercircle, xaxis, piperadius, @Numsegs_pipe_db
pipe_face = entitiestb1.add_face(topcircle)
inner_face.erase!

pipe_face.followme(pipe_path)

I guess it isn’t too bad when you look at it but its seems like an awful lot of code just to generate a donut face.

1 Like

I tend to use arc’s for the path as it gives more control…

model = Sketchup.active_model
entities = model.active_entities

#add_arc(center, xaxis, normal, radius, start_angle, end_angle, num_segments)
segs = 96
start_ang  = 0
end_ang = 360

path   = entities.add_arc( ORIGIN, X_AXIS, Z_AXIS, 100, start_ang.degrees, end_ang.degrees, segs )

center = path.first.start.position

vec = center.vector_to(path.first.end.position)
profile = entities.add_arc( center, Z_AXIS, vec, 10, 0.degrees, 360.degrees, 12 )
profile.first.find_faces
face = profile.first.curve.edges[0].faces[0]
face.followme(path)

I think I have a donut lurking somewhere…

edit: found one…

john

2 Likes