From d4ea39fb40dd4b32225a688473ef3b241d76cf9c Mon Sep 17 00:00:00 2001 From: Pullusb Date: Mon, 27 Sep 2021 17:35:40 +0200 Subject: [PATCH] fix some batch reproject issues 1.6.8 - fix: reproject GP repeating projection on same frames - fix: batch reproject all frame not poping dialog menu --- CHANGELOG.md | 5 +++++ OP_realign.py | 37 +++++++++++++++++++++++++++++++++++++ __init__.py | 2 +- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 015a532..c89f35c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +1.6.8 + +- fix: reproject GP repeating projection on same frames +- fix: batch reproject all frame not poping dialog menu + 1.6.7 - fix: error with operator `OP_key_duplicate_send` poll flooding console diff --git a/OP_realign.py b/OP_realign.py index 744db0a..460ee18 100644 --- a/OP_realign.py +++ b/OP_realign.py @@ -33,16 +33,51 @@ def batch_reproject(obj, proj_type='VIEW', all_strokes=True, restore_frame=False bpy.ops.object.mode_set(mode='EDIT_GPENCIL') + + frame_list = [f.frame_number for l in obj.data.layers for f in l.frames if len(f.strokes)] + frame_list = list(set(frame_list)) + frame_list.sort() + for fnum in frame_list: + bpy.context.scene.frame_current = fnum + bpy.ops.gpencil.select_all(action='SELECT') + bpy.ops.gpencil.reproject(type=proj_type) # 'INVOKE_DEFAULT' + bpy.ops.gpencil.select_all(action='DESELECT') + + + #print('fnum: ', fnum) + + # bpy.context.scene.frame_set(fnum) + # bpy.context.scene.frame_current = fnum + # bpy.ops.gpencil.select_all(action='SELECT') + # bpy.ops.gpencil.reproject(type=proj_type) # default is VIEW + # # bpy.ops.gpencil.select_all(action='DESELECT') + # bpy.ops.object.mode_set(mode='OBJECT') + # bpy.ops.object.mode_set(mode='EDIT_GPENCIL') + # bpy.context.view_layer.update() + + """ for l in obj.data.layers: for f in l.frames: if not len(f.strokes): continue bpy.context.scene.frame_set(f.frame_number) + # bpy.context.scene.frame_current = f.frame_number + + ## / attempt update trigger for failing reproject surface mode + # bpy.ops.object.mode_set(mode='OBJECT') + # bpy.ops.object.mode_set(mode='EDIT_GPENCIL') + # bpy.context.view_layer.update() + # for a in bpy.context.screen.areas: + # a.tag_redraw() + # dg = bpy.context.evaluated_depsgraph_get() + # obj.evaluated_get(dg) + ## / # switch to edit to reproject through ops bpy.ops.gpencil.select_all(action='SELECT') bpy.ops.gpencil.reproject(type=proj_type) # default is VIEW bpy.ops.gpencil.select_all(action='DESELECT') + """ # restore if all_strokes: @@ -356,10 +391,12 @@ class GPTB_OT_batch_reproject_all_frames(bpy.types.Operator): def reproject_clean_menu(self, context): if context.mode == 'EDIT_GPENCIL': + self.layout.operator_context = 'INVOKE_REGION_WIN' # needed for popup (also works with 'INVOKE_DEFAULT') self.layout.operator('gp.batch_reproject_all_frames', icon='SMALL_TRI_RIGHT_VEC') # KEYTYPE_JITTER_VEC def reproject_context_menu(self, context): if context.mode == 'EDIT_GPENCIL' and context.scene.tool_settings.gpencil_selectmode_edit == 'STROKE': + self.layout.operator_context = 'INVOKE_REGION_WIN' # needed for popup self.layout.operator('gp.batch_reproject_all_frames', icon='SMALL_TRI_RIGHT_VEC') # KEYTYPE_JITTER_VEC classes = ( diff --git a/__init__.py b/__init__.py index b68dc0f..b573155 100755 --- a/__init__.py +++ b/__init__.py @@ -15,7 +15,7 @@ bl_info = { "name": "GP toolbox", "description": "Set of tools for Grease Pencil in animation production", "author": "Samuel Bernou, Christophe Seux", -"version": (1, 6, 7), +"version": (1, 6, 8), "blender": (2, 91, 0), "location": "Sidebar (N menu) > Gpencil > Toolbox / Gpencil properties", "warning": "",