2021-09-16 18:37:34 +02:00
|
|
|
import bpy
|
|
|
|
from . import fn
|
|
|
|
|
2021-09-17 16:31:26 +02:00
|
|
|
## not used, replaced by "setup_layers.py"
|
2021-09-16 18:37:34 +02:00
|
|
|
class GPEXP_OT_check_layers_state(bpy.types.Operator):
|
|
|
|
bl_idname = "gp.check_layers_state"
|
|
|
|
bl_label = "Check Layers State"
|
|
|
|
bl_description = "Display state of layer that migh need adjustement"
|
|
|
|
bl_options = {"REGISTER"} # , "UNDO"
|
|
|
|
|
|
|
|
# clear_unused_view_layers : bpy.props.BoolProperty(name="Clear unused view layers",
|
|
|
|
# description="Delete view layer that aren't used in the nodetree anymore",
|
|
|
|
# default=True)
|
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def poll(cls, context):
|
|
|
|
return context.object and context.object.type == 'GPENCIL'
|
|
|
|
|
|
|
|
def invoke(self, context, event):
|
|
|
|
self.ctrl=event.ctrl
|
|
|
|
self.alt=event.alt
|
2021-09-17 16:31:26 +02:00
|
|
|
return self.execute(context)
|
2021-09-16 18:37:34 +02:00
|
|
|
return context.window_manager.invoke_props_dialog(self)
|
|
|
|
|
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
# layout.prop(self, 'clear_unused_view_layers')
|
|
|
|
|
|
|
|
def execute(self, context):
|
|
|
|
if self.alt:
|
|
|
|
pool = [o for o in context.selected_objects if o.type == 'GPENCIL']
|
|
|
|
else:
|
|
|
|
pool = [context.object]
|
|
|
|
|
|
|
|
# TODO create a list to disaply everything in a message box ?
|
|
|
|
|
|
|
|
for ob in pool:
|
|
|
|
layers = ob.data.layers
|
|
|
|
for l in layers:
|
|
|
|
used = False
|
|
|
|
if l.mask_layers:
|
|
|
|
print(f'-> masks')
|
|
|
|
state = '' if l.use_mask_layer else ' (disabled)'
|
|
|
|
print(f'{ob.name} > {l.info}{state}:')
|
|
|
|
used = True
|
|
|
|
for ml in l.mask_layers:
|
|
|
|
mlstate = ' (disabled)' if ml.hide else ''
|
|
|
|
mlinvert = ' <>' if ml.invert else ''
|
|
|
|
print(f' - {ml.info}{mlstate}{mlinvert}')
|
|
|
|
|
|
|
|
if l.opacity != 1:
|
|
|
|
print(f'-> opacity {l.opacity}')
|
|
|
|
used = True
|
|
|
|
|
2021-09-17 16:31:26 +02:00
|
|
|
if l.use_lights:
|
|
|
|
print(f'-> use lights !')
|
2021-09-16 18:37:34 +02:00
|
|
|
used = True
|
|
|
|
if l.blend_mode != 'REGULAR':
|
|
|
|
print(f'-> blend mode "{l.blend_mode}" !')
|
|
|
|
used = True
|
|
|
|
|
|
|
|
if used:
|
|
|
|
print()
|
|
|
|
|
|
|
|
# render = bpy.data.scenes.get('Render')
|
|
|
|
# if not render:
|
|
|
|
# print('SKIP, no Render scene')
|
|
|
|
# return {"CANCELLED"}
|
|
|
|
|
|
|
|
return {"FINISHED"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes=(
|
|
|
|
GPEXP_OT_check_layers_state,
|
|
|
|
)
|
|
|
|
|
|
|
|
def register():
|
|
|
|
for cls in classes:
|
|
|
|
bpy.utils.register_class(cls)
|
|
|
|
|
|
|
|
def unregister():
|
|
|
|
for cls in reversed(classes):
|
|
|
|
bpy.utils.unregister_class(cls)
|