Rs.AddCutPlane() bug and request

The python rhinoscriptsyntax version of AddCutPlane is different than its vb counterpart and Rhino’s CutPlaneCommand.

Both the vb version and Rhino command create a plane that cuts entirely through all the objects and is expanded by a certain margin (looks like 20% larger, but I don’t really know how the margin is calculated).

The python rhinoscriptsyntax version produces a plane that exactly encompasses the object but does not have any margin like the other versions do.

It also has a bug in that it might not cut entirely through the object if the object is in wireframe and isocurves are turned off. Run the following to see… (need an English Rhino or at least one that has a “Wireframe” display mode)

import rhinoscriptsyntax as rs
rs.ViewDisplayMode(mode="Wireframe")
sph=rs.AddSphere(rs.WorldXYPlane(),10.0)
rs.SurfaceIsocurveDensity(sph,-1)
zVec=rs.coerce3dvector([0,0,1])
rs.AddCutPlane([sph],rs.coerce3dpoint([0,0,0]),rs.coerce3dpoint([1,0,0]),zVec)

Note the cut plane starts at the sphere poles and only cuts half the sphere.

So, I would like have the margins if possible, and, of course the bug fixed… :smiling_imp:

Edit: actually, the bug is not in AddCutPlane(), its in how the bounding box is calculated in the above example:

import rhinoscriptsyntax as rs
rs.ViewDisplayMode(mode="Wireframe")
sph=rs.AddSphere(rs.WorldXYPlane(),10.0)
rs.SurfaceIsocurveDensity(sph,-1)
bb=rs.BoundingBox(sph)
rs.AddBox(bb) #Fails because box is only 2d

Hmm, need to see where in RhinoCommon this is failing…

Edit #2 - Found it… The failure looks like it is in GeometryBaseClass.GetBoundingBox(Boolean).
When True is passed, it calculates an “accurate” bounding box. This seems to fail with the sphere sans isocurves. If False is passed, everything works as expected. Most of the rhinoscriptsyntax methods involving GetBoundingBox() are passed True.

import rhinoscriptsyntax as rs
import scriptcontext as sc
rs.ViewDisplayMode(mode="Wireframe")
sph=rs.AddSphere(rs.WorldXYPlane(),10.0)
rs.SurfaceIsocurveDensity(sph,-1)
geom=rs.coercegeometry(sph)
#bb=geom.GetBoundingBox(False)
bb=geom.GetBoundingBox(True)
rs.AddPoints(bb.GetCorners())

Thanks, --Mitch

The CutPlane command and RhinoScript’s AddCutPlane method do calculate tight bounding boxes. But they also grow the bounding box by adding some padding.

I’m gonna throw this on the pile so it gets look at - thanks.

http://mcneel.myjetbrains.com/youtrack/issue/RH-29481