forked from Phantom-Studio/natron-plugins
-
Notifications
You must be signed in to change notification settings - Fork 67
/
TimeLoop.py
135 lines (107 loc) · 3.99 KB
/
TimeLoop.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# -*- coding: utf-8 -*-
# DO NOT EDIT THIS FILE
# This file was automatically generated by Natron PyPlug exporter version 10.
# Hand-written code should be added in a separate file named TimeLoopExt.py
# See http://natron.readthedocs.org/en/master/groups.html#adding-hand-written-code-callbacks-etc
# Note that Viewers are never exported
import NatronEngine
import sys
# Try to import the extensions file where callbacks and hand-written code should be located.
try:
from TimeLoopExt import *
except ImportError:
pass
def getPluginID():
return "natron.community.plugins.TimeLoop"
def getLabel():
return "TimeLoop"
def getVersion():
return 1
def getIconPath():
return "TimeLoop.png"
def getGrouping():
return "Community/Time"
def getPluginDescription():
return "This Pyplug create loops from the input clip, set the start value for the first frame of the loop, then the loop duration (length)"
def createInstance(app,group):
# Create all nodes in the group
# Create the parameters of the group node the same way we did for all internal nodes
lastNode = group
# Create the user parameters
lastNode.Controls = lastNode.createPageParam("Controls", "Controls")
param = lastNode.createIntParam("start", "start")
param.setDisplayMinimum(0, 0)
param.setDisplayMaximum(1000, 0)
param.setDefaultValue(0, 0)
param.restoreDefaultValue(0)
# Add the param to the page
lastNode.Controls.addParam(param)
# Set param properties
param.setHelp("the starting frame of the loop")
param.setAddNewLine(True)
param.setAnimationEnabled(True)
lastNode.start = param
del param
param = lastNode.createIntParam("length", "length")
param.setDisplayMinimum(0, 0)
param.setDisplayMaximum(100, 0)
param.setDefaultValue(0, 0)
param.restoreDefaultValue(0)
# Add the param to the page
lastNode.Controls.addParam(param)
# Set param properties
param.setHelp("the length of the loop in frames")
param.setAddNewLine(True)
param.setAnimationEnabled(True)
param.setValue(20, 0)
lastNode.length = param
del param
# Refresh the GUI with the newly created parameters
lastNode.setPagesOrder(['Controls', 'Node'])
lastNode.refreshUserParamsGUI()
del lastNode
# Start of node "TimeOffset1"
lastNode = app.createNode("net.sf.openfx.timeOffset", 1, group)
lastNode.setScriptName("TimeOffset1")
lastNode.setLabel("TimeOffset1")
lastNode.setPosition(811, 219)
lastNode.setSize(104, 43)
lastNode.setColor(0.7, 0.65, 0.35)
groupTimeOffset1 = lastNode
param = lastNode.getParam("timeOffset")
if param is not None:
param.setValue(148, 0)
del param
del lastNode
# End of node "TimeOffset1"
# Start of node "input"
lastNode = app.createNode("fr.inria.built-in.Input", 1, group)
lastNode.setScriptName("input")
lastNode.setLabel("input")
lastNode.setPosition(808, 84)
lastNode.setSize(104, 43)
lastNode.setColor(0.3, 0.5, 0.2)
groupinput = lastNode
del lastNode
# End of node "input"
# Start of node "Output1"
lastNode = app.createNode("fr.inria.built-in.Output", 1, group)
lastNode.setLabel("Output1")
lastNode.setPosition(811, 426)
lastNode.setSize(104, 30)
lastNode.setColor(0.7, 0.7, 0.7)
groupOutput1 = lastNode
del lastNode
# End of node "Output1"
# Now that all nodes are created we can connect them together, restore expressions
groupTimeOffset1.connectInput(0, groupinput)
groupOutput1.connectInput(0, groupTimeOffset1)
param = groupTimeOffset1.getParam("timeOffset")
param.setExpression("(range(0,frame,(thisGroup.length.get()+1)).pop(-1))-(thisGroup.start.get()-1)", False, 0)
del param
try:
extModule = sys.modules["TimeLoopExt"]
except KeyError:
extModule = None
if extModule is not None and hasattr(extModule ,"createInstanceExt") and hasattr(extModule.createInstanceExt,"__call__"):
extModule.createInstanceExt(app,group)