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.
- 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:
- 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:
- 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 . 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:
- 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:
- Your result should be something like this:
- 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)