Create Face from a Surface and 2D Curve?

Is there Python API to create a Face object, given a Surface (or another Face) and trimming 2D Curve in surface’s UV space (or maybe sequence of curves, or wire)?

Here is an example script :

l2d = Part.Geom2d.Line2dSegment
vec = FreeCAD.Base.Vector2d

l1 = l2d(vec(0.5, 0), vec(3, 0.5))
l2 = l2d(vec(3, 0.5), vec(4,1.0))
l3 = l2d(vec(4, 1.0), vec(0,1.2))
l4 = l2d(vec(0, 1.2), vec(0.5, 0))

sphere = Part.Sphere()
edges = [l.toShape(sphere) for l in [l1, l2, l3, l4]]
wire = Part.Wire(edges)
face = Part.Face(sphere, wire)
Part.show(face)

Thanks, it works! :slight_smile: