diff --git a/CHANGELOG.md b/CHANGELOG.md index c520590..89810e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,11 @@ Activate / deactivate layer opaticty according to prefix Activate / deactivate all masks using MA layers --> + +0.9.2 + +- feat: add button to check if and which layers have masks + 0.9.1 - change: stop reporting all use light disable on `check layer` (too many messages) diff --git a/OP_setup_layers.py b/OP_setup_layers.py index 6e2a64c..1922463 100644 --- a/OP_setup_layers.py +++ b/OP_setup_layers.py @@ -8,6 +8,8 @@ from . import fn import math import re +## TODO : export json info to re-setup layers in AE automagically + class GPEXP_OT_layers_state(bpy.types.Operator): bl_idname = "gp.layers_state" bl_label = "Set Layers State" @@ -103,6 +105,7 @@ class GPEXP_OT_layers_state(bpy.types.Operator): # mlinvert = ' <>' if ml.invert else '' # print(f'{ml.info}{mlstate}{mlinvert}') + if l.opacity != 1: # TODO Skip zeroed opacity ? # check if there is an exclusion word @@ -135,6 +138,13 @@ class GPEXP_OT_layers_state(bpy.types.Operator): l.blend_mode = 'REGULAR' used = True + if len(l.frames) == 1 and len(l.frames[0].strokes) == 0 and not l.hide: + # probably used as separator + l.hide = True + mess = f'{l.info} : No frames. Hiding layer' + print(mess) + changes.append(mess) + used = True if used: print() @@ -315,10 +325,65 @@ class GPEXP_OT_auto_number_object(bpy.types.Operator): return {"FINISHED"} + +class GPEXP_OT_check_masks(bpy.types.Operator): + bl_idname = "gp.check_masks" + bl_label = "Check Masks" + bl_description = "Check and report all masked GP layers" + bl_options = {"REGISTER", "UNDO"} + + @classmethod + def poll(cls, context): + return context.object and context.object.type == 'GPENCIL' + + def execute(self, context): + # if self.all_objects: + # pool = [o for o in context.scene.objects if o.type == 'GPENCIL'] + # else: + # pool = [o for o in context.selected_objects if o.type == 'GPENCIL'] + changes = [] + pool = [o for o in context.scene.objects if o.type == 'GPENCIL'] + for o in pool: + for l in o.data.layers: + if l.use_mask_layer: + obj_stat = f'{o.name} >>' + if not obj_stat in changes: + changes.append(obj_stat) + print(obj_stat) + + hide_state = ' (hided)' if l.hide else '' + text = f' {l.info}{hide_state}:' # :masks: + changes.append(text) + print(text) + + has_masks = False + for ml in l.mask_layers: + # 'hide', 'invert', 'name' + h = ' hided' if ml.hide else '' + i = ' (inverted)' if ml.invert else '' + text = f' - {ml.name}{h}{i}' + changes.append(text) + print(text) + has_masks = True + + if not has_masks: + text = 'No masks!' + changes.append(text) + print(text) + changes.append('') + + if changes: + fn.show_message_box(_message=changes, _title="Masks Check Report", _icon='INFO') + else: + fn.show_message_box(_message='No Masks!', _title="Masks Check Report", _icon='INFO') + + return {"FINISHED"} + classes=( GPEXP_OT_layers_state, GPEXP_OT_lower_layers_name, -GPEXP_OT_auto_number_object +GPEXP_OT_auto_number_object, +GPEXP_OT_check_masks, ) def register(): diff --git a/__init__.py b/__init__.py index e24677c..f9a06cd 100644 --- a/__init__.py +++ b/__init__.py @@ -2,7 +2,7 @@ bl_info = { "name": "GP Render", "description": "Organise export of gp layers through compositor output", "author": "Samuel Bernou", - "version": (0, 9, 1), + "version": (0, 9, 2), "blender": (2, 93, 0), "location": "View3D", "warning": "", diff --git a/ui.py b/ui.py index 2c00ee6..d159972 100644 --- a/ui.py +++ b/ui.py @@ -213,6 +213,7 @@ class GPEXP_PT_gp_dopesheet_ui(Panel): row.operator('gp.auto_number_object', icon='X', text='').delete = True col.operator('gp.layers_state', icon='CHECKMARK', text='Check layers') col.operator('gp.lower_layers_name', icon='SYNTAX_OFF', text='Rename Lowercase') + col.operator('gp.check_masks', icon='MOD_MASK', text='Has Masks') # row = layout.row() layout.prop(bpy.context.preferences.edit, 'use_anim_channel_group_colors')