Hello, I’m trying to edit GPencilPoints
, however they aren’t updating unless I delete a keyframe or copy and paste the keyframes in a new GPencil
object. This occurs after creating new keyframes with existing strokes (e.g. in Edit Mode). I have tried updating everything as I know to do it and I think it may be a bug. Can anyone please help if you know any better?
active_layer = context.active_gpencil_layer
frames = active_layer.frames
start_frame = frames[0]
for frame in range(start_frame.frame_number+1, context.scene.frame_end+1):
new_frame = frames.copy(start_frame)
for i,start_stroke in enumerate(start_frame.strokes):
new_stroke = new_frame.strokes[i]
for p,start_pt in enumerate(start_stroke.points):
new_pt = new_stroke.points[p]
new_pt.co[0] = start_pt.co[0]+(frame*0.5)
new_frame.frame_number = frame
gpencil = context.object
gpencil.data.layers.update()
for l in gpencil.data.layers:
l.frames.update()
for f in l.frames:
f.strokes.update()
for s in f.strokes:
s.points.update()
gpencil.data.update_tag()
context.view_layer.depsgraph.update()
context.view_layer.update()
bpy.ops.gpencil.recalc_geometry()