Grasshopper

algorithmic modeling for Rhino

Hi all,
I am trying out some forms and buttons for some potential future exploration. I see a few different ways to go about it. Some examples set up the form as a class and other just create the form as a subroutine. I see advantages to both (seems the class structure is probably the way to go?). The issue I see with the Class examples is that they always seem to use Application.Run(New Form1) Where 'Form1' is the name of the form class. When I close this form, so too closes the GH def panel and I am not able to retrieve it unless I shutdown rhino and open things up again.

If I create a function to create the form when called, I do not kill GH when I close things...

Now to my issue. Somehow I thought the output variables (A for example) was able to be seen by all aspects of my code. What I want to do is click a button and have A change values. I got a badly working version by declaring a variable and in the button event handler changing the value of that variable. Then I am able to set the function equal to that variable, and eventually 'A' can be set equal to that function.

During the execution of the form, A does not dynamically change as I click the buttons. Only if I close and run the form again do I see the output of A change. How can I set this up so things update as I click the buttons?

Views: 1883

Attachments:

Replies to This Discussion

No dice. That won't work just because you're responsible for starting Rhino in the past. I don't know enough about the possibilities here but I'll ask Steve Baer (he's the dll wizard in the office).

--
David Rutten
david@mcneel.com
Seattle, WA
Ok, Thanks!

One more thing...
Currently if I want to use the output from the script component (pushed out by the 'UI') in any other component there is no refresh. I have to use a timer to update the def...I thought that with each event (button clicked, trackbar slide, etc) the def would be recalculated. I see that while the panel connected to the output changes, no other component recognizes the change. Any way not to use the timer to bypass this?
Yup, Steve confirms this is pretty much impossible with the way DotNET has been designed. So it's impossible to use either the Rhino DotNET SDK or Grasshopper from an external application.


Regarding your latest question, Grasshopper updates when a component claims it expired. So in order to update based on a button press, you need to tell the ScriptComponent that is running your code that it has expired. This will cause it to expire all the objects downstream of it, who in turn will expire all the objects that depend on them and so on. After this shockwave has subsided, the component tells the document that owns it to recompute the solution. The document will then iterate over all components, and when it finds a component which has just been expired it will tell it to recompute itself.

The problem is that your script does not know which component owns it, so it has to expire the entire document instead. I will provide a third member in the VB script editor (alongside doc and app) which points to the component which runs the script. Then you'll be able to trigger a clean recompute. And it will work in the new version.

--
David Rutten
david@mcneel.com
Seattle, WA.

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