Skip to content
October 15, 2018 / stevebaer

Rhino3dm – Geometry Toolkits for .NET, Python, and Javascript

You may be familiar with Rhino3dmIO; our .NET assembly to provide a geometry library with 3dm file import/export capabilities. Rhino3dmIO is a trimmed down version of RhinoCommon that wraps the OpenNURBS (C++) toolkit and works independent of Rhino. It is available on most platforms through nuget.

Rhino3dmIO can be used on its own or as a “fat client” for the compute.rhino3d web service. By “fat client” I mean that many typical geometry operations can be performed efficiently in the client application while operations like meshing of polysurfaces, trimming, and intersections can be completed through calls to compute.rhino3d.

This all works great…. as long as you are working in .NET and on an operating system that nuget packages are available for.

rhino3dm – two new flavors

I’m excited to announce that the .NET version of Rhino3dmIO now has two new siblings, a native CPython library and a javascript (web assembly) library. Both libraries are built under a single public github repo at https://github.com/mcneel/rhino3dm. We dropped the “IO” suffix from the name since you can do a lot more than just file IO and are calling these libraries rhino3dm.

rhino3dm.js is a javascript library with an associated rhino3dm.wasm (web assembly) that is OpenNURBS plus additional C++ to javascript bindings compiled to web assembly. Web assembly is now an available technology on all major browsers as well as node.js.

rhino3dm.py is a python package that is OpenNURBS plus additional C++ to python bindings compiled to a C-extension library that can be used on all current versions of CPython (both 2.7 and 3.7) and is available on all platforms through PyPi.org

Here is one example scenario. The following screenshot is a 3dm file viewer available in the samples on the github repo. The html+javascript to create the viewer is around 300 lines (including comments) and runs on all browsers including mobile devices.  rhino3dm.js is used to read a 3dm file and create an instance of a File3dm class in the browser’s memory.  It then walks through the objects in the model and calls compute.rhino3d.com to create meshes and isocurves for the polysurface. These meshes and isocurves are then added to a three.js scene for display.

rhino3dm_rhinologo

The libraries are still very new and changing rapidly. Give them a try or get involved with the github repository and help make them even better.

These are exciting new technologies and the possibilities that they open up are beyond my imagination. A bunch of my coworkers will be in New York in a couple weeks to talk about this at the AEC Tech 2018 event. Stop by if you get a chance.

5 Comments

Leave a Comment
  1. emilpoulsen / Oct 17 2018 7:54 am

    Very cool, congrats! The interaction between rhino3dm.js, Rhino.Compute and three.js look really smooth.

  2. gwinsky / Nov 24 2018 6:35 am

    Great news Steve! I can’t wait to test this all in browser ! Would it in theory be possible to bring all geometry computations from c++ to wasm?

    • stevebaer / Nov 24 2018 6:10 pm

      In theory yes, but it would be years worth of work to do this for all of Rhino. Web Assembly is also still in a very early phase of maturity, so what we can do in the future may change.

  3. Andrei Nejur / Feb 9 2019 10:46 am

    Currently none of the Js samples work on github. Any ideas ?

    • stevebaer / Feb 23 2019 12:01 am

      I’ll take a look. These samples were pretty early rough drafts and the toolkit has been evolving

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: