fix automerge - force set color
1.1.4 - Changed: force set color by prefix if autobuild option swiched on - fixed: problem with auto merge adjacent layersmain
parent
b1cc4fa5d7
commit
0eea0661bc
|
@ -14,6 +14,11 @@ Activate / deactivate layer opacity according to prefix
|
||||||
Activate / deactivate all masks using MA layers
|
Activate / deactivate all masks using MA layers
|
||||||
-->
|
-->
|
||||||
|
|
||||||
|
1.1.4
|
||||||
|
|
||||||
|
- changed: force set color by prefix if autobuild option swiched on
|
||||||
|
- fixed: problem with auto merge adjacent layers
|
||||||
|
|
||||||
1.1.3
|
1.1.3
|
||||||
|
|
||||||
- added: clean material stack in auto-build
|
- added: clean material stack in auto-build
|
||||||
|
|
|
@ -58,7 +58,7 @@ class GPEXP_OT_render_auto_build(bpy.types.Operator):
|
||||||
timer : bpy.props.FloatProperty(default=0.1, options={'SKIP_SAVE'})
|
timer : bpy.props.FloatProperty(default=0.1, options={'SKIP_SAVE'})
|
||||||
|
|
||||||
excluded_prefix : bpy.props.StringProperty(
|
excluded_prefix : bpy.props.StringProperty(
|
||||||
name='Excluded Layer By Prefix', default='GP, RG, PO',
|
name='Excluded Layer By Prefix', default='GP, RG, PO, MA',
|
||||||
description='Exclude layer to send to render by prefix (comma separated list)')
|
description='Exclude layer to send to render by prefix (comma separated list)')
|
||||||
|
|
||||||
clean_name_and_visibility : bpy.props.BoolProperty(name='Clean Name And Visibility', default=True,
|
clean_name_and_visibility : bpy.props.BoolProperty(name='Clean Name And Visibility', default=True,
|
||||||
|
@ -101,11 +101,12 @@ class GPEXP_OT_render_auto_build(bpy.types.Operator):
|
||||||
layout = self.layout
|
layout = self.layout
|
||||||
col = layout.column()
|
col = layout.column()
|
||||||
col.prop(self, 'clean_name_and_visibility')
|
col.prop(self, 'clean_name_and_visibility')
|
||||||
col.prop(self, 'clean_material_duplication')
|
|
||||||
row = col.row()
|
row = col.row()
|
||||||
row.prop(self, 'prefix_filter')
|
row.prop(self, 'prefix_filter')
|
||||||
row.active = self.clean_name_and_visibility
|
row.active = self.clean_name_and_visibility
|
||||||
|
|
||||||
|
col.prop(self, 'clean_material_duplication')
|
||||||
|
|
||||||
col.prop(self, 'set_layers_colors')
|
col.prop(self, 'set_layers_colors')
|
||||||
col.prop(self, 'trigger_rename_lowercase')
|
col.prop(self, 'trigger_rename_lowercase')
|
||||||
col.prop(self, 'trigger_renumber_by_distance')
|
col.prop(self, 'trigger_renumber_by_distance')
|
||||||
|
@ -127,6 +128,7 @@ class GPEXP_OT_render_auto_build(bpy.types.Operator):
|
||||||
# TODO : add to preferences / environment var
|
# TODO : add to preferences / environment var
|
||||||
# prefix_to_render = ['CO', 'CU', 'FX', 'TO', 'MA']
|
# prefix_to_render = ['CO', 'CU', 'FX', 'TO', 'MA']
|
||||||
prefix_to_render = [p.strip() for p in self.prefix_filter.split(',')]
|
prefix_to_render = [p.strip() for p in self.prefix_filter.split(',')]
|
||||||
|
print('prefix_to_render: ', prefix_to_render)
|
||||||
|
|
||||||
render_scn = bpy.data.scenes.get('Render')
|
render_scn = bpy.data.scenes.get('Render')
|
||||||
if render_scn:
|
if render_scn:
|
||||||
|
@ -134,6 +136,7 @@ class GPEXP_OT_render_auto_build(bpy.types.Operator):
|
||||||
return {'CANCELLED'}
|
return {'CANCELLED'}
|
||||||
|
|
||||||
all_gp_objects = [o for o in context.scene.objects if o.type == 'GPENCIL']
|
all_gp_objects = [o for o in context.scene.objects if o.type == 'GPENCIL']
|
||||||
|
|
||||||
## clean name and visibility
|
## clean name and visibility
|
||||||
if self.clean_name_and_visibility:
|
if self.clean_name_and_visibility:
|
||||||
for o in all_gp_objects:
|
for o in all_gp_objects:
|
||||||
|
@ -145,9 +148,9 @@ class GPEXP_OT_render_auto_build(bpy.types.Operator):
|
||||||
if re.match(r'^[A-Z]{2}_$', l.info):
|
if re.match(r'^[A-Z]{2}_$', l.info):
|
||||||
l.info = l.info + o.name.lower()
|
l.info = l.info + o.name.lower()
|
||||||
|
|
||||||
## Make used prefix visible ?
|
## Make used prefix visible ?? (maybe some layer were intentionally hidden...)
|
||||||
if (res := re.search(r'^([A-Z]{2})_', l.info)):
|
if (res := re.search(r'^([A-Z]{2})_', l.info)):
|
||||||
if res.group(1) in prefix_to_render and l.hide == True:
|
if res.group(1) in prefix_to_render and l.hide == True and not 'invisible' in l.info:
|
||||||
print(f'{o.name} -> {l.info} : Switch visibility On')
|
print(f'{o.name} -> {l.info} : Switch visibility On')
|
||||||
l.hide = False
|
l.hide = False
|
||||||
|
|
||||||
|
@ -167,8 +170,9 @@ class GPEXP_OT_render_auto_build(bpy.types.Operator):
|
||||||
|
|
||||||
## Set layers colors (skip if colors were already set ?)
|
## Set layers colors (skip if colors were already set ?)
|
||||||
if self.set_layers_colors:
|
if self.set_layers_colors:
|
||||||
# Option: Maybe find a way to create a color from prefix hash ? (always give unique color with same prefix on other project!)
|
## Option: Maybe find a way to create a color from prefix hash ?
|
||||||
fn.set_layer_colors(skip_if_colored=True)
|
## (always give unique color with same prefix whatever the project!)
|
||||||
|
fn.set_layer_colors(skip_if_colored=False)
|
||||||
|
|
||||||
## Trigger rename lowercase
|
## Trigger rename lowercase
|
||||||
if self.trigger_rename_lowercase:
|
if self.trigger_rename_lowercase:
|
||||||
|
|
|
@ -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": (1, 1, 3),
|
"version": (1, 1, 4),
|
||||||
"blender": (2, 93, 0),
|
"blender": (2, 93, 0),
|
||||||
"location": "View3D",
|
"location": "View3D",
|
||||||
"warning": "",
|
"warning": "",
|
||||||
|
|
8
fn.py
8
fn.py
|
@ -437,12 +437,20 @@ def group_adjacent_layer_prefix_rlayer(ob, excluded_prefix=[], first_name=True):
|
||||||
]
|
]
|
||||||
|
|
||||||
for prefix, layer_grp in adjacent_prefix_groups:
|
for prefix, layer_grp in adjacent_prefix_groups:
|
||||||
|
## Remove layer that are in excluded viewlayer
|
||||||
|
## Else None/exclusion vl can expand rest of the adjacent layers
|
||||||
|
for l in reversed(layer_grp):
|
||||||
|
if not l.viewlayer_render or l.viewlayer_render == 'exclude':
|
||||||
|
print(f'prefix "{prefix}": remove "{l.info}" from grouping adjacent layers')
|
||||||
|
layer_grp.remove(l) # remove traget the layer directly
|
||||||
|
|
||||||
if len(layer_grp) < 2:
|
if len(layer_grp) < 2:
|
||||||
continue
|
continue
|
||||||
if not prefix or prefix in excluded_prefix:
|
if not prefix or prefix in excluded_prefix:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
ref = layer_grp[0] if first_name else layer_grp[-1]
|
ref = layer_grp[0] if first_name else layer_grp[-1]
|
||||||
|
|
||||||
merge_gplayer_viewlayers(ob, act=ref, layers=layer_grp)
|
merge_gplayer_viewlayers(ob, act=ref, layers=layer_grp)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -380,11 +380,14 @@ def export_gp_objects(oblist, exclude_list=[], scene=None):
|
||||||
if isinstance(exclude_list, str):
|
if isinstance(exclude_list, str):
|
||||||
exclude_list = [p.strip() for p in exclude_list.split(',')]
|
exclude_list = [p.strip() for p in exclude_list.split(',')]
|
||||||
|
|
||||||
|
# print('exclude_list: ', exclude_list)
|
||||||
|
|
||||||
for ob in oblist:
|
for ob in oblist:
|
||||||
for l in ob.data.layers:
|
for l in ob.data.layers:
|
||||||
# if l.hide:
|
# if l.hide:
|
||||||
# continue
|
# continue
|
||||||
if l.hide or any(x + '_' in l.info for x in exclude_list): # exclude hided ?
|
if l.hide or any(x + '_' in l.info for x in exclude_list): # exclude hided ?
|
||||||
|
print(f'Exclude export: {ob.name} : {l.info}')
|
||||||
l.viewlayer_render = fn.get_view_layer('exclude', scene=scene).name # assign "exclude"
|
l.viewlayer_render = fn.get_view_layer('exclude', scene=scene).name # assign "exclude"
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue