Python Script Advice

Just case someone ends up here from doing a search I thought I would link what I figured out about why I can’t undo my script with the button:

Pretty much using Rhino.RhinoApp.RunScript() in a python script causes everything in the alias, or button or whatever to run immediately… so any undo would run way before the script finsihed… any command at all after the script in a button will run immediately when the first Rhino.RhinoApp.RunScript() is used and I can’t find a way to force a wait for the script to end… it’s some probably something very fundamental about the way Rhino.RhinoApp.RunScript() works.

So it’s completely impossible for me to use Export and then do an undo… unless I do the undo myself… but I might get distracted and forget… so the only real option is to with one method or another make a copy, work on the copy, then delete it.