Kangaroo

THIS FORUM IS NO LONGER ACTIVE. PLEASE POST ANY NEW QUESTIONS OR DISCUSSION ON:

https://discourse.mcneel.com/c/grasshopper/kangaroo

The discussions here are preserved for reference, but new questions posted here are likely to go unanswered.

Kangaroo is a Live Physics engine for interactive simulation, optimization and form-finding directly within Grasshopper.

Internalised timer

Good evening Daniel, 

I have a quick question; is there a big trade secret behind how you internalize the timer for kangaroo 2?

or would you mind sharing some information about how you cracked it? 

I am currently trying to do it with the StopWatch class, but I am thinking that you should be able to access your current component and force it to refresh somehow.. 

Looking forward to hear from you.

  • up

    Anders Holden Deleuran

    Hi Jens. You can a look at the function called ghComponentTimer() here. As far as I recall I based it on a C# snippet by either David or Andrew Heumann, you should be able to find it through a forum search I imagine. As you can see the trick is to call ScheduleSolution(). Have a good meeting today and say hi :)

    1
    • up

      Jens Pedersen

      fixed it if anyone is interested:

      private void RunScript(bool a, ref object A)
      {

      if(a){
      _timer();
      }

      A = count++;

      }

      int count = 0;
      GH_Document GHdoc;

      void _timer()
      {
      GHdoc = owner.OnPingDocument();
      GHdoc.ScheduleSolution(1, callBack);
      }

      public void callBack(GH_Document GHdoc)
      {
      owner.ExpireSolution(false);
      }

      public void ExpireSolution(bool recompute)
      {
      recompute = true;
      }