diff --git a/CHANGELOG.md b/CHANGELOG.md index 28c8041..e9d9d82 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ Activate / deactivate layer opacity according to prefix Activate / deactivate all masks using MA layers --> +1.4.0 + +- added: split selection to scenes individually + 1.3.6 - added: scene resolution in json crop pixels information, per objects diff --git a/OP_add_layer.py b/OP_add_layer.py index ff7f164..103de88 100644 --- a/OP_add_layer.py +++ b/OP_add_layer.py @@ -92,14 +92,32 @@ class GPEXP_OT_split_to_scene(bpy.types.Operator): mode : bpy.props.StringProperty(default='ALL', options={'SKIP_SAVE'}) def execute(self, context): - err = fn.split_object_to_scene() - if err: - self.report({'ERROR'}, err) - return {"CANCELLED"} + if self.mode == 'ALL': + print('split selected object in separated scene') + err = fn.split_object_to_scene() + if err: + self.report({'ERROR'}, err) + return {"CANCELLED"} + + elif self.mode == 'INDIVIDUAL': + print('split selected object individually in separated scenes') + errors = [] + selected_objs = [o for o in context.selected_objects] + scn = context.scene + for o in reversed(selected_objs): + err = fn.split_object_to_scene(objs=[o], scene_name=o.name) + if err: + errors.append(err) + + ## Reset to current scene (function use ops and go to new scene) + context.window.scene = scn + + if errors: + fn.show_message_box(errors, 'Error Log') + return {"CANCELLED"} + return {"FINISHED"} - - classes=( GPEXP_OT_add_layer_to_render, GPEXP_OT_add_objects_to_render, diff --git a/__init__.py b/__init__.py index 6c12919..b1d14cf 100644 --- a/__init__.py +++ b/__init__.py @@ -2,8 +2,8 @@ bl_info = { "name": "GP Render", "description": "Organise export of gp layers through compositor output", "author": "Samuel Bernou", - "version": (1, 3, 6), - "blender": (2, 93, 0), + "version": (1, 4, 0), + "blender": (3, 0, 0), "location": "View3D", "warning": "", "doc_url": "https://gitlab.com/autour-de-minuit/blender/gp_render", diff --git a/fn.py b/fn.py index 0f95799..74165a3 100644 --- a/fn.py +++ b/fn.py @@ -1512,12 +1512,14 @@ def remove_scene_nodes_by_obj_names(scn, name_list, negative=False): if (n.parent and n.parent.label in name_list) or (n.type == 'FRAME' and n.label in name_list): scn.node_tree.nodes.remove(n) -def split_object_to_scene(): +def split_object_to_scene(objs=None, scene_name=None): '''Create a new scene from object selection''' - active = bpy.context.object - scene_name = active.name - objs = [o for o in bpy.context.selected_objects] + if not scene_name: + active = bpy.context.object + scene_name = active.name + if not objs: + objs = [o for o in bpy.context.selected_objects] if bpy.data.scenes.get(scene_name): print(f'Scene "{scene_name}" Already Exists') diff --git a/ui.py b/ui.py index d3d9cc8..425ba69 100644 --- a/ui.py +++ b/ui.py @@ -139,7 +139,9 @@ class GPEXP_PT_gp_node_ui(Panel): layout.separator() layout.label(text='Scenes:') - layout.operator('gp.split_to_scene', icon='DUPLICATE', text='Split Selected Obj To Scene') + row = layout.row(align=True) + row.operator('gp.split_to_scene', icon='DUPLICATE', text='Split Selection To Scene').mode = 'ALL' + row.operator('gp.split_to_scene', text='Split Individually').mode = 'INDIVIDUAL' row = layout.row(align=True) row.operator('gp.set_crop_from_selection', icon='CON_OBJECTSOLVER', text='Autoset Crop')