diff --git a/CHANGELOG.md b/CHANGELOG.md index b7b290d..af405f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,11 @@ Activate / deactivate layer opacity according to prefix Activate / deactivate all masks using MA layers --> +1.0.3 + +- fixed: Send to render layer compatibility with blender 3.4 +- added: clear default nodes when creating new render scene + 1.0.2 - added: GP object with name starting with `.` are ignored from "all objects" operation (renaming, numbering, sending to render scene) diff --git a/OP_add_layer.py b/OP_add_layer.py index 77ee9ff..28db903 100644 --- a/OP_add_layer.py +++ b/OP_add_layer.py @@ -64,7 +64,8 @@ def export_gp_objects(oblist, exclude_list=[], scene=None): class GPEXP_OT_add_objects_to_render(bpy.types.Operator): bl_idname = "gp.add_object_to_render" bl_label = "Add all Gp Layer of active object as render nodes" - bl_description = "Setup GP object in render scene\nNote: 'send all' mode skip hided objects" + bl_description = "Setup GP object in render scene\ + \nNote: 'send all' mode skip hided objects" bl_options = {"REGISTER"} @classmethod diff --git a/OP_auto_build.py b/OP_auto_build.py index 43dc02e..c247f3f 100644 --- a/OP_auto_build.py +++ b/OP_auto_build.py @@ -1,4 +1,5 @@ import bpy +from pathlib import Path from . import gen_vlayer, fn class GPEXP_OT_render_auto_build(bpy.types.Operator): @@ -45,6 +46,10 @@ class GPEXP_OT_render_auto_build(bpy.types.Operator): ## TODO: add colors to layers (specified in ENV or hardcoded for now...) ## Option: Maybe find a way to create a color from prefix hash ? (wlways give unique color with same prefix on other project!) + render_scn = bpy.data.scenes.get('Render') + if render_scn: + self.report({'ERROR'}, 'A "Render" scene already exists') + return {'CANCELLED'} ## Trigger rename lowercase bpy.ops.gp.lower_layers_name() @@ -52,13 +57,35 @@ class GPEXP_OT_render_auto_build(bpy.types.Operator): ## Trigger renumber by distance bpy.ops.gp.auto_number_object() - ## Export layer infos ? - bpy.ops.gp.export_infos_for_compo() + ## Export layer infos ? (skip if json already exists) + bpy.ops.gp.export_infos_for_compo('INVOKE_DEFAULT', skip_check=True) ## Send all GP to render scene bpy.ops.gp.add_object_to_render(mode="ALL") + ## Switch to new Render Scene + render_scn = bpy.data.scenes.get('Render') + if not render_scn: + self.report({'ERROR'}, 'No render scene found') + return {'CANCELLED'} + context.window.scene = render_scn + + ## Change to GP workspace (if needed) + if context.window.workspace.name != 'GP Render': + if (render_wkspace := bpy.data.workspaces.get('GP Render')): + context.window.workspace = render_wkspace + else: + render_wkspace_filepath = Path(bpy.utils.user_resource('SCRIPTS'), 'startup', 'GP', 'startup.blend') + ret = bpy.ops.workspace.append_activate(idname='GP Render', filepath=str(render_wkspace_filepath)) + if ret != {'FINISHED'}: + # Fallback to workspace template shipped with addon (TODO : add template blend file in addon) + render_wkspace_filepath = Path(__file__).parent / 'workspaces' / 'startup.blend' + ret = bpy.ops.workspace.append_activate(idname='GP Render', filepath=str(render_wkspace_filepath)) + + ## Group all adjacent layer type + + ## Renumber File outputs diff --git a/OP_setup_layers.py b/OP_setup_layers.py index 5718bcd..a4637b4 100644 --- a/OP_setup_layers.py +++ b/OP_setup_layers.py @@ -61,9 +61,16 @@ class GPEXP_OT_export_infos_for_compo(bpy.types.Operator): def poll(cls, context): return context.object and context.object.type == 'GPENCIL' - def invoke(self, context, event): + skip_check : bpy.props.BoolProperty(default=False, options={'SKIP_SAVE'}) + def invoke(self, context, event): self.l_infos = Path(bpy.data.filepath).parent / 'render' / 'infos.json' + if self.skip_check: + if self.l_infos.exists(): + # Preferably skip if already user defined ? + return {'FINISHED'} + return self.execute(context) + if self.l_infos.exists(): return context.window_manager.invoke_props_dialog(self) return self.execute(context) diff --git a/fn.py b/fn.py index e7d7122..3319a8f 100644 --- a/fn.py +++ b/fn.py @@ -229,7 +229,10 @@ def get_render_scene(): render_scn.use_nodes = True - # TODO Clear node tree (initial view layer stuff) + ## Clear node tree (initial view layer stuff) + render_scn.node_tree.nodes.clear() + # for n in reversed(render_scn.node_tree.nodes): + # render_scn.node_tree.nodes.remove(n) set_settings(render_scn) render_scn['use_aa'] = True diff --git a/gen_vlayer.py b/gen_vlayer.py index 9c09493..2c14823 100644 --- a/gen_vlayer.py +++ b/gen_vlayer.py @@ -106,7 +106,7 @@ def connect_render_layer(rlayer, ng=None, out=None, frame=None): if not rlayer.outputs['Image'].is_linked: sockin = ng.inputs.get(vl_name) if not sockin: - sockin = ng.inputs.new('NodeSocketColor', vl_name) + sockin = ng.node_tree.inputs.new('NodeSocketColor', vl_name) sockin = ng.inputs[-1] links.new(rlayer.outputs['Image'], sockin) @@ -144,7 +144,7 @@ def connect_render_layer(rlayer, ng=None, out=None, frame=None): aa = fn.create_aa_nodegroup(ngroup)# fn.new_aa_node(ngroup) groupout = ng.outputs.get(vl_name) if not groupout: - ng.outputs.new('NodeSocketColor', vl_name) # assigning direcly doesn't link well + ng.node_tree.outputs.new('NodeSocketColor', vl_name) # assigning direcly doesn't link well groupout = ng.outputs[-1] # print('ng_out.inputs.get(vl_name): ', ng_out.inputs.get(vl_name))