Clean GP material stack
1.1.3 - added: clean material stack in auto-build
This commit is contained in:
+14
-4
@@ -64,8 +64,11 @@ class GPEXP_OT_render_auto_build(bpy.types.Operator):
|
||||
clean_name_and_visibility : bpy.props.BoolProperty(name='Clean Name And Visibility', default=True,
|
||||
description='Add object name to layer name when there is only prefix (ex: "CO_")\
|
||||
\nEnable visibility for layer with prefix included in Prefix Filter')
|
||||
|
||||
clean_material_duplication : bpy.props.BoolProperty(name='Clean Material Duplication', default=True,
|
||||
description='Clean material stack. i.e: Replace "mat.001" in material stack if "mat" exists and has same color')
|
||||
|
||||
prefix_filter : bpy.props.StringProperty(name='Prefix Filter', default='CO, CU, FX, TO, MA',
|
||||
prefix_filter : bpy.props.StringProperty(name='Prefix Filter', default='CO, CU, FX, TO', # , MA # exclude MA if mask are applied
|
||||
description='Comma separated prefix to render. Set the other prefix and non-prefixed layer to exluded viewlayer')
|
||||
|
||||
set_layers_colors : bpy.props.BoolProperty(name='Set Layers Colors', default=True,
|
||||
@@ -98,6 +101,7 @@ class GPEXP_OT_render_auto_build(bpy.types.Operator):
|
||||
layout = self.layout
|
||||
col = layout.column()
|
||||
col.prop(self, 'clean_name_and_visibility')
|
||||
col.prop(self, 'clean_material_duplication')
|
||||
row = col.row()
|
||||
row.prop(self, 'prefix_filter')
|
||||
row.active = self.clean_name_and_visibility
|
||||
@@ -129,9 +133,10 @@ class GPEXP_OT_render_auto_build(bpy.types.Operator):
|
||||
self.report({'ERROR'}, 'A "Render" scene already exists')
|
||||
return {'CANCELLED'}
|
||||
|
||||
all_gp_objects = [o for o in context.scene.objects if o.type == 'GPENCIL']
|
||||
## clean name and visibility
|
||||
if self.clean_name_and_visibility:
|
||||
for o in [o for o in context.scene.objects if o.type == 'GPENCIL']:
|
||||
for o in all_gp_objects:
|
||||
if o.hide_render:
|
||||
print(f'skip: {o.name} hide render')
|
||||
continue
|
||||
@@ -145,8 +150,13 @@ class GPEXP_OT_render_auto_build(bpy.types.Operator):
|
||||
if res.group(1) in prefix_to_render and l.hide == True:
|
||||
print(f'{o.name} -> {l.info} : Switch visibility On')
|
||||
l.hide = False
|
||||
|
||||
ob_list = [o for o in context.scene.objects if o.type == 'GPENCIL' and not o.hide_get() and fn.is_valid_name(o.name)]
|
||||
|
||||
if self.clean_material_duplication:
|
||||
print('Clean material duplicates')
|
||||
for ob in all_gp_objects:
|
||||
fn.clean_mats_duplication(ob)
|
||||
|
||||
ob_list = [o for o in all_gp_objects if not o.hide_get() and fn.is_valid_name(o.name)]
|
||||
if not ob_list:
|
||||
self.report({'ERROR'}, 'No GP object to render found')
|
||||
return {'CANCELLED'}
|
||||
|
||||
Reference in New Issue
Block a user