# Creating a face with arcs and lines

Normally I use the add_face method to create a face and looking at the documentation I should be able to use the same method where I have a number of points along with a couple arcs that will define the geometry of the face. The funny thing is I have never run into this before, I’ve only had to deal with polygon faces (only straight segments) or circles.

Does anyone have an example of creating a face with the add_face method that involves straight segments (ie. points) and arc(s)?

In order to include an arc into the add_face() signature you need to convert the arc into it’s constituent point array. Here is code that creates an arc, a point, then calls add_face() with the point appended to the arc point array.

`````` leftCurve=theGroup.entities.add_arc([-50-,50,0],Geom::Vector3d.new(1,0,0),Geom::Vector3d.new(0,0,1),50,0.degrees,90.degrees,8)
pt2=0,0,0

I am more inclined to use `#find_faces`

so adding to the API `#add_arc` example

``````centerpoint = Geom::Point3d.new
# Create a circle perpendicular to the normal or Z axis
vector = Geom::Vector3d.new 0,0,1
vector2 = Geom::Vector3d.new 1,0,0
vector3 = vector.normalize!
model = Sketchup.active_model
entities = model.active_entities
edges = entities.add_arc centerpoint, vector2, vector3, 10, 15.degrees, 135.degrees
arccurve = edges.first.curve
###
# add an edge to close the arc.
# let the edge find it's own face.
closer.find_faces
``````

john

1 Like

Thank-you for both or your examples I learn something new every day when it comes to the Sketchup API.

1 Like

One potential subtle difference between the two approaches: in @john_drivenupthewall 's technique, #find_faces will find all faces bordered by the closer line, not just the one bounded by the new geometry you just created. I’m not sure whether #add_face in @JimG’s method will also find adjacent faces or only the one you added (not where I can check right now). But in either case, you might consider enclosing the geometry in a group if you don’t want to affect anything else.

find_faces draws every possible face that ca be drawn, similar to what SketchUp does when you draw edges through the UI. When creating a drawing tool that draws edges this is useful to match the native behavior but when making a plugin that draws more high level stuff you typically want to specify yourself exactly what faces to draw.

I’d typically use add_face with the series of edges or the points as arguments.

`add_face` also accepts edges. You can create edges up front and then create the face.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.