Set layer length for loops automatically

Share your custom panels, brushes, papers... (you need to be registered to read posts in this section)
Post Reply
User avatar
deruji
Posts: 48
Joined: 28 Jul 2018, 22:53
Location: Germany
Contact:

Set layer length for loops automatically

Post 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"]
The traditional 2D animator working with local and international artists.
You can help support my work to make traditional animation, here.
User avatar
NathanOtano
Posts: 1181
Joined: 01 Apr 2014, 07:07
Location: Biarritz, France
Contact:

Re: Set layer length for loops automatically

Post by NathanOtano »

Thanks :)
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
condepablo
Posts: 60
Joined: 21 Nov 2019, 01:32

Re: Set layer length for loops automatically

Post by condepablo »

excuse me, how do you use it? i have no idea of scripting
User avatar
deruji
Posts: 48
Joined: 28 Jul 2018, 22:53
Location: Germany
Contact:

Re: Set layer length for loops automatically

Post 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.
The traditional 2D animator working with local and international artists.
You can help support my work to make traditional animation, here.
User avatar
D.T. Nethery
Posts: 4110
Joined: 27 Sep 2006, 19:19

Re: Set layer length for loops automatically

Post 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 5957 times
Set Embedded George Script.png
Set Embedded George Script.png (31.81 KiB) Viewed 5957 times
Paste the George Script.png
Paste the George Script.png (83.62 KiB) Viewed 5957 times


The attached TVPX file has the script already embedded.
Attachments
Set Number of Loops.tvpx
(56 KiB) Downloaded 292 times

Animator, TVPaint Beta-Tester, Animation Educator and Consultant.
MacOS 12.7.1 Monterey , Mac Mini (2018) , 3.2 GHz 6-Core Intel Core i7,
16 GB RAM , TVPaint PRO 11.7.1 - 64bit , Wacom Cintiq 21UX 2nd Gen.
,Wacom Intuos Pro 5 , Wacom driver version 6.3.39-1
Post Reply