Region difference discrepancy between rhinocommon and gh

Perhaps a bug that’s addressed in WIP but love to have it working in Rhino 6
The grasshopper native component region difference works.
I call the rhinocommon equivalent in a c# component, but it fails.

regiondiff.gh (4.2 KB)

I also ran into this issue today. Can someone advise me how to get the same result using C# as the Grasshopper “Region Difference” component? In this image below, I can get the ideal result (green colored regions) using the Grasshopper Region Difference component from two sets of curves (blue and red color). However, CreateBooleanDifference from RhinoCommon outputs all the boolean result regions including unnecessary regions.

  private void RunScript(List<Curve> outlines, List<Curve> curves, ref object R)
  {

    double tolerance = RhinoDoc.ActiveDoc.ModelAbsoluteTolerance;
    List<Curve> resultCurves = new List<Curve>();

    for (int i = 0; i < outlines.Count; i++)
    {
      Curve[] trimmedCurves = Curve.CreateBooleanDifference(outlines[i], curves, tolerance);
      resultCurves.AddRange(trimmedCurves);
    }

    R = resultCurves;
  }

I’m attaching the example file. Thank you.RegionDifference.gh (13.5 KB)

I’ve got the same thing going on here - GH region difference works, but the rhinocommon version fails every time in odd ways - any advice on how to improve the calculation time for this would be much appreciated.

Sash


private void RunScript(DataTree<Brep> brepTree, List<Curve> x, List<Curve> y, ref object A)
  {

    double tolerance = Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance;
    int branch = 0;
    DataTree<Curve> resTree = new DataTree<Curve>();
    foreach(List<Brep> breps in brepTree.Branches)
    {
      Brep brep = breps[0];
      GH_Path path = brepTree.Paths[branch];
      List<Curve> intCrvs = new List<Curve>();
      Curve[] crvsX;
      Point3d[] ptsX;
      for (int i = 0; i < x.Count; i++)
      {
        Rhino.Geometry.Intersect.Intersection.CurveBrep(x[i], brep, tolerance, out crvsX, out ptsX);

        if(crvsX.Length > 0)
        {
          intCrvs.Add(x[i]);
        }
      }
      Curve[] joined = Curve.CreateBooleanUnion(intCrvs, tolerance);
      Curve[] edges = Curve.JoinCurves(brep.DuplicateNakedEdgeCurves(true, false));
      Curve[] resCurve = Curve.CreateBooleanDifference(edges[0], joined, tolerance);

      resTree.AddRange(resCurve, path);
      branch++;
    }
    A = resTree;
  }

RegionDiffMisbehave.gh (545.7 KB)

The difference between the Region Difference component and the RhinoCommon equivalent seems to have been fixed in V7 and the V8 WIP.

Don’t think you’ll ever see this fixed in V6.

-Kevin

Damn, a girl can dream

confirmed