Add to scene properties whether we use relative path to .ifc #3251

Previously it was stored as operator's prop which is (turned out) reseted on reopening .blend.
This commit is contained in:
Andrej730
2023-06-05 12:09:59 +05:00
parent 7976fb4d09
commit 5fc31be8aa
2 changed files with 7 additions and 3 deletions
@@ -840,13 +840,16 @@ class ExportIFC(bpy.types.Operator):
return {"RUNNING_MODAL"}
def execute(self, context):
if context.scene.BIMProjectProperties.should_disable_undo_on_save:
project_props = context.scene.BIMProjectProperties
if self.should_save_as:
project_props.use_relative_project_path = self.use_relative_path
if project_props.should_disable_undo_on_save:
old_history_size = tool.Ifc.get().history_size
old_undo_steps = context.preferences.edit.undo_steps
tool.Ifc.get().history_size = 0
context.preferences.edit.undo_steps = 0
IfcStore.execute_ifc_operator(self, context)
if context.scene.BIMProjectProperties.should_disable_undo_on_save:
if project_props.should_disable_undo_on_save:
tool.Ifc.get().history_size = old_history_size
context.preferences.edit.undo_steps = old_undo_steps
return {"FINISHED"}
@@ -883,7 +886,7 @@ class ExportIFC(bpy.types.Operator):
if not scene.DocProperties.ifc_files:
new = scene.DocProperties.ifc_files.add()
new.name = output_file
if self.use_relative_path and bpy.data.is_saved:
if context.scene.BIMProjectProperties.use_relative_project_path and bpy.data.is_saved:
output_file = os.path.relpath(output_file, bpy.path.abspath("//"))
if scene.BIMProperties.ifc_file != output_file and extension not in ["ifczip", "ifcjson"]:
scene.BIMProperties.ifc_file = output_file
@@ -165,6 +165,7 @@ class BIMProjectProperties(PropertyGroup):
active_link_index: IntProperty(name="Active Link Index")
export_schema: EnumProperty(items=get_export_schema, name="IFC Schema")
template_file: EnumProperty(items=get_template_file, name="Template File")
use_relative_project_path: BoolProperty(name="Use Relative Project Path", default=False)
def get_library_element_index(self, lib_element):
return next((i for i in range(len(self.library_elements)) if self.library_elements[i] == lib_element))