Restore the layer state operator
parent
734714be09
commit
85a42939ca
|
@ -161,6 +161,37 @@ class GPEXP_OT_export_infos_for_compo(bpy.types.Operator):
|
|||
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class GPEXP_OT_restore_layers_state(bpy.types.Operator):
|
||||
bl_idname = "gp.restore_layers_state"
|
||||
bl_label = "Restore Layers State "
|
||||
bl_description = "Restore original state of layers"
|
||||
bl_options = {"REGISTER"} # , "UNDO"
|
||||
|
||||
def execute(self, context):
|
||||
layers_info_path = Path(bpy.data.filepath).parent / 'render' / 'infos.json'
|
||||
if not layers_info_path.exists():
|
||||
self.report({"ERROR"}, 'No Info Found')
|
||||
return {"CANCELLED"}
|
||||
|
||||
layers_info = json.loads(layers_info_path.read_text(encoding='utf-8'))
|
||||
|
||||
pool = [o for o in context.scene.objects if o.type == 'GPENCIL' and fn.is_valid_name(o.name)]
|
||||
for gp in pool:
|
||||
for layer_name, info in layers_info.items():
|
||||
if gp.name == info['object']:
|
||||
if not (layer := gp.data.layers.get(layer_name)):
|
||||
return
|
||||
|
||||
if "opacity" in info:
|
||||
layer.opacity = info['opacity']
|
||||
|
||||
if "blend_mode" in info:
|
||||
layer.blend_mode = info['blend_mode']
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class GPEXP_OT_layers_state(bpy.types.Operator):
|
||||
bl_idname = "gp.layers_state"
|
||||
bl_label = "Set Layers State"
|
||||
|
@ -335,6 +366,7 @@ class GPEXP_OT_layers_state(bpy.types.Operator):
|
|||
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class GPEXP_OT_lower_layers_name(bpy.types.Operator):
|
||||
bl_idname = "gp.lower_layers_name"
|
||||
bl_label = "Normalize Layers Name"
|
||||
|
@ -643,6 +675,7 @@ classes=(
|
|||
GPEXP_OT_auto_number_object,
|
||||
GPEXP_OT_lower_layers_name,
|
||||
GPEXP_OT_export_infos_for_compo,
|
||||
GPEXP_OT_restore_layers_state,
|
||||
GPEXP_OT_layers_state,
|
||||
GPEXP_OT_check_masks,
|
||||
GPEXP_OT_select_layer_in_comp,
|
||||
|
|
6
ui.py
6
ui.py
|
@ -274,7 +274,11 @@ class GPEXP_PT_gp_dopesheet_ui(Panel):
|
|||
row.operator('gp.auto_number_object', icon='X', text='').delete = True
|
||||
col.operator('gp.lower_layers_name', icon='SYNTAX_OFF', text='Rename Lowercase')
|
||||
col.operator('gp.export_infos_for_compo', icon='FILE', text='Export Layers Infos') # Not really need, called in Check layers invoke
|
||||
col.operator('gp.layers_state', icon='CHECKMARK', text='Check layers')
|
||||
|
||||
row = layout.row(align=True)
|
||||
row.operator('gp.layers_state', icon='CHECKMARK', text='Check layers')
|
||||
row.operator('gp.restore_layers_state', icon='DECORATE_OVERRIDE', text='')
|
||||
|
||||
col.operator('gp.check_masks', icon='MOD_MASK', text='Has Masks')
|
||||
|
||||
# row = layout.row()
|
||||
|
|
Loading…
Reference in New Issue