How to convert SubD to NURBS in RhinoCommon without using rs.Command?

Hello,

I would like to convert a SubD object to a NURBS Brep in Rhino using RhinoCommon, but I want to avoid using [rs.Command(“_ToNURBS”)] or any command-line calls.
Is there a direct method or class in RhinoCommon (such as a method on the SubD or Brep class) that allows me to convert a SubD object to a NURBS Brep purely through the API?

If possible, could you provide a code example for this conversion?

Thank you!

Hi,
like this?


SubDToBrep.cs (1.3 KB)

var subDToBrepOptions = new SubDToBrepOptions(true, SubDToBrepOptions.ExtraordinaryVertexProcessOption.LocalG1);

var brep = subD.ToBrep(subDToBrepOptions);
Rhino.RhinoDoc.ActiveDoc.Objects.AddBrep(brep);

https://developer.rhino3d.com/api/rhinocommon/rhino.geometry.subdtobrepoptions
https://developer.rhino3d.com/api/rhinocommon/rhino.geometry.subdtobrepoptions.extraordinaryvertexprocessoption

1 Like

Yes, kind of..

but i hope to convert without any interacting with gui. so maybe with only the id of subd.
Is there any way?

Sorry, I don’t know exactly what you mean, but if you can get the SubD shape, you can convert it using the above.

If you know the GUID of the object, you can also get the SubD.

In the video, you have to select a SubD by clicking on it, but what I meant was—if I already know the GUID, can I directly specify it in the code without having to click on it and convert it directly?

Yes.

Oh, it was really helpful to me. Thanks for your help.

1 Like

It converts my SubD to BREP not NURBS(of course NURBS is a kind of BREP) but, what i want is right side one but it gives me the left one. Is there any other method?

You can ask for “unpacked NURBS faces”, which will give a Brep with one NURBS face per SubD face:

var brep = subD.ToBrep(SubDToBrepOptions.DefaultUnpacked);

Or any other way of creating SubDToBrepOptions with packFaces == False

https://developer.rhino3d.com/api/rhinocommon/rhino.geometry.subdtobrepoptions

1 Like