Grasshopper

algorithmic modeling for Rhino

How to write a counter which can be paused and can be reset in c# component?

Hi,

I was trying to write a counter which count from 0 to infinity, with an increment step of 0.01. The current value is the output.

There is a boolean toggle to make the counter start.

There is a boolean toggle to make the counter pause.

There is a boolean toggle to reset the counter to start from 0.

It may look something like the image below

The puzzled thing for me is the boolean toggle is different from buttons in windows form. Buttons are clicked to raise events while boolean toggles have two states. What I need is some input controls to control the start, pause and reset. Is the boolean toggle a right way to start? Is it a correct way to realize this using timers? Could anyone provide some simple code sample for me to start with?

Thanks!

-Jerome

Views: 5909

Replies to This Discussion

If you don't need to go to the trouble of writing your own then I would recommend this set up using Kangaroo's Counter Component.

To Pause right click on the Timer and select Enable.

To Reset Toggle the Boolean to TRUE

To Start Toggle the Boolean to FALSE

EDIT: this might not be a perfect solution as the counter will continue to increase after each Solution Run when the timer is disabled

Thanks for your help, Danny.

This solves part of the problem. One reason I don't like to use the timer component is because I want "pause" based on inputs rather than mouse click. I don't know if this could be achieved not using custom component.

Hi Jerome,

Firefly has a counter which allows you to start/stop the counter and reset.  You can also define the step size of each iteration.  Would this work for what you're trying to do?

-Andy

Thank you, Andy,

The counter component is exactly want I want. By the way, I haven't used your firefly since last August, so many new components! I think I will spend some time to try these new functions.

Thank you for your component and thank you for your firefly!

-Jerome

Hi Andy,

I am trying to use the Firefly counter component with the "reset" input being controlled by a list of boolean values instead of just by one. Basically I want a list of numbers in which some stay at 0 and some would increase.

But as long as one of the reset values is set to "True" the counter stops counting.

Any ideas?

Hi Jerome,

you can also use my GENERATION counters (video) if you want.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service