mantis shrimp – export/import grasshopper (points)
By [Konrad K Sobon](/content/author/ksobon/ "Posts by Konrad K Sobon"/index.html) / 27 Oct 2014
image by archi-lab
In a previous post I have discussed a few things that you need to check to get started with Mantis Shrimp. In this post I will go over a specific workflow of exporting geometry from Grasshopper and then getting it imported into Dynamo.
Let’s start with something simple like a funnel-like surface created in Rhino and referenced into Grasshopper. We will extract some points from it and import them into Dynamo. Here’s the surface and all other needed files in Rhino that we will be working with:
First we need to reference it into Grasshopper. We can use Geometry component. You can find it under Params > Geometry:
Once that is on canvas just right-click it on Geometry component and select Set Multiple Geometries:
That will allow you to now switch over to Rhino viewport and select both of the surfaces and hit space or enter. When your selection is complete you will notice that Geometry component has changed its state from orange to grey:
Now we have a surface (actually two) to extract our points from. From a Surface tab go to Util and select Divide Surface:
Next insert two number sliders by going to Params tab and under Input select Number Slider:
Get two of those and set one to 10 and another to 13 and connect them to U and V inputs on the Divide Surface component. Also, connect the output of Geometry to input S on the Divide Surface. It should look like this:
You should see something like this in your Rhino viewport:
Next thing to do would be to use Mantis Shrimp Export component to get this point information out. First from archi-lab tab drop in Mantis Shrimp Export onto the canvas. You will notice that it needs three inputs. First is geometry which will be the same component that we used before to reference in Rhino surfaces. This time, however I want to simply plug in an output from Divide Surface into it.
Also make sure to flatten the input by right-clicking on it and selecting Flatten:
The input for a file path is a Panel component. You can find it under Params > Input > Panel:
Then just double-click it and type in the location and name where to save the exported file.
Last input is _export and that takes a Boolean component. It can be found on the Param > Input > Boolean Toggle. You can see in the image above. Also, the image above was a final setup on the Grasshopper side. It should be saving a file in the specified location. Now let’s jump over to Dynamo and import it in.
Fire up Revit and then Dynamo 0.7.2 is the version that I was last using it with.
Now it doesn’t matter which way you used to download all of the Mantis Shrimp nodes. They should be available in your Dynamo search menu. Go ahead and bring in first a File Path node and browse to the exact same location that you used to export geometry from Grasshopper. Then drop in a Read GH File node and you should be able to see our points:
At this point, this is still a “Rhino object” and Dynamo doesn’t understand it so let’s use a RH Point to DS Point node to translate them to Design Script that is the native Dynamo language.
Now these are your points translated. Good job! Now you can go on and do more stuff with them inside of Dynamo.
There were two custom Mantis Shrimp nodes that you used and I will go over the code inside of those and intricacies of methods that they executed in the next post. I will also try to ramp up the difficulty/complexity of the geometries that we can translate from Grasshopper to Dynamo.
PS. Keep in mind that this is still a work in progress so there is always a possibility that bugs and unexpected errors will creep up. In case you can’t work with those files and examples provided feel free to email me at ksobon@iit.edu or post in the comments section, and I will try to help out. Remember to attach files that are not working as this is the only way that I can troubleshoot them and come up with fixes.
Good luck!
PS. Since this post has been published Mantis Shrimp has been updated with a few improvements. What that means? Well, when you “read” your *.geo file using the “Read GH File” node, the output will no longer be a Rhino Object but instead will already be a list of Dynamo geometry or data. You no longer have to use “RH Point to DS Point” node to convert those. I hope this makes it easier. (01/01/2015)