set opacity skip masks

0.3.5:

feat: set full opacity -> skip chosen prefix (MA by default)
main
Pullusb 2021-09-22 18:35:52 +02:00
parent 22d9d53626
commit 37809e15e6
5 changed files with 108 additions and 14 deletions

View File

@ -12,6 +12,10 @@ Activate / deactivate layer opaticty according to prefix
Activate / deactivate all masks using MA layers Activate / deactivate all masks using MA layers
--> -->
0.3.5:
feat: set full opacity -> skip chosen prefix (MA by default)
0.3.4: 0.3.4:
feat: swap cams button, code copied from `bg_plane_manager` feat: swap cams button, code copied from `bg_plane_manager`

80
OP_check_scene.py Normal file
View File

@ -0,0 +1,80 @@
import bpy
from . import fn
## not used, replaced by "setup_layers.py"
class GPEXP_OT_check_render_scene(bpy.types.Operator):
bl_idname = "gp.check_render_scene"
bl_label = "Check render scene"
bl_description = "Auto check render scene"
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 True
def invoke(self, context, event):
return self.execute(context)
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):
gp_objs = [o for o in context.scene.objects if o.type == 'GPENCIL']
# 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
if l.use_lights:
print(f'-> use lights !')
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_render_scene,
)
def register():
for cls in classes:
bpy.utils.register_class(cls)
def unregister():
for cls in reversed(classes):
bpy.utils.unregister_class(cls)

View File

@ -20,7 +20,7 @@ class GPEXP_OT_layers_state(bpy.types.Operator):
# (that way compo artists can re-affect opacity quickly or at least have a reminder) # (that way compo artists can re-affect opacity quickly or at least have a reminder)
all_objects : BoolProperty(name='On All Object', all_objects : BoolProperty(name='On All Object',
default=False, description='On All object, else use selected objects') # , options={'SKIP_SAVE'} default=True, description='On All object, else use selected objects') # , options={'SKIP_SAVE'}
set_full_opacity : BoolProperty(name='Set Full Opacity', set_full_opacity : BoolProperty(name='Set Full Opacity',
default=True, description='Check/Set full opacity') # , options={'SKIP_SAVE'} default=True, description='Check/Set full opacity') # , options={'SKIP_SAVE'}
@ -31,6 +31,9 @@ class GPEXP_OT_layers_state(bpy.types.Operator):
set_blend_mode : BoolProperty(name='Set Regular Blend Mode', set_blend_mode : BoolProperty(name='Set Regular Blend Mode',
default=True, description='Check/Set blend mode to regular') # , options={'SKIP_SAVE'} default=True, description='Check/Set blend mode to regular') # , options={'SKIP_SAVE'}
opacity_exclude_list : StringProperty(name='Skip',
default='MA', description='Skip prefixes from this list when changing opacity\nSeparate multiple value with a comma (ex: MA,IN)') # , options={'SKIP_SAVE'}
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
return context.object and context.object.type == 'GPENCIL' return context.object and context.object.type == 'GPENCIL'
@ -48,7 +51,10 @@ class GPEXP_OT_layers_state(bpy.types.Operator):
layout.prop(self, 'all_objects') layout.prop(self, 'all_objects')
layout.separator() layout.separator()
layout.label(text='Set (or only perform a check):') layout.label(text='Set (or only perform a check):')
layout.prop(self, 'set_full_opacity') row = layout.row()
row.prop(self, 'set_full_opacity')
if self.set_full_opacity:
row.prop(self, 'opacity_exclude_list')
layout.prop(self, 'set_use_lights') layout.prop(self, 'set_use_lights')
layout.prop(self, 'set_blend_mode') layout.prop(self, 'set_blend_mode')
# layout.prop(self, 'clear_unused_view_layers') # layout.prop(self, 'clear_unused_view_layers')
@ -79,14 +85,18 @@ class GPEXP_OT_layers_state(bpy.types.Operator):
# print(f'{ml.info}{mlstate}{mlinvert}') # print(f'{ml.info}{mlstate}{mlinvert}')
if l.opacity != 1: if l.opacity != 1:
# TODO Skip zeroed opacity ?
full_opacity_state = '' if self.set_full_opacity else ' (check only)' # check if there is an exclusion word
mess = f'{l.info} : opacity {l.opacity:.2f} >> 1.0{full_opacity_state}' if any(x.strip() + '_' in l.info for x in self.opacity_exclude_list.strip(',').split(',') if x):
print(mess) print(f'Skipped layer : {l.info}')
changes.append(mess) else:
if self.set_full_opacity: full_opacity_state = '' if self.set_full_opacity else ' (check only)'
l.opacity = 1.0 mess = f'{l.info} : opacity {l.opacity:.2f} >> 1.0{full_opacity_state}'
used = True print(mess)
changes.append(mess)
if self.set_full_opacity:
l.opacity = 1.0
used = True
if l.use_lights: if l.use_lights:

View File

@ -2,7 +2,7 @@ bl_info = {
"name": "GP Render", "name": "GP Render",
"description": "Organise export of gp layers through compositor output", "description": "Organise export of gp layers through compositor output",
"author": "Samuel Bernou", "author": "Samuel Bernou",
"version": (0, 3, 4), "version": (0, 3, 5),
"blender": (2, 93, 0), "blender": (2, 93, 0),
"location": "View3D", "location": "View3D",
"warning": "", "warning": "",

6
ui.py
View File

@ -16,8 +16,6 @@ class GPEXP_PT_gp_node_ui(Panel):
layout.operator('gp.render_scene_switch', icon='SCENE_DATA', text='Switch Scene') layout.operator('gp.render_scene_switch', icon='SCENE_DATA', text='Switch Scene')
scn = context.scene scn = context.scene
if not scn.use_nodes or not scn.node_tree:
return
## Camera swapping ## Camera swapping
row = layout.row() row = layout.row()
@ -27,11 +25,13 @@ class GPEXP_PT_gp_node_ui(Panel):
else: else:
text = f'None' # Cam: text = f'None' # Cam:
layout.separator()
# if cam and cam_name == 'draw_cam': # if cam and cam_name == 'draw_cam':
# cam_name = f'{cam.parent.name} > {cam_name}' # cam_name = f'{cam.parent.name} > {cam_name}'
row.operator("gp.swap_render_cams", text=text, icon='OUTLINER_OB_CAMERA') row.operator("gp.swap_render_cams", text=text, icon='OUTLINER_OB_CAMERA')
if not scn.use_nodes or not scn.node_tree:
return
layout.separator()
# TODO : add advanced bool checkbox to hide some options from the user # TODO : add advanced bool checkbox to hide some options from the user
col = layout.column(align=True) col = layout.column(align=True)