Increasing integer number with push buttons

Is it possible with standard Grasshopper without using Anemone addon or Data recorder?

I just learned this today!

The following python script should do it:

if "count" not in globals():
     count = 0

if input1:
    count += 1

If input2:
    count -= 1
1 Like

I dont know python. Is it possible with standard widgets?

Insert a python component.
Double click it to open the editor.
Delete whatever is there.
Copy the following code in.
Click okay to save and close.

if "count" not in globals():
     count = 0

if x:
    count += 1

If y:
    count -= 1

a = count

Now you have a component that outputs a number. Whenever you press a button connected to x the number will go up and down on y.

  1. Solution exception:unexpected token ‘y’

The “if” before y should be lowercase. Sorry about that

thanks you! Can you please another button which will decrease the number?

Just connect a button to the y input

Hi!

Very nice!
The only thing I noticed is: when this Python component is present in a ‘Cluster’, everytime the cluster is reopend, the numbering is reset to 1.

Do you know a solution to ‘remember’ the last number?

Many thanks :slight_smile: