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
gpv2
Pullusb 2021-09-27 17:35:40 +02:00
parent ea772b297a
commit d4ea39fb40
3 changed files with 43 additions and 1 deletions

View File

@ -1,5 +1,10 @@
# Changelog # Changelog
1.6.8
- fix: reproject GP repeating projection on same frames
- fix: batch reproject all frame not poping dialog menu
1.6.7 1.6.7
- fix: error with operator `OP_key_duplicate_send` poll flooding console - fix: error with operator `OP_key_duplicate_send` poll flooding console

View File

@ -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') 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 l in obj.data.layers:
for f in l.frames: for f in l.frames:
if not len(f.strokes): if not len(f.strokes):
continue continue
bpy.context.scene.frame_set(f.frame_number) 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 # switch to edit to reproject through ops
bpy.ops.gpencil.select_all(action='SELECT') bpy.ops.gpencil.select_all(action='SELECT')
bpy.ops.gpencil.reproject(type=proj_type) # default is VIEW bpy.ops.gpencil.reproject(type=proj_type) # default is VIEW
bpy.ops.gpencil.select_all(action='DESELECT') bpy.ops.gpencil.select_all(action='DESELECT')
"""
# restore # restore
if all_strokes: if all_strokes:
@ -356,10 +391,12 @@ class GPTB_OT_batch_reproject_all_frames(bpy.types.Operator):
def reproject_clean_menu(self, context): def reproject_clean_menu(self, context):
if context.mode == 'EDIT_GPENCIL': 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 self.layout.operator('gp.batch_reproject_all_frames', icon='SMALL_TRI_RIGHT_VEC') # KEYTYPE_JITTER_VEC
def reproject_context_menu(self, context): def reproject_context_menu(self, context):
if context.mode == 'EDIT_GPENCIL' and context.scene.tool_settings.gpencil_selectmode_edit == 'STROKE': 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 self.layout.operator('gp.batch_reproject_all_frames', icon='SMALL_TRI_RIGHT_VEC') # KEYTYPE_JITTER_VEC
classes = ( classes = (

View File

@ -15,7 +15,7 @@ bl_info = {
"name": "GP toolbox", "name": "GP toolbox",
"description": "Set of tools for Grease Pencil in animation production", "description": "Set of tools for Grease Pencil in animation production",
"author": "Samuel Bernou, Christophe Seux", "author": "Samuel Bernou, Christophe Seux",
"version": (1, 6, 7), "version": (1, 6, 8),
"blender": (2, 91, 0), "blender": (2, 91, 0),
"location": "Sidebar (N menu) > Gpencil > Toolbox / Gpencil properties", "location": "Sidebar (N menu) > Gpencil > Toolbox / Gpencil properties",
"warning": "", "warning": "",