I have a Python script which does some stuff and remembers which state it is in after doing the stuff. I then use scriptcontext.sticky to remember what state the file is in.
The problem is if I undo the changes then Rhino doesn’t undo the change in scriptcontext.sticky, so it thinks it is in the new state when it is really back in the old state.
Is there a way to undo changes to scriptcontext or another undoable way to remember variables in a Python script?
import scriptcontext as sc import rhinoscriptsyntax as rs def statechange(): if sc.sticky.has_key("state"): state = sc.sticky["state"] else: state = False rs.MessageBox("changed state to "+ str(state)) rs.AddPoint(0,0,0) state = not state sc.sticky["state"] = state if __name__ == "__main__": statechange()