diff --git a/src/blenderbim/blenderbim/bim/module/brick/operator.py b/src/blenderbim/blenderbim/bim/module/brick/operator.py index 72ef846c87..854480f25c 100644 --- a/src/blenderbim/blenderbim/bim/module/brick/operator.py +++ b/src/blenderbim/blenderbim/bim/module/brick/operator.py @@ -22,7 +22,7 @@ import blenderbim.tool as tool import blenderbim.core.brick as core import blenderbim.bim.handler from blenderbim.bim.ifc import IfcStore - +from blenderbim.tool.brick import BrickStore class Operator: def execute(self, context): @@ -207,6 +207,26 @@ class RedoBrick(bpy.types.Operator, Operator): class SerializeBrick(bpy.types.Operator, Operator): bl_idname = "bim.serialize_brick" bl_label = "Serialize Brick" + filter_glob: bpy.props.StringProperty(default="*.ttl", options={"HIDDEN"}) + filepath: bpy.props.StringProperty(subtype="FILE_PATH") + should_save_as: bpy.props.BoolProperty(name="Should Save As", default=False, options={"HIDDEN"}) + + def invoke(self, context, event): + if self.should_save_as or not BrickStore.path: + WindowManager = context.window_manager + WindowManager.fileselect_add(self) + return {"RUNNING_MODAL"} + else: + return self.execute(context) def _execute(self, context): - core.serialize_brick(tool.Brick) \ No newline at end of file + if self.should_save_as or not BrickStore.path: + BrickStore.path = self.filepath + core.serialize_brick(tool.Brick) + return {"FINISHED"} + + @classmethod + def description(cls, context, properties): + if properties.should_save_as: + return "Save Brick project to a selected file" + return "Save the Brick project" \ No newline at end of file diff --git a/src/blenderbim/blenderbim/bim/module/brick/ui.py b/src/blenderbim/blenderbim/bim/module/brick/ui.py index 717ee3eb12..f863b0fb5f 100644 --- a/src/blenderbim/blenderbim/bim/module/brick/ui.py +++ b/src/blenderbim/blenderbim/bim/module/brick/ui.py @@ -20,7 +20,7 @@ import blenderbim.tool as tool from bpy.types import Panel, UIList from blenderbim.bim.helper import prop_with_search from blenderbim.bim.module.brick.data import BrickschemaData, BrickschemaReferencesData - +from blenderbim.tool.brick import BrickStore class BIM_PT_brickschema(Panel): bl_label = "Brickschema Project" @@ -41,6 +41,10 @@ class BIM_PT_brickschema(Panel): row.operator("bim.load_brick_project", text="Load Project") return + if BrickStore.path: + row = self.layout.row(align=True) + row.label(text=BrickStore.path, icon='FILEBROWSER') + row = self.layout.row(align=True) if len(self.props.brick_breadcrumbs): row.operator("bim.rewind_brick_class", text="", icon="FRAME_PREV") @@ -63,7 +67,10 @@ class BIM_PT_brickschema(Panel): row.operator("bim.redo_brick", icon="LOOP_FORWARDS") row = self.layout.row(align=True) - row.operator("bim.serialize_brick") + op = row.operator("bim.serialize_brick", icon="EXPORT", text="Save") + op.should_save_as = False + op = row.operator("bim.serialize_brick", icon="FILE_TICK", text="Save As") + op.should_save_as = True self.layout.template_list("BIM_UL_bricks", "", self.props, "bricks", self.props, "active_brick_index") diff --git a/src/blenderbim/blenderbim/core/brick.py b/src/blenderbim/blenderbim/core/brick.py index cd7fafaed0..695e5cb319 100644 --- a/src/blenderbim/blenderbim/core/brick.py +++ b/src/blenderbim/blenderbim/core/brick.py @@ -118,5 +118,5 @@ def redo_brick(brick): brick.redo_brick() brick.run_refresh_brick_viewer() -def serialize_brick(brick, file_name="BlenderBIMSerializeTest.ttl"): - brick.serialize_brick(file_name) \ No newline at end of file +def serialize_brick(brick): + brick.serialize_brick() \ No newline at end of file diff --git a/src/blenderbim/blenderbim/tool/brick.py b/src/blenderbim/blenderbim/tool/brick.py index b4539c64aa..f7cb4e0b8f 100644 --- a/src/blenderbim/blenderbim/tool/brick.py +++ b/src/blenderbim/blenderbim/tool/brick.py @@ -332,12 +332,10 @@ class Brick(blenderbim.core.tool.Brick): BrickStore.graph.redo() @classmethod - def serialize_brick(cls, file_name): - #temporary file path, could either be user selected for "save as" or use the BrickStore.path for simply "save" - cwd = os.path.dirname(os.path.realpath(__file__)) - dest = os.path.join(cwd, "..", "bim", "schema", file_name) - BrickStore.get_project().serialize(destination=dest, format="turtle") - + def serialize_brick(cls): + print(BrickStore.path) + BrickStore.get_project().serialize(destination=BrickStore.path, format="turtle") + class BrickStore: schema = None # this is now a os path path = None # file path if the project was loaded in