Page 1 of 1

Script Undo

Posted: 11 Oct 2012, 04:17
by clintonman
Doing some tests to see if undo can be done for a long series of script changes.

1. set streaming off in recorder preferences - side note: the tabs don't switch so you have to manually choose the settings tab to see it
2. RsRec.Clear()
3. RsRec.Start(Space.CurrentScene())
4. do scripting stuff
5. RsRec.Stop() last command in step 4
if need to undo
6. RsRec.Play(1000)
7. RsRec.Pause()
8. RsRec.Playback(10)

The RsRec commands must be run outside of the scene, because the scene is affected by them. I was chasing my tail a little bit because of that oversight.

Re: Script Undo

Posted: 11 Oct 2012, 12:53
by stan
great Clinton..does it undo those usual places that won't undo

Re: Script Undo

Posted: 11 Oct 2012, 14:42
by clintonman
stan wrote:great Clinton..does it undo those usual places that won't undo
Do you have an example?
If you mean outside of the 3d scene then no.

A couple of quotes from the sdk and manual gave me the idea.

sdk_tS761B8/Doc/structIRiRecorder.html, "Everything in the 3d Encapsulator is recorded....This technique allows detecting all changes in the content caused by user action, activity or simulation and then replay them even in reversed order"
manual chapter 2, "It can also be useful as unlimited undo support during scene and object editing."

Re: Script Undo

Posted: 11 Oct 2012, 18:41
by stan
Ok, when you used script changes in your first post I wondered if you mean it worked in a script when the undo doesn't.
I can see it being useful as a scene undo. I know I keep my history stack to the default amount of undo's. Then you could keep the recording and be possible to undo on demand.

Re: Script Undo

Posted: 11 Oct 2012, 19:40
by clintonman
Ordinary undo works for scripts as far as I know. It becomes a problem when the script makes say 50 changes with one key press, so you would have to undo 50 times to undo the script action.

My first test went ok. I added to the edge bevel script. It undos all the way back but then exits PE mode for some reason. I'll need to test some more to see if there's a way around that. The other thing I found is that if the "script undo" is run later in time then everything that changed between would be lost. I'm thinking a time limit on the undo might be good when using this technique.

Re: Script Undo

Posted: 13 Feb 2021, 20:05
by trueBlue
I find this to be super valuable when running your true Edge Bevel script in cases when the Bevel is not quite right.
Did you find a problem when using this?
Does not matter if Streaming is checked or unchecked and I can run it from the Scene
3D Record UnDo.png
3D Record UnDo.png (5.91 KiB) Viewed 2498 times
Start
if(Node.Exists("/Preferences/RecPref")) {
//Default settings
Node.Value("/Preferences/RecPref", "Compress during recording") = -1
Node.Value("/Preferences/RecPref", "Maintain record time") = 0
Node.Value("/Preferences/RecPref", "Streaming during record and replay") = -1
Node.Value("/Preferences/RecPref", "Speed of Replay") = 1
}
RsRec.Clear()
RsRec.Start(Space.CurrentScene())

Stop
RsRec.Stop()

Cancel
RsRec.Stop()
RsRec.Clear()

Undo
RsRec.Play(1000)
RsRec.Pause()
RsRec.Playback(10)
RsRec.Clear()