What the script is supposed to do is turn on History if it’s not already on and remember that so it can turn it back off again at the end; but if History is on to begin with, I assume the user doesn’t want to turn it off, so it needs to stay on.
hState = Rhino.EnableHistoryRecording(True)
turns history on, but hState stores the previous condition
There is a bug currently that if History isn’t on, Rhino.EnableHistoryRecording() returns Empty instead of False. So I set up the script to look at what hState is at the end - if it’s anything OTHER than True (this includes both False and Empty), it turns the history back off.
If Not hState Then
This way, when the bug gets fixed, the script will still work…