Find lowest points to create footprint

I am trying to draw footprint out of the box. But I have a problem, instead of taking corners from the actual box, code takes them from Bounding Box. I do not understand why, even if I found corners of the box.

// Getting corners from box
Point3d[] tempCorners = mass.GetCorners();
// List Point3d for base points
List<Point3d> mBasePoints = new List<Point3d> ();
for (int i = 0;i < tempCorners.Length;i++)
//sort points according to Z coordinate
if(tempCorners[i].Z < mass.Center.Z)
//put points in one list

// to close polyline add start point to the list
Point3d endPoint = mBasePoints[0];

Polyline mFootprint = new Polyline(mBasePoints); (33.7 KB)

I don’t know what ‘mass’ is referring to actually, but while you think you may have gotten the actual box object, you probably still have the (world-aligned) bounding box.

The way I have gotten footprints of objects that have a lower planar surface that is parallel to the XY plane is to get all the faces in the Brep, find the plane of each face, check if it is parallel to XY. If yes, if the face plane origin Z value is within tolerance of the bounding box lower Z, that should be a “bottom face”. If you have multiple faces that are on the bottom, you may need to combine them afterward to get the footprint outline, or, maybe do a MergeAllFaces before doing the above.

Otherwise, you can also get all of the brep edges, and find which ones lie in the plane of the lower bounding box face. If you get all of those, you will have the footprint. If multiple joined surfaces are involved, again, a MergeAllFaces will help before the edge extraction.


Oh, and in looking back as some of my scripts, I see that I also used a technique where I intersected the Brep object with the plane of the object’s bounding box lower face. The intersection so found should be the footprint.

Input parameters are just Box:

RunScript(Box mass, ref object A)

That still doesn’t tell me much - what is ‘box mass’? Where is that box coming from? Are you doing this in the main Rhino framework or in Grasshopper?

Actually why it happens?

Sorry, the Boxes come from Rhino, I write code using C# component.
Does it really matter from where the boxes come, ether from Rhino or Grasshopper?

Well, maybe you need to provide a Rhino file with the code you used so someone can test… I don’t do C#, so someone else may answer here…

It shouldn’t matter if the boxes are created in Rhino or GH, just that the programming environment is somewhat different.

You didn’t show how you made the boundingbox, which is where the problem is.

Anyway, try taking the Brep (box) and pick a surface from it (any surface should do) and make an aligned BoundingBox, like so:

// Assuming you grabbed the Rhino Brep box into the variable "brep_box":

Plane aligned_plane;
brep_box.Faces[0].TryGetPlane(out aligned_plane); 

// now get a BoundingBox which is aligned with the plane
Box bbox;
brep_box.GetBoundingBox(aligned_plane, out bbox);

// now your bbox should be aligned. Get corners from this bbox.
... aso

See also

// Rolf

I hate to rely on assumptions here, the assumption being that all of the plane faces of the boxes are actually untrimmed and aligned with the box axes…

Try the script on the box in the Rhino file below…

import rhinoscriptsyntax as rs
import Rhino

objID=rs.GetObject("Select box",16)
print "Plane X axis={}, Plane Y axis={}".format(plane.XAxis,plane.YAxis)
if rc:

GetBoxPlane.3dm (330.1 KB)

Admittedly, this is an extreme concocted case, but it could happen.

Good catch!

The OP would know though. :wink:

// Rolf

I’m sure that’s the case if he actually created the boxes… But I always like to plan for the unexpected.

1 Like