Custom Panels for flipping between Keys, Breakdowns, Inbetweens etc.
Posted: 30 Sep 2024, 23:21
Hello, here are a couple of custom panels I've developed and explanation of what they do/how to use them.
PLEASE NOTE: These were made for TVPAINT 12, and while I've tested them on the demo version of 11.7.3, and they function fine there I have not tested them as thoroughly. Also, I am new to scripting, and only after trying one final time did I make some headway with GEORGE. I've tried to debug these panels/scripts as much as I can testing it out myself. They should work fine, but they do use a loop, and it's possible I missed some variable that might cause it to misfire. If after installing them, you end up having an issue where it seems like TVPAINT is frozen, please hold the ESCAPE key for a second or two, if there is some issue with the code being stuck in a loop or executing it will cancel the script out.
(I had posted an earlier version in another thread in the George scripting subforum, this version gets rid of some bugs I discovered, changed the way some of the code was built, more features etc. etc. I will call this version v1.0 as the other thread was mostly to show Sven what I had been thinking of and had gotten to work somewhat)
Flip Keyboard Toggle
The idea behind this panel is some similar functionality to Harmony as discussed in this thread: https://forum.tvpaint.com/viewtopic.php ... 17#p124917
Basically, I want to have two buttons on my keyboard set as shortcuts to move backward/forward along the timeline, with the ability to toggle on/off options for which images those shortcuts go to, and that's in short what this panel does.
**note These panels makes use of writing/reading to the config file under the head [kcustom]. It shouldn't cause any problems in the config, but If you want remove the panel and any remove traces of it, go into the config.ini file in the AppData\Roaming\TVPaint\Confignamehere and open it in a text editor and delete the portion underneath [kcustom].
Parts of the Custom Panel
1. Backward/Forward Keys > First thing is you will need to set up a shortcut key for going backward and forward along the timeline. I use F and G respectively. Once you have set these shortcuts, you can close the horizontal divider in the custom panel to hide those buttons to make it smaller.
**I would also highly suggest setting a modifier key such as shift or ctrl + the above two buttons to either layer > Go LEFT/RIGHT or layer > Prev/Next IMAGE. This will be explained more later, but because the script only moves between instance heads, these added shortcuts will give you the ability to move through individual exposures to break them etc. I use shift F + G myself.
2. K B E I Buttons > These four buttons make up the main portion of the functionality.
Keys, Breakdowns, Extremes and Inbetweens respectively, they will use the first 3 built in Image Marks for Keys, Breakdowns, and Extremes. For Inbetweens, the script does not use an Image Mark, but rather the lack of a Mark to determine which instances should be considered an inbetween.
The way these buttons work is pressing them once will turn that respective flag on, and pressing it again will turn the flag off.
(Just a quick explanation: I don't use extremes in my own workflow, but having an extra flag to work with is useful for a number of reasons. I've put extremes after breakdowns in the "hierarchy order" though technically they would come before in importance: see the discussion in the above linked thread for more discussion about Keys/Extremes etc if you are so inclined. If this is annoying to you, you can just simply swap the icons and use what is the current Breakdown button and MARK 2 for Extremes and vice versa, BUT just be aware in the code underneath the flags are labelled as Mark 2 = BD, Mark 3 = EX and so only change the ICON of the buttons, not the button order or it may break things).
The buttons are color agnostic in the script as the code only checks for the built in number of Mark 1, Mark 2, and Mark 3(labelled A, B, C respectively by default in v12.0.1) So please feel free to recolor and change the icons accordingly, I use different colors myself but thought for demonstration this would be simpler.
(If you are inclined, the code *I think* should be simple enough to add any number of flags/marks you want. If you look at each button and the george scripts that are produced by installing the script, they are documented to explain whats happening. I haven't tried this but it should be not to difficult the way I have it set up)
3. Check Button > The check button is super important and should get it's own shortcut. (I use CTRL + F) As TVPaint has no way to tell you if a custom panel button is turned on/off, this is the workaround I am using. Pressing the check button will bring up a menu at your mouse position with the following options.
The numbers show the relationship of the Custom Panel buttons to their respective options in the Menu.
The top row(highlighted in white) is your "Check" portion, which will be how you can quickly reference which Flags are on/off. (note**Choosing this option, cancelling out, or clicking outside the menu will not do anything)
From left to right they correspond with the K, B, E, I, WRAP buttons. An O will mean that flag/button is ON and an X will mean that button/flag is OFF.
The other portions of the drop down menu give you another option of setting flags on/off as if you were clicking the custom panel buttons. WRAP and ALL open sub menu's with ON/OFF and will be explained below.
4.Wrap Menu > This will allow you to set wrap ON/OFF which will cause the script to wrap around and start at the beginning/end of the layer looking for the next image to go to. This acts like the "Loop" function available in the built in Image Mark menu when you use the built in prev/next mark shortcuts, but also works for inbetweens. Wrap will work as soon as you are at the image in a layer where there are no more flags in that direction to continue to.
5.ALL Menu > This will set all flags On/Off.
The Function of the Script
Setting the script flags for K, B, E, I will cause your shortcut keys(F, G in this example) to skip all images aside from those flagged with their respective Image Mark, or lack thereof for Inbetweens.
These flags operate irrespective of each other, so you can have any combination set on/off and those that are OFF will be skipped.
For a first and simplest example is if you have only K turned on, then F/G will only go between your Red Image Mark(Key) frames.
Another example if you have K & B set, then using F/G will only go backward/forward to images Marked with Red(Keys)/Orange(Breadkdowns).
If you have only I(inbetweens on) all frames that have an Image Mark will be skipped as the script looks then for non-marked frames(this includes ANY marks not just the first 3 in the list).
Some important functionality notes:
-By default the flags are all off and if you try and use F/G with all flags off, the Inbetweens flag will automatically turn on. This is to prevent everything being turned off and the user coming back between sessions and forgetting why nothing is happening. Also, if there are any marks outside the first 3 added to an image, that image will be skipped by the IB flag, so this is one way to have all your flags ON when going through every instance but skip certain frames/images.
-If wrap is set to OFF, you can proceed outside the start or end of a layer's current images so that adding more instances is easier(this is an improvement over the original script). This is better as it functions like the default behaviour of next/previous instance shortcut to allow easily adding new frames.
-When wrap is on, having shift + F/G which we set up to earlier as layer:next/prev image or layer:go left/right will be the quickest way to move outside the current images to add new frames(You can use mouse or other keyboard shortcuts as well). Wrap will only function WITHIN a layer's images, so if you use your mouse or another shortcut to go outside the current set of images(to an empty frame) and try and press F/G, wrap is automatically turned off and you will proceed frame by frame as normal. If you use the shift F/G key to get outside, then add a new image, Wrap will continue to stay ON.
-As mentioned earlier the main script only moves between instance heads, these added shortcuts of shift F/G(in this example) will serve another use, which is to move through individual exposures to break them etc. HOWEVER, if any image marks are set to an individual exposure the script will go to them if the respective flag is enabled.
-If wrap is ON and there is no other flagged images on a layer for the script to go to(such as a layer with a single image), it will give you a warning (both to prevent an infinite loop, and remind you wrap is on and that's why you aren't moving).
-The script functions on each type of layer(anim, bg, ctg) except Puppet, Folder layers and the Camera layer. Note it functions fine on the layers inside a folder, but not on the folder layer itself. (Puppet layers are a bit buggy, and function a bit differently, so I have it disabled for now)
I think that's pretty much it for that custom panel, I've tried to be exhaustive especially for the aspects that might not be readily apparent, and if I realize I left anything out I will edit this.
The second panel:
Flips Toggle
This functions very similarly and is meant to compliment the above Panel. It looks about the same so I won't go over every button again, but note that the WRAP/ALL buttons do not exist. I'll explain that below.
The main idea behind this panel is to have one single shortcut(in my case I use W) for a FLIP that can have its behaviour changed without having to go into the FLIP MENU to do so. The added bonus of the CHECK menu means you can also do this at your mouse cursor very easily.
First thing, we need to create a MANUAL FLIP in the built in Flip menu, and call it "FlipsToggle" no quotes or spaces between words, case should not matter. Set a shortcut, I am going to use "W" for this example. You can
Next go to your shortcut menu and set a shortcut for the CHECK menu as we did for the previous panel. This functions the same albeit with some differences outlined below. I am using "SHIFT + W" for this shortcut as its ergonomic for me.
If you try and use the script it will always check there is a flip named FlipsToggle, if there is not it will prompt you to create it and exit. Please make sure FlipsToggle is a MANUAL flip, it will not function as intended for other flip types.
Note**The rest of the settings in the flip panels, such as limits, return to origin OOP etc. as far as I have tested shouldn't cause any bugs as this script is using the built in FLIPS functionality, and simply changing the CHECKPOINT flags. However, be aware I use the settings in the panel shown and haven't exhaustively tested those other options.
The 3 main buttons function the same as before. If you flag K, B, or E, it is going to change the settings for "FlipsToggle" CHECKPOINTS to Mark1, Mark2, Mark3 as checked respectively. These can be combined and toggled on/off irrespective of each other to skip certain marked frames and not others.
Important to note, anytime you flag one of the Marks, it will automatically turn the IB flag off. If you want to include IBs, you need to turn that one on separately, there is more info below in the IB section regarding how to go through all your instances.
So with all 3 Marks on it will look like this
Now, the major difference between the two panels is how the "I" or Inbetween flag works.
With this panel, flagging the IB ON will change the CHECKPOINTS to INSTANCES (irrespective of if you have any or all marks flagged OFF). This functionality will also allow you to keep your MARK flags set to on, but then while IB is flagged you will go through all instances, and then when you flag off IB's again you will have your Marks still flagged as previously. The other differences between the panels are:
There is already a WRAP option built into the Flips Panel, which is "Loop between limits," but there is no shortcut for turning that on/off that in the custom panel (maybe on my to do list for later).
Also the way the ALL button functions is different. It will still toggle all Flags ON/OFF, but with all flags set to OFF, the Checkpoint will instead change to ALL IMAGES, this is some added functionality so you have an option to go through exposures as well to break them etc. with just this custom panel. One last tiny note: the way FLIPS function is that if you are on a frame not flagged when you start to use the FLIP, it will include that frame as you cycle through your "roll". This is a feature not a bug I believe, and so if for example you have only KEYS on, and start using a FLIP while on a Breakdown, it will include that Breakdown as you "roll." When you stop on a KEY, and start again, that Breakdown that was included before will now not be included in the "roll" because it is not part of the Checkpoints flag.
Hopefully you find these panels useful if you were looking for this kind of function, if it existed as a custom panel elsewhere on the forum and I somehow missed it then please ignore(haha, *cry*)
Please report any bugs you run into and I will do my best to fix them. Also let me know if you think it can be improved or if it is useful to you at all.
Special thanks to Svengali for pointing me in the direction of using tv_writeuserstring and tv_readuserstring for toggleable buttons and encouraging me that once you get around some syntax stuff, George is not too bad.
PLEASE NOTE: These were made for TVPAINT 12, and while I've tested them on the demo version of 11.7.3, and they function fine there I have not tested them as thoroughly. Also, I am new to scripting, and only after trying one final time did I make some headway with GEORGE. I've tried to debug these panels/scripts as much as I can testing it out myself. They should work fine, but they do use a loop, and it's possible I missed some variable that might cause it to misfire. If after installing them, you end up having an issue where it seems like TVPAINT is frozen, please hold the ESCAPE key for a second or two, if there is some issue with the code being stuck in a loop or executing it will cancel the script out.
(I had posted an earlier version in another thread in the George scripting subforum, this version gets rid of some bugs I discovered, changed the way some of the code was built, more features etc. etc. I will call this version v1.0 as the other thread was mostly to show Sven what I had been thinking of and had gotten to work somewhat)
Flip Keyboard Toggle
The idea behind this panel is some similar functionality to Harmony as discussed in this thread: https://forum.tvpaint.com/viewtopic.php ... 17#p124917
Basically, I want to have two buttons on my keyboard set as shortcuts to move backward/forward along the timeline, with the ability to toggle on/off options for which images those shortcuts go to, and that's in short what this panel does.
**note These panels makes use of writing/reading to the config file under the head [kcustom]. It shouldn't cause any problems in the config, but If you want remove the panel and any remove traces of it, go into the config.ini file in the AppData\Roaming\TVPaint\Confignamehere and open it in a text editor and delete the portion underneath [kcustom].
Parts of the Custom Panel
1. Backward/Forward Keys > First thing is you will need to set up a shortcut key for going backward and forward along the timeline. I use F and G respectively. Once you have set these shortcuts, you can close the horizontal divider in the custom panel to hide those buttons to make it smaller.
**I would also highly suggest setting a modifier key such as shift or ctrl + the above two buttons to either layer > Go LEFT/RIGHT or layer > Prev/Next IMAGE. This will be explained more later, but because the script only moves between instance heads, these added shortcuts will give you the ability to move through individual exposures to break them etc. I use shift F + G myself.
2. K B E I Buttons > These four buttons make up the main portion of the functionality.
Keys, Breakdowns, Extremes and Inbetweens respectively, they will use the first 3 built in Image Marks for Keys, Breakdowns, and Extremes. For Inbetweens, the script does not use an Image Mark, but rather the lack of a Mark to determine which instances should be considered an inbetween.
The way these buttons work is pressing them once will turn that respective flag on, and pressing it again will turn the flag off.
(Just a quick explanation: I don't use extremes in my own workflow, but having an extra flag to work with is useful for a number of reasons. I've put extremes after breakdowns in the "hierarchy order" though technically they would come before in importance: see the discussion in the above linked thread for more discussion about Keys/Extremes etc if you are so inclined. If this is annoying to you, you can just simply swap the icons and use what is the current Breakdown button and MARK 2 for Extremes and vice versa, BUT just be aware in the code underneath the flags are labelled as Mark 2 = BD, Mark 3 = EX and so only change the ICON of the buttons, not the button order or it may break things).
The buttons are color agnostic in the script as the code only checks for the built in number of Mark 1, Mark 2, and Mark 3(labelled A, B, C respectively by default in v12.0.1) So please feel free to recolor and change the icons accordingly, I use different colors myself but thought for demonstration this would be simpler.
(If you are inclined, the code *I think* should be simple enough to add any number of flags/marks you want. If you look at each button and the george scripts that are produced by installing the script, they are documented to explain whats happening. I haven't tried this but it should be not to difficult the way I have it set up)
3. Check Button > The check button is super important and should get it's own shortcut. (I use CTRL + F) As TVPaint has no way to tell you if a custom panel button is turned on/off, this is the workaround I am using. Pressing the check button will bring up a menu at your mouse position with the following options.
The numbers show the relationship of the Custom Panel buttons to their respective options in the Menu.
The top row(highlighted in white) is your "Check" portion, which will be how you can quickly reference which Flags are on/off. (note**Choosing this option, cancelling out, or clicking outside the menu will not do anything)
From left to right they correspond with the K, B, E, I, WRAP buttons. An O will mean that flag/button is ON and an X will mean that button/flag is OFF.
The other portions of the drop down menu give you another option of setting flags on/off as if you were clicking the custom panel buttons. WRAP and ALL open sub menu's with ON/OFF and will be explained below.
4.Wrap Menu > This will allow you to set wrap ON/OFF which will cause the script to wrap around and start at the beginning/end of the layer looking for the next image to go to. This acts like the "Loop" function available in the built in Image Mark menu when you use the built in prev/next mark shortcuts, but also works for inbetweens. Wrap will work as soon as you are at the image in a layer where there are no more flags in that direction to continue to.
5.ALL Menu > This will set all flags On/Off.
The Function of the Script
Setting the script flags for K, B, E, I will cause your shortcut keys(F, G in this example) to skip all images aside from those flagged with their respective Image Mark, or lack thereof for Inbetweens.
These flags operate irrespective of each other, so you can have any combination set on/off and those that are OFF will be skipped.
For a first and simplest example is if you have only K turned on, then F/G will only go between your Red Image Mark(Key) frames.
Another example if you have K & B set, then using F/G will only go backward/forward to images Marked with Red(Keys)/Orange(Breadkdowns).
If you have only I(inbetweens on) all frames that have an Image Mark will be skipped as the script looks then for non-marked frames(this includes ANY marks not just the first 3 in the list).
Some important functionality notes:
-By default the flags are all off and if you try and use F/G with all flags off, the Inbetweens flag will automatically turn on. This is to prevent everything being turned off and the user coming back between sessions and forgetting why nothing is happening. Also, if there are any marks outside the first 3 added to an image, that image will be skipped by the IB flag, so this is one way to have all your flags ON when going through every instance but skip certain frames/images.
-If wrap is set to OFF, you can proceed outside the start or end of a layer's current images so that adding more instances is easier(this is an improvement over the original script). This is better as it functions like the default behaviour of next/previous instance shortcut to allow easily adding new frames.
-When wrap is on, having shift + F/G which we set up to earlier as layer:next/prev image or layer:go left/right will be the quickest way to move outside the current images to add new frames(You can use mouse or other keyboard shortcuts as well). Wrap will only function WITHIN a layer's images, so if you use your mouse or another shortcut to go outside the current set of images(to an empty frame) and try and press F/G, wrap is automatically turned off and you will proceed frame by frame as normal. If you use the shift F/G key to get outside, then add a new image, Wrap will continue to stay ON.
-As mentioned earlier the main script only moves between instance heads, these added shortcuts of shift F/G(in this example) will serve another use, which is to move through individual exposures to break them etc. HOWEVER, if any image marks are set to an individual exposure the script will go to them if the respective flag is enabled.
-If wrap is ON and there is no other flagged images on a layer for the script to go to(such as a layer with a single image), it will give you a warning (both to prevent an infinite loop, and remind you wrap is on and that's why you aren't moving).
-The script functions on each type of layer(anim, bg, ctg) except Puppet, Folder layers and the Camera layer. Note it functions fine on the layers inside a folder, but not on the folder layer itself. (Puppet layers are a bit buggy, and function a bit differently, so I have it disabled for now)
I think that's pretty much it for that custom panel, I've tried to be exhaustive especially for the aspects that might not be readily apparent, and if I realize I left anything out I will edit this.
The second panel:
Flips Toggle
This functions very similarly and is meant to compliment the above Panel. It looks about the same so I won't go over every button again, but note that the WRAP/ALL buttons do not exist. I'll explain that below.
The main idea behind this panel is to have one single shortcut(in my case I use W) for a FLIP that can have its behaviour changed without having to go into the FLIP MENU to do so. The added bonus of the CHECK menu means you can also do this at your mouse cursor very easily.
First thing, we need to create a MANUAL FLIP in the built in Flip menu, and call it "FlipsToggle" no quotes or spaces between words, case should not matter. Set a shortcut, I am going to use "W" for this example. You can
Next go to your shortcut menu and set a shortcut for the CHECK menu as we did for the previous panel. This functions the same albeit with some differences outlined below. I am using "SHIFT + W" for this shortcut as its ergonomic for me.
If you try and use the script it will always check there is a flip named FlipsToggle, if there is not it will prompt you to create it and exit. Please make sure FlipsToggle is a MANUAL flip, it will not function as intended for other flip types.
Note**The rest of the settings in the flip panels, such as limits, return to origin OOP etc. as far as I have tested shouldn't cause any bugs as this script is using the built in FLIPS functionality, and simply changing the CHECKPOINT flags. However, be aware I use the settings in the panel shown and haven't exhaustively tested those other options.
The 3 main buttons function the same as before. If you flag K, B, or E, it is going to change the settings for "FlipsToggle" CHECKPOINTS to Mark1, Mark2, Mark3 as checked respectively. These can be combined and toggled on/off irrespective of each other to skip certain marked frames and not others.
Important to note, anytime you flag one of the Marks, it will automatically turn the IB flag off. If you want to include IBs, you need to turn that one on separately, there is more info below in the IB section regarding how to go through all your instances.
So with all 3 Marks on it will look like this
Now, the major difference between the two panels is how the "I" or Inbetween flag works.
With this panel, flagging the IB ON will change the CHECKPOINTS to INSTANCES (irrespective of if you have any or all marks flagged OFF). This functionality will also allow you to keep your MARK flags set to on, but then while IB is flagged you will go through all instances, and then when you flag off IB's again you will have your Marks still flagged as previously. The other differences between the panels are:
There is already a WRAP option built into the Flips Panel, which is "Loop between limits," but there is no shortcut for turning that on/off that in the custom panel (maybe on my to do list for later).
Also the way the ALL button functions is different. It will still toggle all Flags ON/OFF, but with all flags set to OFF, the Checkpoint will instead change to ALL IMAGES, this is some added functionality so you have an option to go through exposures as well to break them etc. with just this custom panel. One last tiny note: the way FLIPS function is that if you are on a frame not flagged when you start to use the FLIP, it will include that frame as you cycle through your "roll". This is a feature not a bug I believe, and so if for example you have only KEYS on, and start using a FLIP while on a Breakdown, it will include that Breakdown as you "roll." When you stop on a KEY, and start again, that Breakdown that was included before will now not be included in the "roll" because it is not part of the Checkpoints flag.
Hopefully you find these panels useful if you were looking for this kind of function, if it existed as a custom panel elsewhere on the forum and I somehow missed it then please ignore(haha, *cry*)
Please report any bugs you run into and I will do my best to fix them. Also let me know if you think it can be improved or if it is useful to you at all.
Special thanks to Svengali for pointing me in the direction of using tv_writeuserstring and tv_readuserstring for toggleable buttons and encouraging me that once you get around some syntax stuff, George is not too bad.