mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
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:
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user