Extrusion Bounding Box behaviour different in Rhino 7 and Rhino 8

Hi,

We are working on upgrading one of our Rhino plugins from Rhino 7 to Rhino 8. We came across this bug with extrusion objects and bounding boxes.

If you run the code below on Rhino 7 you will get a a bounding box that correctly fits the geometry. However, if you run the same code in Rhino 8, you get an incorrect bounding box that is way too big.

		var rhinoDoc = RhinoDoc.ActiveDoc;

		var polylineCurve = new PolylineCurve(new Polyline()
		{
			new(0, 0, 0),
			new (3271, 1947, 0),
			new (3348, 1993, 0),
			new (3339, 2368, 0),
			new (-7217, 2368, 0),
			new (-8527, 1295, 0),
			new (-5107, 0, 0),
			new (0, 0, 0),
		});
		var extrusion = Extrusion.Create(polylineCurve, 37, true);

		var localPlane = new Plane(
			Point3d.Origin,
			new Vector3d(0.8592956334680628, 0.5114792413214057, 0),
			new Vector3d(-0.5114792413214057, 0.859295633468062, 0)
		);

		var grainPlane = new Plane(localPlane);
		grainPlane.Rotate(5.2093745710934982, Vector3d.ZAxis);

		var transform = Transform.ChangeBasis(Plane.WorldXY, localPlane);
		extrusion.Transform(transform);

		var id = rhinoDoc.Objects.Add(extrusion);
		// extrusion = rhinoDoc.Objects.FindGeometry(id) as Extrusion;

		var box = new Box(grainPlane, extrusion);
		var brep = box.ToBrep();

		rhinoDoc.Objects.Add(brep);

On Rhino 7 it will look like this. The bounding box is in green.

On Rhino 8 it will instead look like this.

It seems to resolve itself if you retrieve the object that was added to the rhinoDoc. You can do so by uncommenting the commented line in the code above.

I checked the breps generated by the extrusion and the second extrusion created when added to the Rhino document. Both seem identical according to GeometryBase.GeometryEquals. Our internal brep hashing code also shows that they are identical. I also tried to generate the box with Extrusion.GetBoundingBox but is has the same result.

In case it matters, this was tested on Rhino 8.19.25132.1001 and Rhino 7.27.23032.13001 on Windows.

Would anyone have any ideas on how to fix this, or find a workaround? Unfortunately for us just adding the object to Rhino is not a viable solution. Our plugin does the geometry rendering directly in the pipeline, so these objects are not added to Rhino in our case.

@csykes @CallumSykes Any thoughts on this?

Hello hello @SK-Structurecraft!

Thanks so much for all these instructions, they make it so much easier to fix. I’m not a geometry guy, but trying your code in Rhino 7 it works, in 8 it does exactly as you describe and is still an issue in Rhino 9 WIP.

I’ve created a ticket here for the issue → https://mcneel.myjetbrains.com/youtrack/issue/RH-89799/Extrusion-Bounding-Box-behaviour-different-in-Rhino-7-and-Rhino-8 so that someone who does knto about this stuff can take a look.

Thanks, appreciate that. It is a bit of a blocker for us, so it would be nice to have a fix or a workaround.

Expect some more post in the near future as we work through our upgrade.

I think staying away from extrusions might help…

Saw in the ticket RH-89799 that the following workaround is suggested.

var box = new Box(grainPlane, extrusion.ToBrep());

Confirmed that this does seem to work and that the box now is correct. We’ll test it internally for any side-effects and how it affects performance, but initially it looks good.

While this works for extrusions it might not work for the more general case of using GeometryBase objects for creating the box. There are also some performance issues with using ToBrep since using breps is a lot slower than just using the Rhino.Geometry objects.

We can probably work with this for now, but a longer term fix would still be needed.

Hi @SK-Structurecraft - I’m hoping to have time to look at this today.

– Dale

RH-89799 is fixed in Rhino 8 Service Release 25