Way to check if surface is non-developable in Rhinocommon?

I’m trying to figure out if there’s a way to check if a surface bends in two directions or not in Rhinocommon? Is there a built-in method for this? I cannot seem to find a way to do it.

Hi @siemen,

Are you trying to test if a surface is unrollable?

– Dale

Yes @dale

Hi @siemen,

There isn’t a function on the SDK that you can call to determine if a surface is unrollable. But you can probably write your own test function that would cover most cases.

For example:

import Rhino
import scriptcontext as sc

# Determines if a surface is linear in a specifed direction
def IsSurfaceLinear(srf, dir, rel_tol):
    if not srf:
        return
    nurb = srf.ToNurbsSurface()
    if not nurb:
        return
        
    dir = Rhino.RhinoMath.Clamp(dir, 0, 1)
    if rel_tol < 0.001:
        rel_tol = 0.001

    knots = nurb.GetSpanVector(dir)
    for i in range(len(knots)):
        crv = nurb.IsoCurve(dir, knots[i])
        length = crv.GetLength()
        if length < Rhino.RhinoMath.SqrtEpsilon:
            continue
        if not crv.IsLinear(rel_tol * length):
            return False
            
    return True

def Test():
    filter = Rhino.DocObjects.ObjectType.Surface
    rc, objref = Rhino.Input.RhinoGet.GetOneObject("Select surface", False, filter)
    if not objref or rc != Rhino.Commands.Result.Success:
        return
        
    srf = objref.Surface()
    if not srf:
        return
    
    tol = sc.doc.ModelAbsoluteTolerance
    rc = srf.IsPlanar(tol)
    print("Surface is planar: {0}".format(rc))
    
    rel_tol = sc.doc.ModelRelativeTolerance
    rc = IsSurfaceLinear(srf, 0, rel_tol)
    print("Surface is linear in the U direction: {0}".format(rc))
    rc = IsSurfaceLinear(srf, 1, rel_tol)
    print("Surface is linear in the V direction: {0}".format(rc))

if __name__ == "__main__":
    Test()

– Dale

2 Likes

I could have specified I’m using C# but I can work with this, thanks!