Rs.AddSrfContourCrvs creates non planar curve

Struggling with something here as the output of a series of curves is unplanar. Seems to be a tolerance issue. Can we have a tolerance setting added to this method please?

Can you post some sample geometry and script code that repeats the problem you are seeing?

Dale,
thanks for looking this up.
Here is an example, deleted most of the irrelevant code but there is still some in there.
https://copy.com/QDnCc724qdUp3axb

I noticed that if I tighten the document tolerance, the troublesome curve becomes planar.

This seems to work on your model using plain old Python:

import rhinoscriptsyntax as rs

def TestContourSurface():
    obj_id = rs.GetObject("Select polysurface to contour", 16)
    if obj_id:
        box = rs.BoundingBox(obj_id)
        dist = rs.Distance(box[1], box[0])
        crv_ids = rs.AddSrfContourCrvs(obj_id, (box[0], box[1]), dist / 100.0) 
        if contours:
            for crv in crv_ids:
                if not rs.IsCurvePlanar(crv):
                    rs.SelectObject(crv)
                    print crv, " is not planar"

if __name__ == "__main__":
    TestContourSurface()

Thanks Dale,
I can also find workarounds for it. Like projecting the unplanar curve onto a plane, ignore it, tightening the tolerance etc. But my goal was to distribute a .ghpy that would work as expected. It does seem that there are odd cases when the method creates a non planar curve when the intersection object is very small compared to the tolerance, I assume. I’d like to know if these odd cases are left to the scripters to deal with or if the method will be changed to prevent those unplanar results. Both fine by me, although a method should do what is expected of it, whether inside a ghpy or simple py. I guess for now I’ll work around. Thanks again.

rs.AddSrfContourCrvs calls RhinoCommon’s Rhino.Geometry.Brep.CreateContourCurves which calls Rhino’s internal contour function. RhinoCommon uses the document’s absolute tolerance as the intersection tolerance. Thus, if you are determining if a curve is planar with something tighter than this, then there is a good chance the curve will report as being non-planar.

Does this help?

Thanks Dale, it makes sense. There are methods in RS that do take a tolerance input, would be nice to have that option with AddSrfContourCrvs too. For now I just have to check for planarity to be sure I can pass those results to Area for example. If unplanar I have to tighten the tolerance and rerun the method, takes time…