Grasshopper

algorithmic modeling for Rhino

Hi all,

I'm trying to write a C# component that can update parameter values of other components in the GH Document outside of itself and can also read in values from other components during execution.

The Galapagos component is essentially an example of this very thing.  Any thoughts or directions would be much appreciated.

Thanks!

David

 

Views: 540

Replies to This Discussion

That's not possible. While a C# component is executing a document solution is in progress which means that you cannot make changes to objects.

You can change values and read data, but you have to do so outside of the GH solution pipeline. This involves either delayed callbacks to methods, or you can trigger the methods from a window. Galapagos chooses to do the latter, but it's cumbersome to design windows using pure code.

Thanks for the information here David.  I really appreciate it.  It saves me quite a bit of time banging my head against the keyboard. 

So if I wanted to trigger methods from a window, I assume that's something I can't easily do from within a C# scripting instance in GH, but that it would better to do it in visual studio (utilizing the assembly wizard for GHA projects) by utilizing VS's form creation/editing tools?  Appreciative of any thoughts you might have here on how to tackle this.  Also if it's too complicated, then I'll try other directions.  Thanks again for your time and thoughts!    

It depends a bit on what sort of UI you want to make. Just a window with one or two buttons and labels shouldn't be too difficult in code.

I have to go make dinner now, but I may be able later to code up a small example.

It's a bit clumsy, but the script creates a window (every time it runs) with one button. This button create all slider permutations (so be careful, there may be a lot of permutations on high resolution sliders) and harvests all data in the specified parameter. Ultimately it inserts a new parameter with all recorded data.

Attachments:

This is great!  Exactly what I needed to get my head around the issue!  Thanks so much for taking the time.  Very much appreciated!

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