I need bound boxes from all document objects. When got from curves they are correct, when got from annotations they are wrong, but not too much. Example:
The correct bounding box is: x0,y0= 10.13, 4.96 x1,y1= 17.70, 9
The reported bound box is: x0,y0= 10.13, 0.96 x1,y1= 17.70, 5
If I use as bounding box origin the annotation plane origin and keep the dx and dy above I get a better, but still wrong, result:
x0,y0= 10, 5 x1,y1= 17.57, 9.04
I’m using Rhino3dmIO v 6.27.20176.5001 under Visual Studio 2015. I read them like this: Rhino.Geometry.BoundingBox bb = o.Geometry.GetBoundingBox(true);
using System;
using Rhino.FileIO;
namespace gridExtractor
{
class Program
{
static void Main(string[] args)
{
File3dm rhinoFile = File3dm.Read(@"C:\Users\lscandella\data\gucci\Rhinoceros\gridExtractor\gridExtractor\txt.3dm");
File3dmObjectTable objectTable = rhinoFile.Objects;
foreach (File3dmObject o in objectTable)
{
Rhino.Geometry.BoundingBox bb = o.Geometry.GetBoundingBox(true);
Console.WriteLine("Bounding box x0,y0,x1,y1: " + bb.Min.X.ToString() + " " + bb.Min.Y.ToString() + " " + bb.Max.X.ToString() + " " + bb.Max.Y.ToString());
}
Console.WriteLine("Press any key to stop...");
Console.ReadKey();
}
}
}
Please rename the path to point to the attached filetxt.3dm (21.8 KB)
and forget my ideas about the annotation plane. The problem is text formatting. Apparently the boundingBox method does not care about it. In the example file you find a simple string “Txt” aligned on the left and on the bottom. The method reports it bounding box as if it were aligned on the left and on the top.
Having a similar problem with sphere and torus. The bounding box doesn’t fit the object. Here is a sample file and the resulting bbox I get using Rhino3dmIO 6.28 nuget package. The program I used is attached at the bottom.
Tight bounding boxes for Breps are computed in Rhino from their render mesh. Rhino3dmIO is not capable of tessellating Breps. So this is what you are going to get.
If a tight bounding box for Breps is important to you in Rhino3dmIO, then I recommend saving 3dm files with cached render meshes. Then, then you need the tight bounding boxes of Breps, get the meshes from the Brep faces and build a bounding box based on them.
I am guessing that one of these files has once been shaded before being saved as geometry-only, in which case the ON_Brep::m_bbox member would be valid and, thus, returned if one asked for it.
Hi @dale I’ve noticed the spheres return different bounding box depending on the rotation they have and maybe the one fit in my sample was tighter just by luck? Check this video
As @dale pointed out, tight boundingboxes cannot be computed when the object lacks a rendermesh attached to it. It looks to me that instead the ‘controlpoints’ for the (sub)surfaces are used.
If you rotate the sphere, its controlpoints are oriented dirrerent in relation to the world plane thus you get a different result for the boundingbox:
@dale might be able to confirm of deny this assumption