Hi,
We are working on upgrading one of our Rhino plugins from Rhino 7 to Rhino 8. We came across the following bug with ProjectToPlane for specific breps and curves.
The code below creates a sphere with a cylinder that removes the center of it. When you project the faces of the Brep to the world xy plane it works fine and generates the curves as shown below. In Rhino 7 it works fine, but in Rhino 8 it fails.
var rhinoDoc = RhinoDoc.ActiveDoc;
Point3d sphereCenter = new Point3d(0, 0, 0);
double sphereRadius = 10;
Sphere sphere = new Sphere(sphereCenter, sphereRadius);
Brep brepSphere = Brep.CreateFromSphere(sphere);
Circle cylinderBase = new Circle(sphereCenter, 5);
double cylinderHeight = 20;
Cylinder cylinder = new Cylinder(cylinderBase, cylinderHeight);
Brep brepCylinder = Brep.CreateFromCylinder(cylinder, false, false);
Brep[] brepDifference = Brep.CreateBooleanDifference(new[] { brepSphere }, new[] { brepCylinder }, 0.001);
Brep brep = brepDifference[0];
rhinoDoc.Objects.Add(brep);
Plane testPlane = new Plane(Point3d.Origin, Vector3d.ZAxis);
foreach (var face in brep.Faces)
{
var loop = face.OuterLoop.To3dCurve();
var newLoop = Curve.ProjectToPlane(loop, testPlane);
if (newLoop is not null)
{
rhinoDoc.Objects.Add(newLoop);
}
}
In case it matters, this was tested on Rhino 8.19.25132.1001 and Rhino 7.27.23032.13001 on Windows.
This particular API call is used quite a bit in our plugin, so it would be good to know what exactly triggers this failure. A workaround could go a long way as well.
