Introduction to openNURBS and a 15-step guide to a Rhino (.3dm) model

April 19, 2021


Blog, Technology


Introduction to openNURBS and a 15-step guide to a Rhino (.3dm) model

What is openNURBS

openNURBS is an open source toolkit which reads and writes Rhino (.3DM) files. The full-featured development platform is provided in the Rhino SDK. The openNURBS provides tools for a developer to accurately read and/or write3D geometry between Rhino format  and other platforms or representations.

The openNURBS toolkit consists of C++ source code for a library that will read and write openNURBS 3D model files (.3dm). The toolkit is currently used by more than 400 software development teams and applications, including Rhinoceros, exchange 3D models using the openNURBS file format. The openNURBS Toolkit has source code for several example programs, NURBS evaluation tools and elementary geometric and 3D view manipulation tools.


The tools provided by openNURBS include:

  • C++ source code libraries to read and write the 3DM file format. Currently compilers from Microsoft and Apple are supported.The .NET source code to read and write the 3DM file format.
  • Quality assurance and revision control is also provided by openNURBS.

key Features of OpenNURBS

1. NURBS Curve and Surface Operations: OpenNURBS allows you to create NURBS curves and surfaces of various degrees and control point structures. You can evaluate these curves and surfaces at specific parameter values, perform transformations, and manipulate their control points and knot vectors.

2. Geometry Intersections: OpenNURBS provides functions for computing intersections between curves, surfaces, and other geometric primitives. This can be useful for tasks like collision detection or finding the intersection points of curves or surfaces.

3. File I/O: OpenNURBS supports reading and writing NURBS geometry from and to the 3DM file format, which is commonly used by McNeel’s Rhino software. This enables interoperability between OpenNURBS and other applications that support the 3DM format.

4. Geometry Query and Analysis: OpenNURBS includes utilities for querying and analyzing NURBS geometry, such as determining curve lengths, surface areas, bounding boxes, and surface curvatures.

5. Memory Management: OpenNURBS provides memory management capabilities for handling NURBS geometry, allowing you to allocate and deallocate memory efficiently.

OpenNURBS is widely used in the computer graphics and CAD/CAM industries, especially in applications that require robust NURBS handling. The library is written in C++ and provides a C-style API for easy integration into different software projects. It is available for various platforms, including Windows, macOS, and Linux.

15 Key Points While Traversing the Rhino Model

1. Before calling any openNURBS API you need to call ON::Begin() function to ensure all class definitions are linked. Just before your application exits to clean, then you need to call ON::End() function. After ON::End() function call openNURBS will work correctly.

2. To traverse the Rhino model you first need to open a file containing opennurbs archive using ON::OpenFile() function. After opening the file you need to read the contents of the Rhino file into an ONX_model object using the Read() function and later you can close the file using ON::CloseFile() function.

3. The ONX Model contains data of models like the  embedded images, materials, line patterns, text styles, annotation styles, hatch patterns, layers, group, lights, model geometry object and model settings (like units, tolerance and bounding box etc).

4. Every openNURBS class has a method Dump() which can be used to dump the data on the console window.

5. ONX model has different model components (like the ModelGeometry, RenderMaterial, Layer, InstanceDefinition, etc).Now to iterate the corresponding component we need to pass it to Model Component Iterator (ONX_ModelComponentIterator). For example if you need to traverse model geometry then you need to pass ‘ModelGeometry’ to ONX_ModelComponentIterator.

6. Rhino models also have geometry blocks as instance definitions which can be referred to more than once in the model geometry. So while traversing you will receive instance reference as geometry object type. Instance reference objects have reference to the block present in instance definition and its transformation matrix.

7. As a block present in instance definition can be referred more than once in the original model so to avoid geometry repetition you can first traverse the instance definition component and create its corresponding geometry (store it in some data structure container), you can refer these geometry objects once you get instance reference object while traversing model geometry and apply transformation to it.
Below image showing one of the Rhino 3dm models having the instance definitions. You can see these instance definitions for the model in the Rhino modelar using the ‘BlockManager’ command.

 Rhino Model

8. Instance definition blocks can also have linked file reference, which means that another Rhino (.3dm) file is referred to as a block in instance definition. There is a flag in instance definition object which tells you if the block is linked file reference, if the flag returns yes then it also has the full path of the linked file. Now to traverse a linked reference file you need to call your traversing code recursively.

9. While traversing model geometry components we get geometry object and attribute object. Geometry objects contain the actual geometry data (geometry types like point, curves, surfaces, B-Rep, Mesh, extrude etc) and attributes objects contain information about the geometry (like name, color, transparency etc).

10. Every geometry object has a ‘Duplicate()’ method which creates a copy of the geometry object. It is an advice that you should always work on the copy object as it will not impact an actual geometry object. It is your responsibility to free the memory of the duplicate object.

11. Every OpenNURBS object in a model is on some layer. The layer definitions in an OpenNURBS model are stored in a layer table. The layer has color, material, linetype and weight associated with it.

12. The color attribute used to display an OpenNURBS object is specified in one of 3 ways. If the color source is the layer then layer color is used, if the color source is the object then the value of m_color variable is used. And if the color source is the material then the diffuse color of the object’s render material is used.

13. Attribute objects have a field which tells us which color is applied on the model (layer or material). While traversing you can also find geometries on which layer color is applied on the geometry object. But on layer, material color is applied. Means if the material is applied on a specific layer then you can retrieve the material from the layer and if the material is applied on the object directly then one can retrieve them directly from the object.

14. The 3dm model geometry attribute also has the name attribute attached with it, you can get the name of the objects/geometries from it. There is also a visibility attribute in openNURBS attributes data. OpenNURBS attributes also have an API which can be used to check if the model is visible or hidden.

15. OpenNURBS also comes with example applications which have sample code for reading/traversing and writing the .3dm file. You can also find a few sample codes regarding traversing in Rhino documents. Also you can post your queries on mcneel forum, they can help you to the maximum possible extent.

About ProtoTech Solutions

ProtoTech Solutions is a leading provider of 3D software technology solutions was founded in 2005. If you have a product idea that requires 3D technology, we can help you. We can build the product for you which is the best in quality and bring it to market quickly. ProtoTech also provides technology solutions for 3D data import/export, 3D visualisation and 3D object measurements. Our products are used by customers from over 80 countries in the world. Many of our customers are highly reputed global technology and engineering multinational companies.

We are familiar with almost every software technology component in the 3D technology domain (2D/3D visualization, data exchange, solid modelling, CAD/CAM/CAE, 3D printing etc.). Our 80+ software experts can help you quickly choose a technology, build a product, and bring it to market. We are familiar with all platforms (Windows, Mac, Linux etc.), mobile apps (iOS, Android etc.), and Cloud technologies (AWS, GCP, Azure etc.). We are also partners with companies like Microsoft, Autodesk, Solidworks and many other engineering technology providers and can help you build bespoke solutions around their offerings.

For more queries regarding any of the above-mentioned topics, feel free to connect with us on our website, or email us at

Leave a Reply

Your email address will not be published. Required fields are marked *