Grasshopper

algorithmic modeling for Rhino

Hi I have just downloaded Grasshopper and Firefly. I wanted to use the Binary Blink in Firefly to increase an integer value over time, but I'm not having much luck. can anyone point me in the right direction?

Views: 517

Replies to This Discussion

Hi Conor,

I think you have the wrong impression of what the Binary Blink component does.  It merely oscillates 0s and 1s based on an incoming time pattern (in ms).  So, this wont increment anything (as it will always return back to 0).  I'm not sure there is a built in component (although I could be wrong) that does what you want to do (Kangaroo might have something).

However, this isn't hard to do with a simple scripting component.  Basically, what you need to do is to declare a counter variable outside the RunScript routine.  Each time the RunScript routine is called, the counter is incremented by 1.  You can use the GH Timer component to trigger this solve instance routine to occur at regular intervals.  If you add an input for the reset (boolean), then you can reset the counter back to zero whenever you want.  The code would look something like this (in C#).

 

private void RunScript(bool rst, ref object A)
  {
    globalcnt += 1;
    if (rst) globalcnt = 0;
    A = globalcnt;
  }

  //<Custom additional code>
  int globalcnt = 0;

 

I've also added the .ghx file in case you wanted to take a look.

Attachments:
If you are looking for a ready made component for this, the Kangaroo 'counter' component works just like the code Andy posted - A boolean toggle to reset, and it increments by one with every update.
Thanks very much. I will give these a go

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