SR flip flop

Hi all;

How can I write a SR flip flop either in python or C# in grasshopper?

I have a list of “True” “False” items (S) which update based on timer. When I receive False, I want to have false in my output. But when it changes to True, I want to keep it for ever True even if it gets back to false, unless I press the R(reset) manually.

Firefly has a similar component called “NOR Flip Flop”. It works properly with one item. But for multiple inputs, when it receives one True, it changes all of items to true.


Interesting problem!

You need to declare a list outside the RunScript scope, and then update that accordingly. This will also enable you to resize the list if you add more booleans and then hit the button:

private void RunScript(List S, bool Reset, ref object A) {
  for(int i = 0; i < S.Count; i++) outBools.Add(false);

for(int i = 0; i < outBools.Count; i++)
  if(!outBools[i] && S[i]) outBools[i] = true;

A = outBools;


// <.Custom additional code>
List outBools = new List();
// </Custom additional code>


Thanks John. It works properly.

1 Like