How to convert QuadMesh to SubD in RhinoCommon likewise _ToSubD in GUI?

Hello,

I would like to convert a QuadMesh object to a SubD in Rhino using RhinoCommon, but I want to avoid using [rs.Command(“_ToSubD”)] or any command-line calls.

In the GUI, I usually use _ToSubD with the following options:

  • Mesh Use = Control Points
  • Mesh Crease = Yes
  • Mesh Edge = Yes
  • Surface Use = Position
  • Surface Edge = No

However, RhinoCommon’s SubDCreationOptions exposes different parameters, and I’m not sure how to set them to match the GUI options above.

Is there a way to achieve the same result as _ToSubD with these options using only RhinoCommon?
Or is there another function in RhinoCommon that uses the exact same parameters as _ToSubD?

Either approach would be a solution for me.

Additionally, when using Rhino.Geometry.Mesh.QuadRemesh() to remesh to a quad mesh, is there a way to directly convert the result to SubD as in the GUI, without using command macros?

Any advice or code examples would be greatly appreciated. Thank you!

Hi @Young_Geon_Park,

Try using SubD.CreateFromMesh.

– Dale

Hello,
Thanks to your reply.

I know that by using the command in rhinocommon to convert mesh into SubD, but i have a problem with the params.

There are a few params to control the conversion, but it is different with GUI command _ToSubD, so i wonder how to convert as same as the GUI command.

Thanks

Hi @Young_Geon_Park,

For meshes, this should be all you need:

#! python 3
import Rhino

def GetSubDCreationOptions(UseMesh, MeshCreases, MeshCorners):

    options = Rhino.Geometry.SubDCreationOptions.Smooth

    # True = ControlPoints, False = Location
    options.InterpolateMeshVertices = UseMesh
    
    if MeshCreases:
        options.InteriorCreaseTest = Rhino.Geometry.SubDCreationOptions.InteriorCreaseOption.AtMeshDoubleEdge
    else:
        options.InteriorCreaseTest = Rhino.Geometry.SubDCreationOptions.InteriorCreaseOption.NONE

    if MeshCorners:
        options.ConvexCornerTest  = Rhino.Geometry.SubDCreationOptions.ConvexCornerOption.AtMeshCorner 
    else:
        options.ConvexCornerTest  = Rhino.Geometry.SubDCreationOptions.ConvexCornerOption.NONE

    return options

– Dale