-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhierhin.py
39 lines (32 loc) · 1.09 KB
/
hierhin.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
import bpy
#duration in [frames]
duration = 60
name = bpy.context.active_object.name
x1 = bpy.data.objects[name].location.x
y1 = bpy.data.objects[name].location.y
z1 = bpy.data.objects[name].location.z
keylist =[]
frame = bpy.data.scenes['Scene'].frame_current
for f in bpy.context.object.animation_data.action.fcurves:
for k in f.keyframe_points:
fr = k.co[0]
keylist.append((int(abs(fr))));
frame = bpy.data.scenes['Scene'].frame_current
for x in range(0,len(keylist)):
if keylist[x] > frame:
lastframe = keylist[x-2]
break
try:
print(lastframe)
except:
lastframe = keylist[-1]
bpy.context.scene.frame_set(lastframe)
x = bpy.data.objects[name].location.x
y = bpy.data.objects[name].location.y
z = bpy.data.objects[name].location.z
bpy.context.scene.frame_set(frame - duration)
bpy.data.objects[name].location = (x,y,z)
bpy.ops.anim.keyframe_insert_menu(type='Location')
bpy.context.scene.frame_set(frame)
bpy.data.objects[name].location = (x1,y1,z1)
bpy.ops.anim.keyframe_insert_menu(type='Location')