forked from katiemorrisfx/KMFX-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkmfx_timeOffset.py
65 lines (43 loc) · 1.63 KB
/
kmfx_timeOffset.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
import fx
from fx import *
from tools.objectIterator import getObjects
class KMFXtimeOffset(Action):
"""Offsets keyframes on selected nodes"""
def __init__(self,):
Action.__init__(self, "KMFX|Node Time Offset")
def available(self):
assert fx.selection() != [], "Select some nodes"
def execute(self):
if fx.selection() == []:
displayError("KMFXNode Time Offset: Select some nodes", title="Error")
return
num = { "id" : "num", "label" : "Frames to offset", "value" : 0 }
direction = { "id" : "list", "label" : "Direction", "value" : "Head", "items" : [ "Head", "Tail"] }
fields = [ num, direction ]
result = getInput(title="Offset Node Keyframes", fields=fields)
if result != None:
fx.beginUndo("KMFX Node time offset")
offset = result['num'] *-1 if result["list"] == "Head" else result['num']
nodes = fx.selection()
for node in nodes:
if node.isType("PaintNode"):
pass ## cant change paint nodes at this time
elif node.type in ["RotoNode","MorphNode"]:
child = node.children
objects = getObjects(child)
selectedlist = [] ## selection is just to refresh timeline
for o in objects:
if o.selected == True:
selectedlist.append(o)
for p in o.properties:
if o.property(p).constant != True:
o.property(p).moveKeys(offset)
### this is for all nodes properties
for p in node.properties:
if node.property(p).constant != True:
node.property(p).moveKeys(offset)
x = fx.selection()
fx.select([])
fx.select(x)
fx.endUndo()
addAction(KMFXtimeOffset())