Python: Center of a trimmed NURBS Surface

What’s the easiest way to get the center of a trimmed NURBS surface? I looked at GetBoundingBox but that gets the plane (untrimmed) of the surface.

Hi Mike - GetBoundingBox(True) should do it.

-Pascal

Also depends on what you consider to be the “center”… Maybe the area centroid? If it’s not planar, it might not actually be on the surface…

This red NURBS surface is what I’m trying to get the “general” center of to simply place some text. I’m not worried about center vs centroid.

Trimmed NURBS Surface

In my code I retrieved the BoundingBox passing True as the parameter and drawing a rectangle in according to what I retrieve back. Then I add the text according to the center of the bounding box.

The bounding box is showing this is a trimmed surface on the lower side. How do I get the center of the trimmed surface, not the untrimmed part of it?

I was thinking maybe I need to take a look at the vertices since I have access to the original brep and there are 3 vertices. Then I could calculate the center based off of that. I was thinking there should be a faster/easier way than that.

            objSBB = objS.GetBoundingBox(True)
            rs.AddText('test', objSBB.Center, 1, None, 0, 2 + 131072)
            rec = rs.AddRectangle(rs.WorldXYPlane(), objSBB.Max.X - objSBB.Min.X, objSBB.Max.Y - objSBB.Min.Y)
            trans = rg.Vector3d(objSBB.Min.X, objSBB.Min.Y, objSBB.Min.Z)
            rs.MoveObject(rec, trans)

Hi Mike - I think I’d look at getting Area Centroid of the face and finding the underlying surface ClosestPoint (in case there is a hole or somerthing in the trimmed face)
Does that make sense?

https://developer.rhino3d.com/api/rhinocommon/rhino.geometry.areamassproperties

-Pascal

Yes…thank you!