Week 11

Baptiste Higgs
Design Computing
Published in
3 min readMay 23, 2017

Although I have worked on my project, none of the progress is particularly interesting and/or noteworthy. Instead, here are some things I’ve found after working with GhPython (for some other projects) which Ben introduced a couple weeks ago in one of his lectures:

  • In order to import variables from grasshopper scripting you’ve done, connect the modules as you would with any other grasshopper component. The names of the input and outputs will correspond to the variable names in python. If you want to change the variable names, right click on the corresponding input/output and edit the name text at the top of the menu that appears.
  • You can also add & remove variables by zooming really close in to the module and clicking the + and — buttons to respectively add and remove variables.
  • To edit the code, double click on the module. You can also import the code as an input to the module. To access this input, right click on the name of the module and click on ‘Show “code” input parameter’.
  • To be able to actually make geometry in rhino (e.g. lines, circles, etc.) you have to use something called rhino script syntax. Here’s a link to a really helpful wiki on it: http://developer.rhino3d.com/guides/#rhinoscript Before all the rest of your code you need to add the following line in order to use any rhinoscript functions:
  • You don’t actually have to type the ‘as rs’ at the end, but you’ll find that nearly everyone does — typing rs.AddClippingPlane() is much shorter than typing rhinoscriptsyntax.AddClippingPlane() and everyone knows what rs means.
  • Once you’ve actually got your code you want to run, you can press ‘Test’, which does the same thing as ctrl+shift+b in atom. You’ll see any printed text in the area between the ‘Test’ button and the typing area. If you’re printing the rhino/grasshopper objects you’re trying to use (e.g. a point) it’s not going to look very friendly, as you can see in the results below. If you click ‘OK’ below, the code will be run, but the editor will close too and you’ll be able to see any results you’ve generated in a much more understandable way.
  • To make sure that the code didn’t have any issues in it, I found it easier to just copy-paste it into a file in atom and see what errors come up. When you run code in the GhPython editor it does tell you where it failed to run if there were some errors, but it isn’t as intuitive and easy to use as in the atom editor.
  • Sadly, as far as I know there is no way to use a grasshopper module within a piece of GhPython code as a function, but rather you have to output the values, use the module, and then re-input into a different GhPython block (if necessary).

Once I started using GhPython, I couldn’t stop — after I got used to it it was much easier to do a lot of tasks in python rather than messing around with modules that had limited capabilities. Definitely give it a go if you haven’t already!

--

--