I got an automated height detection that uses ClosestPoint.
If the user uses a CageEdit => BoundingBox the Brep.ClosestPoint will use this Cage instead of the Brep itself…
Dim br As Brep = New DocObjects.ObjRef(g).Brep //g is the Guid of the Brep I use
Dim bb As BoundingBox = br.GetBoundingBox(True)
Dim pt As New Point3d(bb.Center.X, bb.Min.Y + 35, bb.Min.Z - 70)
Dim newPt As Point3d = br.ClosestPoint(pt)
If CageEdit is off I get the right result. When the user uses a CageEdit => BoundingBox then I will always get the bb.Min.Z result.
Oke. Use this on a brep:
RhinoApp.RunScript("_CageEdit _Pause _Boundingbox _Enter _X 3 _y 16 _Z 4 _enter _enter", False)
Then use:
Dim br As Brep = New DocObjects.ObjRef(g).Brep //g is the Guid of the Brep I use
Dim bb As BoundingBox = br.GetBoundingBox(True)
Dim pt As New Point3d(bb.Center.X, bb.Min.Y + 35, bb.Min.Z - 70)
Dim newPt As Point3d = br.ClosestPoint(pt)