Mantis Shrimp is a Dynamo (Revit) and Grasshopper (Rhino) interoperability project that allows you to read Rhino’s native *.3dm file type as well as export geometry from Grasshopper. It is written in Python in form of a user objects (on Grasshopper side for exporting) and custom Python nodes (on Dynamo side for importing). It’s an OPEN SOURCE project with all of the source code available on GitHub. At the moment it’s a collaboration project between myself and Mostapha Sadeghipour.
I decided to make this project an open source for multitude of reasons but most importantly because it was written on top of Dynamo (an open source project) using OpenNurbs (an open source project) and inspired by Rhynamo (an open source project since December 2014), and finally I was helped along the way by Mostapha who’s almost never written anything that he didn’t like to share. I think i got the “bug” – not Ladybug – for sharing from him.
This should be considered for those who sell online, especially when selling generic drugs online.
Here’s how to get started with Mantis Shrimp:
- Mantis Shrimp is written as custom Python nodes using OPENNurbs library provided by McNeal (Rhino makers) so you will need to make sure that RhinoCommon.dll is in the specified location as well as pickle.py for de-serializing geometry. By default if you have Rhino installed on your machine the RhinoCommon.dll will be located in C:\Program Files\Rhinoceros 5 (64-bit)\System so that should not be a problem. Pickle is part of Iron Python so adding a reference to default IronPython library folder should make it work. Sometimes Rhino can be installed in a different location if its an evaluation copy so I added few more paths that will be checked by default:
- C:\Program Files\Rhinoceros 5 (64-bit)\System\RhinoCommon.dll
- C:\Program Files\Rhinoceros 5.0 (64-bit)\System\RhinoCommon.dll
- C:\Program Files\McNeel\Rhinoceros 5.0\System\RhinoCommon.dll
- I am usually also referencing in System.Collections module for dealing with Arrays and Lists so that’s what you see in the code snippet below.
- PS. I am posting this so you can check your IronPython folder location and see if you have pickle in there otherwise you would have to download it. Also, check if your Rhino was installed at the provided location since its a default location I am assuming it is, but if you have specified a custom location for either IronPython/Rhino then make sure to update the following code in your nodes.
- Just like I mentioned above Mantis Shrimp is written in Python so you will need ghPython plugin for Grasshopper. You can get it from here:
- Once we have that part covered we can jump to Grasshopper. That part now consists of multiple user objects so the best way to get them all is to install Mantis Shrimp from a Dynamo Package Manager. They will be located in the “extra” folder of your package:
- C:\Users\yourUserName\AppData\Roaming\Dynamo\0.7\packages\Mantis Shrimp\extra
- You can either drag and drop those *.ghuser files onto Grasshopper canvas or copy and paste it into the following location:
- C:\Users\yourUserName\AppData\Roaming\Grasshopper\UserObjects. Remember to replace the username with YOUR username. You can also access it by going to Grasshopper’s File>Special Folders>User Object Folder:
- There is also one more file called mantisshrimp.py in that “extra” folder. Please do not move that file as all of the GH nodes will be reading from it for conversion methods.
- Once you do that, you will find a new tab in your Grasshopper UI named archi-lab under which there will be a component called Mantis Shrimp Export. Drop it on canvas. It takes three (3) inputs.
- _geometry – input any geometry that you wish to export to Dynamo
- _filePath – input a local file path with a file name and extension that you wish to save the exported geometry to (file extension is not important. i am using *.geo but it can be anything)
- _export – input a Boolean Toggle set to True to run an export
- All of the other Import components are pretty similar so you should have no trouble understanding how to use them.
- Now we need to make sure that our Dynamo import nodes are all available. There are three ways you can get all of the nodes into Dynamo:
- One is to download all of the custom nodes from GitHub and paste them into the Dynamo folder like so:
- Another is to download/install them through Package Manager: Search for “Mantis Shrimp”. This is the easiest and preferred method. It will also download all of the Grasshopper components as mentioned above.
- Finally you can simply copy and paste code from GitHub into a custom Python node. I do that quite frequently for testing purposes as you can’t see errors for a Python node that is wrapped inside of custom node.
This should be all you need to make sure/do to get started with Mantis Shrimp. In next post i will explain in greater detail how to export/import your first geometry samples.