mantis shrimp – export/import 3dm (nurbs surface)

image by archi-lab

In my previous post I showed how to export Geometry from Grasshopper using Mantis Shrimp. In this post I want to go over reading/importing 3dm files directly from Rhino. If you have something that you have modeled in Rhino and want to move that over to Dynamo to do some Adaptive Components paneling, this will be a great way to get your stuff into Dynamo.

  • We are going to get started with the same Rhino file and a “funnel like” surface that we used previously. This time i will show how to import geometry that exists in Rhino using geometry type (Nurbs Surface) and Layer that it exists on.
  • First let’s ensure that our surfaces are on the Nurbs Surface layer. For the sake of clarity I will keep my layers organized by geometry type.

image_01

  • Let’s save our Rhino file and jump over to Dynamo. In Dynamo let’s first drop in a File Path node and browse to our just save Rhino file. We then need to drop in a Get Rhino File node and hook it up to Watch node to see if we are reading the Rhino file properly. If all is good we should see something like this:

image_02

  • Let’s collect all of our layers next so that we can isolate certain objects by a layer. For that let’s select Get Rhino Layers node and for its input lets plug in output of Get Rhino File node. It should look as follows:

image_03

  • You can see that we are showing a list of Rhino layers just like they are in our Rhino file. Now we can use Get Objects by Layer to select only objects sitting on the Nurbs Surface layer. However, an input to Get Objects by Layer node is a single Rhino Layer and output of Get Rhino Layers is a list of layers we need to first extract one layer that interests us.
  • To do that simply use List.GetItemAtIndex node and feed it a Number node set to 1 since our layer of interest is a list item at index [1]. The input for a list is the output of Get Rhino Layers. That will select just the desired layer for us and we can input that into Get Objects by Layer. When done it should look as following:

image_04

  • You can now see that its showing two objects since our funnel like surface is actually made of two separate surfaces. We can use those two objects with Mantis Shrimp RH NurbsSurface to DS NurbsSurface node like so:

image_05

  • Your result should be something like this:

image_06

  • A few things to keep in mind when working with Nurbs Surfaces. When we are using RhinoCommon to read them they are actually considered Breps so a surface as such would be a Brep with one face and no trimming curves.
  • I haven’t gotten into explaining the underlying code in any of the nodes but I am considering doing a series of tutorials that explain what is going on for those of you that have interest in learning a little bit more about python, rhino common and design script.
  • Remember that all of the nodes/source code can be found on Mantis Shrimp gitHub page.

PS. Since this post has been published Mantis Shrimp has gotten a few improvements. Mainly it now checks Units in the Rhino file to make sure that your imported geometry is of the correct scale. What that means is that there is an extra output called “Units” coming from “Get Objects By Layer” node and all of the geometry nodes will have an extra input for it. Make sure that you plug those together, otherwise an error will be thrown. (01/01/2015)

Support archi-lab on Patreon!

2 Comments

  1. Bjarke Koch-Ørvad says:

    Hi Konrad

    Thanks for your great work.

    The import of the Rhino-file is working for me (after changing the path in rhpath.txt from …\Rhinoceros 5 (64-bit)\…. to ….\Rhinoceros 5.0 (64-bit)\…), but my problem is converting the polysurfaces that I try to import into DS geometry. It returns “null”. Any idea what’s wrong?

    /Bjarke

    • Can you please email me your Rhino file that you are trying to import? I want to test it out and only then i will be able to tell you if there is anything that i can do to help. You can email me at ksobon1986[at]gmail[dot]com

Leave a Comment