How to get data out of NURBS solids in Rhino

How I can get some specific data out of NURBS solids drawn in Rhino in a .txt Format? Data like coordinates of control Points, their respective weights and knot vectors.

Finding from the earlier question, I can get some data out of NURBS curves and surfaces.

How to get data out of NURBS curves in Rhino

For example, to get the data of NURBS surface, the following code can be used:

import Rhino
import System.Guid
import scriptcontext
import rhinoscriptsyntax as rs
surface=rs.GetObject(“Select”,rs.filter.surface)
print ‘NURBS Data’
if rs.IsSurface(surface):
points = rs.SurfacePoints(surface)
weights = rs.SurfaceWeights(surface)
knots = rs.SurfaceKnots(surface)
print points
print weights
print knots
print ‘Done’

Please let me know if anyone knows how to get this. Thank you.

Hi @Henry_Jeff,

How you convert the list of information into a text file will depend on how you want to use it as I do not believe there is any standard format for a nurbs data set.
If you want it to be then exported to another software, you will need to format the values according to that software’s standard.

If you are exporting and then re-importing, to recreate the surface, you will use the following:
https://developer.rhino3d.com/api/RhinoScriptSyntax/#surface-AddNurbsSurface
Therefore you will need to write a reader for your file.

Thank you very much for your help. After getting the control points and kont vectors of NURBS surfaces, generally I will deal them using MATLAB.

In my previous project, I write the values line by line in a custom format.
This format was then read into matlab line by line with ** as a way of separating element types and using the str2num function.
I am unable to share the code that I used though.

Cool! Thank you for your guide.

You can Export the selected geometry in IGES format. IGES files are formated as 80 character long lines of ASCII text. The IGES format is documented in https://web.archive.org/web/20120821190122/http://www.uspro.org/documents/IGES5-3_forDownload.pdf
https://www.govinfo.gov/content/pkg/GOVPUB-C13-7b81ba8b0f709555f162cb496aa63b3b/pdf/GOVPUB-C13-7b81ba8b0f709555f162cb496aa63b3b.pdf

Export the selected geometry in STEP format is also a possib-lity.