diff --git a/OP_merge_layers.py b/OP_merge_layers.py index fb9f5a4..f297a2f 100644 --- a/OP_merge_layers.py +++ b/OP_merge_layers.py @@ -167,7 +167,7 @@ class GPEXP_OT_merge_selected_dopesheet_layers(bpy.types.Operator): rlayers.append(rl) color = None - if not any(isclose(i, 0.2, abs_tol=0.0001) for i in act.channel_color): # and bpy.context.preferences.edit.use_anim_channel_group_colors + if fn.has_channel_color(act): # and bpy.context.preferences.edit.use_anim_channel_group_colors color = act.channel_color merge_layers(rlayers, disconnect=self.disconnect, color=color) diff --git a/fn.py b/fn.py index aea40c9..b6b300a 100644 --- a/fn.py +++ b/fn.py @@ -2,7 +2,7 @@ import bpy import re from mathutils import Vector from pathlib import Path - +from math import isclose from collections import defaultdict @@ -21,8 +21,8 @@ def create_node(type, tree=None, **kargs): def new_aa_node(tree): '''create AA node''' aa = create_node('CompositorNodeAntiAliasing', tree) # type = ANTIALIASING - aa.threshold = 0.5 - aa.contrast_limit = 0.5 + aa.threshold = 0.5 # 1.0 + aa.contrast_limit = 0.5 # 0.25 aa.corner_rounding = 0.25 aa.hide = True return aa @@ -72,7 +72,7 @@ def get_render_scene(): render = bpy.data.scenes.new('Render') ## copy original settings over to new scene # copy_settings(current, render) # BAD - for attr in ['frame_start', 'frame_end']: + for attr in ['frame_start', 'frame_end', 'frame_current', 'camera', 'world']: setattr(render, attr, getattr(current, attr)) copy_settings(current.render, render.render) @@ -82,8 +82,8 @@ def get_render_scene(): render.collection.objects.link(ob) # use same cam and world - render.camera = current.camera - render.world = current.world + # render.camera = current.camera + # render.world = current.world # set adapted render settings (no AA) set_settings(render) @@ -523,6 +523,11 @@ def renumber_keep_existing(fo, offset=10): ct += offset +def has_channel_color(layer): + '''Return True if gp_layer.channel_color is different than the default (0.2, 0.2, 0.2) ''' + if not any(isclose(i, 0.2, abs_tol=0.001) for i in layer.channel_color): + return True + ## confirm pop-up message: def show_message_box(_message = "", _title = "Message Box", _icon = 'INFO'): def draw(self, context): diff --git a/gen_vlayer.py b/gen_vlayer.py index e10d1be..54c4a6f 100644 --- a/gen_vlayer.py +++ b/gen_vlayer.py @@ -285,6 +285,10 @@ def get_set_viewlayer_from_gp(ob, l, scene=None): cp = add_rlayer(vl_name, scene=scene, location=loc) cp.parent = frame + # use same color as layer + if fn.has_channel_color(l): + cp.use_custom_color = True + cp.color = l.channel_color connect_render_layer(cp, frame=frame) @@ -301,6 +305,10 @@ def get_set_viewlayer_from_gp(ob, l, scene=None): if cp.layer != vl_name: print(f'problem with {cp}: {cp.layer} != {vl_name}') return + + if fn.has_channel_color(l): + cp.use_custom_color = True + cp.color = l.channel_color frame = [f for f in nodes if f.type == 'FRAME' and f.label == ob.name][0] rl_nodes = frame_dic[frame.label] # get nodes from