diff --git a/Fange_Pipeline/operators/lighting.py b/Fange_Pipeline/operators/lighting.py index ad9a0e5..2ef90b9 100644 --- a/Fange_Pipeline/operators/lighting.py +++ b/Fange_Pipeline/operators/lighting.py @@ -1,5 +1,7 @@ import bpy +from pathlib import Path + class ConfigLighting(bpy.types.Operator): """Add or conform a lighting build""" @@ -7,6 +9,44 @@ class ConfigLighting(bpy.types.Operator): bl_label = 'Config or update a lighting' def execute(self, context): - print(f'[Pipeline] Start lighting operator') + # Look if a light object are in the scene to clear + self.clear_light_on_scene() + + r = self.get_blend_resources_file() + print(f'[Pipeline] Get file resource {r}') return {'FINISHED'} + + @staticmethod + def get_blend_resources_file(): + """Get the blend file shared with the addon""" + addon_folder = Path(bpy.utils.user_resource('SCRIPTS')) + print(f'[Pipeline] Get addon folder "{addon_folder}"') + addon_name = str(bpy.context.preferences.addons[__name__.split(".")[0]]) + print(f'[Pipeline] The addon name "{addon_name}"') + + return addon_folder.joinpath("addons", addon_name, "resources").as_posix() + + def get_world(self): + pass + + def get_light_collection(self): + pass + + def clear_light_on_scene(self): + bpy.ops.object.select_all(action='DESELECT') + + for ob in bpy.data.objects: + if ob.type == 'LIGHT' and self.find_collection(ob): + ob.select_set(True) + bpy.ops.object.delete() + + else: + ob.select_set(False) + + @staticmethod + def find_collection(ob, name='Lighting'): + """Check if an object are attached with the Lighting collection""" + for collection in ob.users_collection: + if collection.name == name: + return True diff --git a/Fange_Pipeline/operators/misc.py b/Fange_Pipeline/operators/misc.py index 4bfcb8c..dc1d160 100644 --- a/Fange_Pipeline/operators/misc.py +++ b/Fange_Pipeline/operators/misc.py @@ -11,4 +11,5 @@ class MakeBasicCollision(bpy.types.Operator): return bpy.context.object def execute(self, context): + # TODO return {'FINISHED'} diff --git a/Fange_Pipeline/operators/outline.py b/Fange_Pipeline/operators/outline.py index b2e3fce..34003e0 100644 --- a/Fange_Pipeline/operators/outline.py +++ b/Fange_Pipeline/operators/outline.py @@ -86,5 +86,7 @@ class SetCollectionSocket(bpy.types.Operator): def __init__(self): self.socket = bpy.data.collections.get('Socket') + def execute(self, context): + # TODO return {'FINISHED'} diff --git a/Fange_Pipeline/resources/Lighting.blend b/Fange_Pipeline/resources/Lighting.blend new file mode 100644 index 0000000..6f8ffe6 Binary files /dev/null and b/Fange_Pipeline/resources/Lighting.blend differ