Page 1 of 1

Set layer length for loops automatically

Posted: 20 Jan 2023, 08:20
by deruji
I recently updated this script and wanted to share it here. This will set markin and markout for you depending on how many loops you want and sets the layers to loop. It should take into account if the animation does not start on the first frame of your selected layer. You just need to manually export the clip. You can add it to your panel as a button and use when needed. Let me know if you have any suggestions for improving the code.

Code: Select all

// Script to set layer length to repeat for a set number of loops

tv_LayerInfo [tv_layercurrentid]
PARSE Result layerDisplay layerPosition layerOpacity layerName layerType layerFirstFrame layerLastFrame layerPrelighttable layerPostlighttable selectable editable stencil

Anim_Offset = layerFirstFrame - 1
Anim_Length = layerLastFrame - Anim_Offset

Loop_Count = 1
Loop_Min = 1
Loop_Max = 10
Loop_Title = "How many Loops?"

tv_reqnum Loop_Count Loop_Min Loop_Max Loop_Title
PARSE Result Loop_Count Loop_Min Loop_Max Loop_Title

IF ( CMP( Result, "cancel") == 1 )
    exit
END

Loop_Markout = (Anim_Length * Loop_Count) + Anim_Offset

tv_markin [0] ["set"]
tv_markout [Loop_Markout] ["set"]
tv_layerpostbehavior [tv_layercurrentid] ["repeat"]

Re: Set layer length for loops automatically

Posted: 20 Jan 2023, 20:01
by NathanOtano
Thanks :)

Re: Set layer length for loops automatically

Posted: 27 Feb 2023, 23:11
by condepablo
excuse me, how do you use it? i have no idea of scripting

Re: Set layer length for loops automatically

Posted: 12 Mar 2023, 19:30
by deruji
condepablo wrote: 27 Feb 2023, 23:11 excuse me, how do you use it? i have no idea of scripting
You can add an action to your panels, then set the action to use George script and paste the above script into it.
When you press the button the script will be executed.

Re: Set layer length for loops automatically

Posted: 12 Mar 2023, 19:54
by D.T. Nethery
deruji wrote: 12 Mar 2023, 19:30
condepablo wrote: 27 Feb 2023, 23:11 excuse me, how do you use it? i have no idea of scripting
You can add an action to your panels, then set the action to use George script and paste the above script into it.
When you press the button the script will be executed.

To add to this: First make a new Custom Panel , from menu Custom Panels > New Custom Panel.

OR add an action to a current custom panl. Then right-click on it to Edit. From the menu select Embedded George Script.
Copy and Paste the George Script into the window that opens up. Click OK.

So now when you press the button in your Custom Panel the embedded script will run.
This one will ask you how many times you want the selected layer to loop. It will automatically set the Mark-In and Mark-Out based on how
many times the animation should loop.


Edit the Custom Panel.png
Edit the Custom Panel.png (12.02 KiB) Viewed 10058 times
Set Embedded George Script.png
Set Embedded George Script.png (31.81 KiB) Viewed 10058 times
Paste the George Script.png
Paste the George Script.png (83.62 KiB) Viewed 10058 times


The attached TVPX file has the script already embedded.