How to let GhPython choose the latest updated value?


#1

Hi all,

If there are multi-inputs, is it possible to let GhPython to detect and choose the latest inputted value?
Say I have 3 inputs are 12, 8.3 and 4.8, and the last one I type in is the 8.3, I want to let GhPython automatically always choose the last number I type.


Thanks for any suggestion,

Jack


#2

This is (perhaps) not always working, but a decent starting point:


(Giulio Piacentino) #3

Yes, as @MarcusStrube writes, you could save the values of the previous iteration and compare with the new values. Does it help, @Jack_Zeng?


#4

Splendor!!
I have tested it and it works perfectly!!
Could you explain a little bit more what is sticky and what it exactly doing?
Just want to learn a bit more on this…


Choose the Latest Inputed Value.gh (6.1 KB)

Appreciate for the help,

Jack


#5

I am not too good when it comes to explaining… But you can google sth. like “sticky python grasshopper”. It’s been answered several times. Sticky generally is a dictionary in which you can save all kinds of things to save state. And triplet is a tuple.

Most people, btw, use print very often… And enumerate and zip are very nicely explained in Python’s very good documentation.


#6

Cool!
Thanks Marcus!!:grin: