mantis shrimp – export/import grasshopper (points)

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:

image_02

  • First we need to reference it into Grasshopper. We can use Geometry component. You can find it under Params>Geometry:

image_03

  • Once that is on canvas just right click it on Geometry component and select Set Multiple Geometries:

image_04

  • 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:

image_05

  • Now we have a surface (actually two) to extract our points from. From a Surface tab go to Util and select Divide Surface:

image_06

  • Next insert two number sliders by going to Params tab and under Input select Number Slider:

image_07

  • 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 output of Geometry to input S on the Divide Surface. It should look like this:

image_03

  • You should see something like this in your Rhino viewport:

image_04

  • 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.

image_05

  • Also make sure to flatten the input by right clicking on it and selecting Flatten:

image_12

  • The input for a file path is a Panel component. You can find it under Params>Input>Panel:

image_08

  • 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 image above was a final set up 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 browsed 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:

image_06

  • At this point this is still “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 a native Dynamo language.

image_07

  • Now these are your points translated. Good job! Now you can go on and do more stuff with them inside of Dynamo.

image_13

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 and 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 not longer be a Rhino Object but instead it 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)

 

Support archi-lab on Patreon!

27 Comments

  1. Eric says:

    Hi Konrad,

    Thanks for your amazing work!

    I am having trouble with importing GH geo through Mantis Shrimp.

    The import works fine for Data but not for geometry, a little error pops up saying

    “Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
    Traceback (most recent call last):
    File “”, line 54, in
    File “”, line 51, in readFromFile
    File “C:\Program Files (x86)\IronPython 2.7\Lib\pickle.py”, line 1378, in load
    File “C:\Program Files (x86)\IronPython 2.7\Lib\pickle.py”, line 858, in load
    File “C:\Program Files (x86)\IronPython 2.7\Lib\pickle.py”, line 1133, in load_reduce
    StandardError: Exception has been thrown by the target of an invocation.”

    And the the end results says “Null’

    Would love to get some help on this.

    Thanks!

    Eric

    Attachment:  Capture.jpg

  2. Can you send me your Grasshopper/Rhino file that you are trying to read? I wasn’t able to replicate this error and from the message I can understand only that pickle is having trouble serializing the geometry back together. I can’t really troubleshoot it without the file. Thank you

  3. Also, I just updated the entire package to a new Dynamo 0.8.0 version. Major change is that I no longer do Unit conversion under the hood and instead since Dynamo is now unitless all you need to do is make sure that Rhino/Grasshopper and Revit are set to the same units. This makes it pretty easy to move geometry between files and not worry much about unit conversion.
    I also, updated all of the location folders to 0.8 since that’s where new Dynamo lives.
    Good luck!

    • Eric says:

      Hi Konrad,

      Thanks for you reply, i have attached my GH and Dynamo file, is just a simple export operation i am trying to test out, however I keep on getting Null result on the Dynamo end.(Note:Data export works fine, but not for geometry)

      I have the latest Mantis shrimp installed today, and have followed instructions that you have posted on the website. The rhino ddl file is in the right location too.

      Would be good to get some insight on this.

      Thanks alot

      Eric

      • Your file is just points. I don’t think MS would have any trouble with it. Can you send me what error you are getting on Dynamo side? When components return NULL its because something inside that custom component (cluster) threw an exception. Best way to troubleshoot it, is to see what the error says. Since errors thrown inside of custom components don’t propagate to the top you would have to double click the Read GH File component, copy the Python component inside of it, and paste it in your main canvas. Then wire it up like the custom component, and run. You should be able to read the error. I want to see that error.

        • Eric says:

          Hi Konrad,

          Following your instruction, i get the following error:
          Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
          Traceback (most recent call last):
          File “”, line 48, in
          File “”, line 45, in readFromFile
          File “C:\Program Files (x86)\IronPython 2.7\Lib\pickle.py”, line 1378, in load
          File “C:\Program Files (x86)\IronPython 2.7\Lib\pickle.py”, line 858, in load
          File “C:\Program Files (x86)\IronPython 2.7\Lib\pickle.py”, line 1133, in load_reduce
          StandardError: Exception has been thrown by the target of an invocation.

          Thanks

          • So, this is a really weird error. Doing some google searching for answers to this one told me that it is being caused by possibly conflicting versions of Iron Python being installed on a computer or sometimes it has to do with permission. So my answer will be, make sure that you have full admin access to all of the folders (iron python install folder where pickle is, dynamo folders where mantis shrimp is etc.). If that is all OK, then i would just try uninstalling Dynamo all together and installing a fresh version then installing MS anew. Most of solutions to this error that i found were something like this: I had to uninstall ironpython, python tools for visual studio and install again but without any python tools because they were conflicting…..so on, so on. With all honesty I got this error once, and it went away next time I ran my solution so i dont know how to really fix it. I am sorry.

    • Eric says:

      Hi Konrad,

      Thanks for you reply, just tried an fresh install on another computer with admin rights, but the problem is still there.

      I guess the issue most likely lies within the IronPython part, just wondering, is the latest build on their website ok to download? or should i use the previous build?

      Thanks

      Thanks alot

      Eric

      • This is tough. I am sorry about this. This latest version of Dynamo has got me scrambling all over the place. I have no idea what they are doing with this. I will try to further troubleshoot it and see if i can come up with a solution. Package Manager has the latest Mantis Shrimp. archi-lab website doesnt have it. I think you can install any of the previous versions from Package Manager. I think there are some options in the drop down that let you pick. So theoretically you can install dynamo 0.7.5 and previous version of MS and make it work. See if that helps. I will keep trying.

        • Eric says:

          Hi Konrad,

          Thanks so much for your effort in resolving my issue, but i was actually wondering if latest ironpython 2.7.5 is what you are using? or should be using a previous build?

          Another thing not sure if it helps, but when i dragged out the python script by itself without connection nodes to it, it pops up with an error saying

          “Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
          Traceback (most recent call last):
          File “”, line 48, in
          File “”, line 44, in readFromFile
          IOError: [Errno 2] Could not find file ‘C:\Program Files\Autodesk\Revit 2014\None’.: None”

          Not sure if this helps.

          Thanks
          Eric

          • This is still a readFromFile error, so still caused by pickle and probably IronPython. I use 2.7, that comes with Dynamo. I would not update without Dynamo first updating to it.

          • Eric says:

            How do i find Ironpython from Dynamo? I couldnt find it in package manager, so i actually downloaded it from their website. I think that must be the reason why?

          • Maybe. When you installed Dynamo it automatically installed IronPython in C:\Program Files (x86)\IronPython 2.7 and thats the one that I am referencing in MS.

          • Eric, I was able to make some updates to MS. Please uninstall all Dynamo and IronPython versions that you have. Install a fresh copy of Dynamo 0.8.0 and then install Mantis Shrimp. Run the “Specify RhinoCommon.dll Path” node (once), and then just go on to set everything up as usual. See if this works.

          • Eric says:

            Thanks Konrad!

            I will give it a go :)

            Eric

          • Eric says:

            Hi Konrad,

            What did you mean by “Run the “Specify RhinoCommon.dll Path” node (once)”

            I couldnt find it in GH nor Dynamo list of commands.

            Thanks
            Eric

          • Eric,

            I found the reason you were getting this error. It was caused by you using a 32bit version of RhinoCommon.dll. I wrote Mantis Shrimp for 64-bit, so using 32-bit RhinoCommon will not work. Here’s a solution. Download latest version of Mantis Shrimp. Use the component called “SpecifyRhinoCommon.dll Path” (it is in the latest version) and using FilePath node navigate to where your Rhino 64-bit is located in. That location is usually C:\Program Files\Rhinoceros 5 (64-bit)\System\RhinoCommon.dll or similar. Hit run and you should be good to go. You might have to close Revit/Rhino and re-open for this to take effect. Thank you! Also, make sure that you are using 64bit Rhino to run Mantis Shrimp on.

          • Eric says:

            HI Konrad,

            Thanks for your reply, it is working now :)

            Thanks
            Eric

  4. Bjarke Koch-Ørvad says:

    Hi

    First of all, great work with the plug-in.

    I’ve managed to import points into Dynamo, but my problem is the conversion from RH points to DS points. I can see all off the RH points, but the conversion node returns an empty list.

    What to do?

    Thanks
    Bjarke

  5. Bjarke Koch-Ørvad says:

    Sorry

    I forgot to read this ;)

    “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 not longer be a Rhino Object but instead it 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’m having trouble though, using the points for anything. It returns an error

    • Bjarke,

      Well, I will start from the top:
      1. Sphere.ByCenterPointRadius has two inputs: centerPoint and radius. CenterPoint is a SINGLE point not a LIST OF POINTS which is what you are trying to use. I think Grasshopper had that back in the days where you could set the lacing to be CrossProduct, Shortest List or Longest List. Dynamo has a very similar lacing capability that you can set by clicking on the “|” symbol in the bottom right corner. Change that to longest list and give that a whirl. You should be getting a lot of Spheres.
      2. Line.ByStartPointDirectionLength is the same as above. Change the lacing and you should make a lot of lines. :-)
      3. NurbsSurface.ByPoints should be fine with a list of points as an input. What is weird is a 50 input for a degree U and V. I am not sure you are familiar with this, but a degree is not the same as number of segments. Try using something like 3 for both inputs. Also, please do read up about degrees in Nurbs Surfaces so you can better understand the tools that you are trying to play with. :-)

      Good luck!

      • Bjarke says:

        Thanks a lot

        Was it really that easy. I’m new to Dynamo but i’m a Grasshopper user so I know about lacing, I guess I just have to get use to the differences, working with list/tree structures ;)

        Regarding the UV I didn’t pay attention to what it actually needed as input. I just assumed the UV referred to number of UV divisions of the srf. My Bad ;)

        Thanks again
        Bjarke

        • Yeah, I was a Grasshopper user before I was a Dynamo user so I guessed that, that’s what tripped you up. Getting used to Dynamo after using Grasshopper is a little bit of a drag but its for sure easier than starting from scratch. It’s more like moving back in time and remembering where GH was few years ago. :-)

  6. Constantin says:

    Hello Konrad!
    This plugin is indeed amazing and opens up to huge possibilities.
    I had some troubles installing it but one of the reasons was because i used Dynamo Studio. After i changed to Dynamo i finally made it work.

    • I am glad it worked for you. Do you mind sharing which part of the installation process was hard? I would like to make that as easy as possible so all feedback is welcome.

  7. Nivaldo Curcio says:

    Would you please advise us any reason why we are receiving the error below.

    “The user object could not be created as the base type is missing.”

    Thanks in advance,.

Reply to Bjarke Koch-Ørvad Cancel Reply