From 86fb848e4a6a9f84731dd4353bb944934854230b Mon Sep 17 00:00:00 2001 From: pullusb Date: Wed, 27 Nov 2024 18:01:18 +0100 Subject: [PATCH] fix batch reproject frame issue --- OP_realign.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/OP_realign.py b/OP_realign.py index 73ecadf..026b5fd 100644 --- a/OP_realign.py +++ b/OP_realign.py @@ -69,19 +69,22 @@ def batch_reproject(obj, proj_type='VIEW', all_strokes=True, restore_frame=False # matrix = np.array(obj.matrix_world, dtype='float64') # matrix_inv = np.array(obj.matrix_world.inverted(), dtype='float64') #mat = src.matrix_world - for l in obj.data.layers: + for layer in obj.data.layers: if not all_strokes: - if not l.select: + if not layer.select: continue - if l.hide or l.lock: + if layer.hide or layer.lock: continue - f = next((f for f in l.frames if f.frame_number == i), None) - if f is None: - # FIXME: some strokes are ingored - # print(f'skip {l.name}, no frame at {i}') + + frame = next((f for f in layer.frames if f.frame_number == i), None) + if frame is None: + print(layer.name, 'Not found') + # FIXME: some strokes are ignored + # print(frame'skip {layer.name}, no frame at {i}') continue - for s in f.drawing.strokes: - # print(l.name, s.material_index) + + for s in frame.drawing.strokes: + # print(layer.name, s.material_index) ## Batch matrix apply (Here is slower than list comprehension). # nb_points = len(s.points) @@ -96,8 +99,8 @@ def batch_reproject(obj, proj_type='VIEW', all_strokes=True, restore_frame=False # Basic method (Slower than foreach_set and compatible with GPv3) ## TODO: use low level api with curve offsets... - for i, p in enumerate(s.points): - p.position = matrix_inv @ new_world_co_3d[i] + for pt_index, point in enumerate(s.points): + point.position = matrix_inv @ new_world_co_3d[pt_index] ## GPv2: ravel and use foreach_set ## Ravel new coordinate on the fly @@ -416,9 +419,6 @@ class GPTB_OT_batch_reproject_all_frames(bpy.types.Operator): box = layout.box() axis = context.scene.tool_settings.gpencil_sculpt.lock_axis box.label(text=orient[axis][0], icon=orient[axis][1]) - - - def execute(self, context): t0 = time()