How to use a line and arc to create a face?

I want to script up making a stair tread. Its cross section would be 3 lines and a semi-circle. I want to make a face from those pieces, and then push pull it for the width. I’ve looked at the “entities” documentation, and see the line/arc/etc. creation methods, but how do I stitch them together to make a cross section face? Just a simple description should be enough (I don’t think I need example code, yet). Thanks.

Once you draw your profile, pick any one of the edges and use Edge#find_faces.

Since find_faces does not return a Face, you need to find the added Face, then use Face#pushpull

See also: Homepage | SketchUp Developer

I would guess you probably want to create the tread as a Component.

The actual drawing is going to be similar to drawing in the Model. The difference is which Entities you add the geometry to.

Create a new ComponentDefinition in the Model’s DefinitionList. Then add the geometry to the Definition’s Entities collection instead of the Model’s Entities collection.

Adding to what Jim said, the search for the Face created by find_faces is simpler if you work within a new ComponentDefinition’s entities because there is no additional geometry there. The only Face in the collection must be the one you want!

Thanks for the tips. I used edge.find_faces, and then edge.faces, to create/find my face to pushpull. But I now see pushpull surprises (like when a face with z=0 is pushpull’d). My face normal ended up being in -z direction, so my face (at z=1) goes “down”, when I expected “up”. So my first question is: Can I predict the face’s normal when I connect lines and arcs? Considering a cross section where the front of the step is to the right, my points consist of the upper right of a rectangle, upper left (ur), lower left, and lower right. To this I add an arc (semi-circle) to be the front of the step. I initially drew with add_line(lr,ll), add_line(ll,ul), add_line(ul,ur), add_arc(center=(lr+ur)/2, X=1,0,0, normal=0,0,1, radius=(ury-lry)/2, -90deg, +90deg, 4 edges). When pushpull’d, the solid went down. I then changed the order to add_line(ur,ul), add_line(ul,ll), add_line(ll,lr), add_arc (same as above). When this was pushpull’d, it went up, kind of like what I would have expected from a “right hand rule” with edge drawing proceeding ccw. So is the final normal from some thinking about the edges that made the face, from a random edge, etc.? Also, it wasn’t obvious, and I couldn’t find in searching, which way does an arc’s edge generation proceed from start_angle to end_angle, ccw or cw? It does what I expected using -90 for a start and 90 for an end, so was I lucky? I’d like to know which half of a circle I’ll be getting. Since I’ll be making more than one, Components sound like the way to go. Thanks.

Ordinarily SketchUp orients a new surface so that if the outline traces counterclockwise as you look at the points, the normal vector points toward you (right-hand rule). However, there are some special cases that violate this general rule. The most common is that when you create a face at z=0 the normal is always oriented down (-z) regardless of how you ordered the outline. So, before pushpull it is generally a good idea to check whether the face’s normal is pointed the way you want and reverse the face if not.