From 649b19a33d4f40b845695fcdb2f0c49603e6b3ae Mon Sep 17 00:00:00 2001 From: Aurelien Vaillant Date: Tue, 7 May 2024 22:49:09 +0200 Subject: [PATCH] Make model about path used --- Fange Pipeline/models.py | 28 ++++++++++++++++++++++++++++ Fange Pipeline/ops.py | 8 +++++--- 2 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 Fange Pipeline/models.py diff --git a/Fange Pipeline/models.py b/Fange Pipeline/models.py new file mode 100644 index 0000000..2b4d7b0 --- /dev/null +++ b/Fange Pipeline/models.py @@ -0,0 +1,28 @@ +import bpy + +from pathlib import Path + + +class FangeProject: + def __init__(self): + self._pref = bpy.context.preferences.addons[__name__.split(".")[0]].preferences + + self._project_path = Path(self._pref.project_path) + self._subdir_path = Path(self._pref.subdir_graph) + + self._building_path = Path(self._pref.subdir_buildings) + self._props_path = Path(self._pref.subdir_props) + self._characters_path = Path(self._pref.subdir_characters) + + @property + def buildings(self): + """Get the buildings project path, on absolute""" + return self._project_path.joinpath(self._subdir_path, self._building_path) + + @property + def props(self): + return self._project_path.joinpath(self._subdir_path, self._props_path) + + @property + def characters(self): + return self._project_path.joinpath(self._subdir_path, self._characters_path) diff --git a/Fange Pipeline/ops.py b/Fange Pipeline/ops.py index 8ac785a..2b226e3 100644 --- a/Fange Pipeline/ops.py +++ b/Fange Pipeline/ops.py @@ -1,5 +1,6 @@ import bpy +from .models import FangeProject from pathlib import Path @@ -10,7 +11,7 @@ class ExportForFange(bpy.types.Operator): def __init__(self): self.coll_layout = bpy.data.collections.get('Placeholder') - self.output = Path("W:\\", "Graou Studio", "Game Projects", "Fange Prototype", "Assets", "Graph", "Buildings") + self.path = FangeProject() self.fbx_preset = 'sm-unity-building' @classmethod @@ -32,11 +33,12 @@ class ExportForFange(bpy.types.Operator): print(f'[Pipeline] Select all mesh inside the collection "{child.name}"') for ob in child.all_objects: print(f'\tLook "{ob.name}", his type are "{type(ob.data)}"') - if isinstance(ob.data, bpy.types.Mesh) or isinstance(ob.data, bpy.types.Empty): + # TODO Support another type object, not only SM/SK + if isinstance(ob.data, bpy.types.Mesh): ob.select_set(True) # TODO The plugin export only the garden building - abs_export = self.output.joinpath("Garden", "Meshes") + abs_export = self.path.buildings.joinpath("Garden", "Meshes") if not abs_export.exists(): abs_export.mkdir()