Connected toggles

Hi!

I have a script in which I let the user toggle previews along the way.

However, these toggles are in different parts of the document, controlling different previews. So I thought I could add froGH “Toggle Autostop” to the script, so that only one toggle can be set to True at a time, but I can’t get it to work. When a toggle is set to True and I click another one, the first toggle does revert to False, but so does the one that I click on.

Any ideas on how to fix this?

Thank you!

/Kaj

Toggle connections.gh (15.6 KB)

Here’s a method where you have a single master “Preview On/Off” switch and a drop-down list to choose which preview you want to activate. When you add new items to the list on the left, you need to zoom in and add a corresponding output to the Stream Gate component.

Pick A Preview.gh (7.3 KB)

Even simpler: You could have a “none” option in the list and just leave that Stream Gate output disconnected.

Also a Record Data with Value Limit = 1 might work?

Last_Button_True_other_Falses.gh (9.8 KB)

Hi!

Thanks you very much!

I used parts of both your ideas and made the recorder save 2, so the preview turns off if I press the same button twice, works well for my purposes!

EDIT:
Well, that didn’t work, I didn’t think it through properly.

I can’t turn it on and off, only on once and then it doesn’t turn on again.

Any more ideas on how to keep the on/off function working?

maybe using some sort of persistent data makes things easier… this is an example with python (I think you can write it in like 3 lines of code… but I’m very bad at it :smiley: )

Sticky_bools.gh (6.1 KB)

Wow, that works perfectly, just as I wanted! Thank you so much!

/Kaj

I didn’t see any toggles in the attached file. And although the topic is solved, this seemed like a fun “stuck at home sick on your holiday” thing to get the old brain working again. Here’s a quick go, where we set all input toggles to False expect for the last toggled one, which will be True (they are input using hidden wires here, in order). There might be some odd expiration/update issues here, but seems to work as expected when recording the toggle outputs (i.e. using the standard Data Recorder):


251016_OneTrueNFalseToggler_00.gh (5.0 KB)

Oh yeah, sorry, they were toggles from Ladybug, I use them so much I forgot that they’re not part of the regular program!

Thanks for the help!

verry cool. thank you!
(take the freedom to add a condition:

=

Ah yeah, good call. One would probably want to add some additional conditionals here and there, depending on the implementation context. And maybe an on/off toggle.