CageEdit and brep.ClosestPoint

Hi,

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.

How can I get the right result?

Anyone has an idea?

I guess I need some simple, sample code that I can run that will repeat the problem. So far, I haven’t been able to repeat this…

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)

the newPt is not on the brep but on the cage.