Project curve to brep

Hello to all,
in C# I’m trying to project a curve on to a surface. The surface is trimmed.
Then I convert the surface to brep.

Brep bed = srf.ToBrep();
    bed.Compact();

then I project the curve onto the brep like this:
arrProCrv = Curve.ProjectToBrep(c, bed, vecDir, 0.01);

what I got is the projection of the curve in the original surface and not in the actual geometry.

What I need as result are the blue lines.

I also try transforming the brep to mesh.
should I project onto the brep face instead of the brep?

any clue will help.

thanks in advance
Carlos

Hi Carlos,

This is not going to create a trimmed Brep. Rather, this will create a Brep that has a single face and that face is geometrically the same as the underlying surface.

If you run Brep.IsSurface, I’m sure true is returned.

Can you post your geometry and some same source code that isn’t working for you?

– Dale

Hello Dale,
Thank you very much.
Please find attached the geometry and code

thanks in advance,
kind regards
Carlos

srf.3dm (5.0 MB)

and the code is here:

  List<Curve> ProjectedCurves(List<Curve> lstC, Plane pl, Surface srf)
  {
    Brep bed = srf.ToBrep();
    bed.Compact();
    Rhino.Geometry.Collections.BrepFaceList bfl = bed.Faces;
    bfl.ShrinkFaces(); // some test
    Brep br = bfl[0].ToBrep(); // some test
    //List < Face> faceList = bed.Faces;

    Vector3d vecDir = VectorCorrection(pl);

    List<Curve> lstCrvProjected = new List<Curve>();
    Curve[] arrProCrv;
    foreach(Curve c in lstC)
    {
      arrProCrv = Curve.ProjectToBrep(c, bed, vecDir, 0.001);
      if(arrProCrv.Length > 0)
      {
        lstCrvProjected.Add(arrProCrv[0]);
      }
    }
    return lstCrvProjected;
  }

you might need this method also:

  Vector3d VectorCorrection(Plane pl)
  {
    Vector3d vecA = pl.ZAxis;
    Point3d ptO = pl.Origin;
    Point3d endPt = ptO + vecA;
    Point3d center = new Point3d(0, 0, 0);

    if(endPt.DistanceTo(center) < ptO.DistanceTo(center))
    {
      vecA.Reverse();
    }

    return vecA;
  }

Well, your code is incomplete and your model doesn’t contain any curves…

But if you need a sample of how to project a set of curves onto a planar Brep face, here is one.

https://github.com/dalefugier/SampleCsCommands/blob/master/SampleCsProjectCurvesToBrep.cs

– Dale

Hi Dale,
sorry, I thought you only want interested in the the part of the code where the projection occurs.
please have a look the full code.

kind regards
Thanks in advance
c.
panels Seam code.gh (8.3 KB)