Brep.CreatePatch Trim?

Hi,

I am trying to build a patch out of points and a boundary curve in C #. Below is the code. It creates the Brep, but no matter what, it doesn’t trim the Brep along the boundary. Do you have any suggestions?

private void RunScript(Curve edg, List<Point3d> pnts, ref object a)
{
    var gmtrs = new List<GeometryBase>();

    gmtrs.Add(edg); 
    gmtrs.AddRange(pnts.Select(p => new Rhino.Geometry.Point(p)));
    
    var tangency = new bool[4]{false, false, false, false};

    var m = Brep.CreatePatch(gmtrs, null, 10, 10, true, false, 0.7, 100, 100, tangency, 0.01);

    a = m;
}

To properly trim the Brep along the boundary curve, you need to begin by creating a starting surface. Here’s how you can modify your code:

private void RunScript(List<Curve> curves, List<Point3d> points, ref object a)
{
    var tolerance = RhinoDocument.ModelAbsoluteTolerance;
    var geometry = new List<GeometryBase>();
    geometry.AddRange(curves);
    geometry.AddRange(points.Select(p => new Rhino.Geometry.Point(p)));

    // Create a starting surface
    var startingSurface = Brep.CreatePatch(geometry, 20, 20, tolerance).Faces[0];

    // Create the final trimmed Brep
    a = Brep.CreatePatch(geometry, startingSurface, 20, 20, true, false, 0.7, 100.0, 0.01, new bool[4], tolerance);
}


Patch.gh (4.3 KB)

@Mahdiyar it works like a charm! Thanks much,

Best,
W