Grasshopper

algorithmic modeling for Rhino

Hello!

Let's say I have a complex Grasshopper definition, with some inputs (which can be for instance one surface, and 4 numbers), and some outputs (which could be maybe 2 surfaces and a list of curves).

I want to run it several times (but don't know how many!), but with different inputs. Is it possible to call the definition from inside a scripting component? (C# preferable, but not important).

Something like: A = MyOwnComplexDefinition(input1, input2, ....)

Just as easily as creating a new Point3D or Line inside a script, can I create a new MyOwnComplexDefinition?

Views: 1223

Replies to This Discussion

It's not exactly trivial, but it can be done. The attached file loads a cluster by name from the same file as the C# component (but you can load GH_Documents from wherever you want). It then makes sure that the cluster document is duplicated by copy/pasting it. This is obviously quite a time-hog, so you'll want to actually cache this step in production code. Finally, it sets the data from script inputs to cluster hooks and solves the internal document.

The code is very unoptimized and repeats itself a lot.

Attachments:

Thank you David, that works exactly as I hoped!


Is there a reliable way, on the grasshopper canvas, to input several instances of cluster inputs into a cluster, while still making sure that a new instance of the cluster is run every time? That way the cluster wouldn't be run from the scripting component, but the cluster inputs could be generated in a scripting component. Or would another method speed things up? 

Some (or all) of the cluster outputs seem to be left in Grasshopper until I restart Rhino (they're not removed from memory even if the cluster and everything else is disabled).

Is there a way to clear the memory, or get rid of those outputs, without having to restart Rhino?

Hi David, I am not a very advanced programmer. Can this be written in python as well?

To complement,
from Visual Studio you can create a DLL with a function that simulates your definition. Then from one script component in gh you insert the dll and call the function.
However, I think your problem can be done without code. It depends on if you only care about the outcome. In this case, since grasshopper you can make an algorithm to change one or all parameters after all the algorithm is executed, and save the result. This is to automate the production, not in a very elegant way, but you have this possibility with gh quite easily.

RSS

About

Translate

Search

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service