tv_undoOpenStack / CloseStack

A forum dedicated to George scripting questions
Post Reply
User avatar
NathanOtano
Posts: 1209
Joined: 01 Apr 2014, 07:07
Location: Biarritz, France
Contact:

tv_undoOpenStack / CloseStack

Post by NathanOtano »

Hey!

Some questions on tv_undoOpenStak and tv_undoCloseStack.

On a button, if it's an embedded comand script, what is the difference between putting just "tv_undoCloseStack" and, as on the wiki, "tv_undoCloseStack "Action Name""?
I've seen on the animator panel a button with his button name as the "action name". Also can a button have a name with "/" ou spaces or things like that and stille me recognize as a name? And on a script, why do we have to put an action name when we close it but not when we open it? What is, concretly, the "action name"?

And what about update undo? I don't really understand the wiki too.

I've seen some curious things with my undo and my own buttons with "tv_undoX", it undoes but keeps some actions, i think the last ones, even if i undo everything.

Thank you :)

Nathan
Working on Windows 10
Creator of Disnosc, providing storyboard, animation and design for 2D realistic pictural animation: https://www.disnosc.fr/ - nathanotano@disnosc.fr
Highly interested in animation workflows, I'm open to scripting new TVP functions for individuals and studios.
User avatar
Mads Juul
Posts: 3992
Joined: 02 May 2007, 19:18

Re: tv_undoOpenStack / CloseStack

Post by Mads Juul »

NathanOtano wrote: as on the wiki, "tv_undoCloseStack "Action Name""?
I don't know if putting a name after tv_undoCloseStack does do something. Maybe it is a mistake it is written in the WIKI?
does some from the TVPaint team know?
NathanOtano wrote: And what about update undo? I don't really understand the wiki too.
I've seen some curious things with my undo and my own buttons with "tv_undoX", it undoes but keeps some actions, i think the last ones, even if i undo everything.
I do not fully understand tv_updateUndo either. But if you do script do not undo properly. that means if your project have one state A. and you execute some script surrounded with tv_undoOpenStack and tv_undoCloseStack. and you Update one time. and You don't go back to the same Situation as before the script. then maybe you can solve it with tv_updateUndo. I have noticed especially when switching layers with George mistakes can happen.

I will show you an example
If I have this script to duplicate part of layers to other part of layers

Code: Select all


tv_undoOpenStack

getBounds = "68 139 1091 735"
setBounds = "68 736 1091 1332"

PARSE setBounds x1 y1 x2 y2
dotX = x1+((x2-x1)/2)
dotY = y1+((y2-y1)/2)

run = 1
layerPos = 0
WHILE run   
   tv_LayerGetID layerPos   
   lid = result   
   IF CMP(lid,"NONE")==0      
         tv_layerSet lid
      tv_BrushCut getBounds
      tv_restorebrush "subpixel 0"
      tv_dot dotX dotY
      layerPos = layerPos+1   
   ELSE      
      run =0
   END
END
tv_undoCloseStack
Here is my Project before the scipt. I have a layer with a blue Cirkle and A layer with a green add sign
undo_bug00000.jpg
undo_bug00000.jpg (28.38 KiB) Viewed 1240 times
Then I run my script. And the part of each layers in the "getBound" is copied to the "setBound"
undo_bug00001.jpg
undo_bug00001.jpg (31.8 KiB) Viewed 1240 times
But when I press undo I get this
undo_bug00002.jpg
undo_bug00002.jpg (29.19 KiB) Viewed 1240 times
It should be the same as before the script of course, but the green add sign is dissapeared, and now I got blue circles on more layers.
Clearly not the disired effect of an undo ;)
But if I place tv_unpdateUndo just before I switch layers in my script like this

Code: Select all

tv_undoOpenStack

getBounds = "68 139 1091 735"
setBounds = "68 736 1091 1332"

PARSE setBounds x1 y1 x2 y2
dotX = x1+((x2-x1)/2)
dotY = y1+((y2-y1)/2)

run = 1
layerPos = 0

WHILE run   
   tv_LayerGetID layerPos   
   lid = result   
   IF CMP(lid,"NONE")==0
	 tv_updateUndo  // PLEASE NOTICE I PLACED A TV_UPDATEUNDO HERE!!!!!!
         tv_layerSet lid
      
      tv_BrushCut getBounds
      tv_restorebrush "subpixel 0"
      tv_dot dotX dotY
      layerPos = layerPos+1   
   ELSE      
      run =0
   END
END

tv_undoCloseStack
Then I get the desired effect.
I find this a confusing behaviour. And i think it could be nice if tv_UndoOpenStack and tv_UndoCloseStack would work witout tv_updateUndo. I actually think it is a bug and I already have submitted it to the developers and I hope some day they would look at it. But then again it is not that big deal because we can fix it with putting in tv_updateUndo before a layer switch.

A last note on undo Some things you cannot undo forinstance setting the stencil with tv_layerStencil 0 On cannot be undo. But it wil also not be undone if you do it manually in TVPaint(Which I think could be nice. So I just sneak a little feature request in to add momodifying stencil to undo history)

Hope it Helps
-Mads
User avatar
NathanOtano
Posts: 1209
Joined: 01 Apr 2014, 07:07
Location: Biarritz, France
Contact:

Re: tv_undoOpenStack / CloseStack

Post by NathanOtano »

Thank you for your reply :) I understand now, cool to have your experience with it here. Really helpfull!
And now that you say it, i think my problem of non-undoing things was mainly with layers yes.

Du you think that if i put an updateundo just after (or before?) the undoopen it would always work for the whole script? If i dont want to put it right where the problem is on the script.
Working on Windows 10
Creator of Disnosc, providing storyboard, animation and design for 2D realistic pictural animation: https://www.disnosc.fr/ - nathanotano@disnosc.fr
Highly interested in animation workflows, I'm open to scripting new TVP functions for individuals and studios.
User avatar
Mads Juul
Posts: 3992
Joined: 02 May 2007, 19:18

Re: tv_undoOpenStack / CloseStack

Post by Mads Juul »

NathanOtano wrote: Du you think that if i put an updateundo just after (or before?) the undoopen it would always work for the whole script? If i dont want to put it right where the problem is on the script.
I think you need to put it right before the problem in the script. that mean before tv_layerSet lid in my example
User avatar
NathanOtano
Posts: 1209
Joined: 01 Apr 2014, 07:07
Location: Biarritz, France
Contact:

Re: tv_undoOpenStack / CloseStack

Post by NathanOtano »

Ok i think i understood by testing it. I think you always have to put an updateundo beacause the tv_openstack doesn't do it, it just stops the recordings of the actions (just after the action of launching the button that is recorded). And for some reason with some actions is also updates the stack even when it's open, but if you put an updateundo it always goes back to the updateundo place instead when you undo.

Seems ok for you? If you put the update undo just after the openstack in your script it should work, no?
Working on Windows 10
Creator of Disnosc, providing storyboard, animation and design for 2D realistic pictural animation: https://www.disnosc.fr/ - nathanotano@disnosc.fr
Highly interested in animation workflows, I'm open to scripting new TVP functions for individuals and studios.
User avatar
Mads Juul
Posts: 3992
Joined: 02 May 2007, 19:18

Re: tv_undoOpenStack / CloseStack

Post by Mads Juul »

NathanOtano wrote: Seems ok for you? If you put the update undo just after the openstack in your script it should work, no?
Like this?

Code: Select all

tv_undoOpenStack
tv_updateUndo //PLACING TV_UPDATEUNDO HERE DOES NOT WORK!!!

getBounds = "68 139 1091 735"
setBounds = "68 736 1091 1332"

PARSE setBounds x1 y1 x2 y2
dotX = x1+((x2-x1)/2)
dotY = y1+((y2-y1)/2)

run = 1
layerPos = 0

WHILE run   
   tv_LayerGetID layerPos   
   lid = result   
   IF CMP(lid,"NONE")==0
      // PLEASE NOTICE I PLACED A TV_UPDATEUNDO HERE!!!!!!
         tv_layerSet lid
      
      tv_BrushCut getBounds
      tv_restorebrush "subpixel 0"
      tv_dot dotX dotY
      layerPos = layerPos+1   
   ELSE      
      run =0
   END
END

tv_undoCloseStack
No it doesn't work. I think it only works when you pout it before the tv_layerSet.
-Mads
User avatar
NathanOtano
Posts: 1209
Joined: 01 Apr 2014, 07:07
Location: Biarritz, France
Contact:

Re: tv_undoOpenStack / CloseStack

Post by NathanOtano »

thank you :) ok, so if somebody of the team can explain it, it would be nice.
Working on Windows 10
Creator of Disnosc, providing storyboard, animation and design for 2D realistic pictural animation: https://www.disnosc.fr/ - nathanotano@disnosc.fr
Highly interested in animation workflows, I'm open to scripting new TVP functions for individuals and studios.
Post Reply