-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathreanimate.py
More file actions
executable file
·43 lines (36 loc) · 1.28 KB
/
reanimate.py
File metadata and controls
executable file
·43 lines (36 loc) · 1.28 KB
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
import bpy
from .utils import draw_glyph
class GREASEPENCIL_OT_reanimate(bpy.types.Operator):
bl_label = "Reanimate"
bl_idname = "grease_writer.reanimate"
bl_description = "(Re)animates the strokes for a grease-pencil object"
bl_options = {"REGISTER", "UNDO"}
@classmethod
def poll(self, context):
obj = bpy.context.view_layer.objects.active
gpencil = obj.data
if (len(gpencil.layers) > 0 and
len(gpencil.layers[0].frames) > 0):
return True
else:
return False
def execute(self, context):
obj = bpy.context.view_layer.objects.active
gpencil = obj.data
thicknesses = []
layer = gpencil.layers[0]
frame = layer.frames[-1]
glyph_strokes = []
for stroke in frame.strokes:
verts = []
thicknesses.append(stroke.line_width)
for point in stroke.points:
verts.append([point.co.x, point.co.y, point.co.z])
glyph_strokes.append(verts)
layer.clear()
try:
bpy.context.scene.frame_current = gpencil.layers[0].frames[0].frame_number + 1
except IndexError:
pass
draw_glyph(obj, glyph_strokes, thicknesses=thicknesses)
return {"FINISHED"}