Grasshopper

algorithmic modeling for Rhino

I'm not sure if this is possible, but I have several grasshopper components that I would like to run from inside a single Grasshopper component...

Since grasshopper components are created as class types, I am wondering if it is possible to call everything within "Protected Overrides Sub SolveInstance(DA As IGH_DataAccess)" for every component that I want to run... They all have the same inputs and outputs, so there shouldn't be any problems with variables.

I imagine this "Combined" component would look something like:

Protected Overrides Sub SolveInstance(DA As IGH_DataAccess)

run Component1.vb(SolveInstance)

run Component2.vb(SolveInstance)

run Component3.vb(SolveInstance)

... etc

End Sub

I have just been diving into VB for the past few weeks, so I may be overlooking something rudimentary... Please let me know if this is possible, your comments and suggestions are welcome!

Views: 743

Replies to This Discussion

Steve has done some work making this possible in python. If however you have some files you want to run, you can load an entire GH document in a VB component, populate the inputs and solve it. Do you have a *.gh file?

I think my problem was learning VB a little bit better. I figured out that if I place the script in each component into a Public Shared Sub, then I can call the script from the Protected Overrides Sub. Then the component is just calling the Public Shared Sub to do my bidding:

'------------------------------------------

Protected Overrides Sub SolveInstance(DA As IGH_DataAccess)

DA.GetData(0, input)

DA.GetData(1, run)

if run = True Then

ComponentName1.SharedSubName1(input)

ComponentName2.SharedSubName2(input)

ComponentName3.SharedSubName3(input)

End if

End Sub

'--------------------------

In this way I can have several components, and one that can run all of the others simultaneously.

This probably seemed like a trivial problem to begin with.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service