mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 22:50:21 +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"}
|
return {"RUNNING_MODAL"}
|
||||||
|
|
||||||
def execute(self, context):
|
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_history_size = tool.Ifc.get().history_size
|
||||||
old_undo_steps = context.preferences.edit.undo_steps
|
old_undo_steps = context.preferences.edit.undo_steps
|
||||||
tool.Ifc.get().history_size = 0
|
tool.Ifc.get().history_size = 0
|
||||||
context.preferences.edit.undo_steps = 0
|
context.preferences.edit.undo_steps = 0
|
||||||
IfcStore.execute_ifc_operator(self, context)
|
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
|
tool.Ifc.get().history_size = old_history_size
|
||||||
context.preferences.edit.undo_steps = old_undo_steps
|
context.preferences.edit.undo_steps = old_undo_steps
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
@@ -883,7 +886,7 @@ class ExportIFC(bpy.types.Operator):
|
|||||||
if not scene.DocProperties.ifc_files:
|
if not scene.DocProperties.ifc_files:
|
||||||
new = scene.DocProperties.ifc_files.add()
|
new = scene.DocProperties.ifc_files.add()
|
||||||
new.name = output_file
|
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("//"))
|
output_file = os.path.relpath(output_file, bpy.path.abspath("//"))
|
||||||
if scene.BIMProperties.ifc_file != output_file and extension not in ["ifczip", "ifcjson"]:
|
if scene.BIMProperties.ifc_file != output_file and extension not in ["ifczip", "ifcjson"]:
|
||||||
scene.BIMProperties.ifc_file = output_file
|
scene.BIMProperties.ifc_file = output_file
|
||||||
|
|||||||
@@ -165,6 +165,7 @@ class BIMProjectProperties(PropertyGroup):
|
|||||||
active_link_index: IntProperty(name="Active Link Index")
|
active_link_index: IntProperty(name="Active Link Index")
|
||||||
export_schema: EnumProperty(items=get_export_schema, name="IFC Schema")
|
export_schema: EnumProperty(items=get_export_schema, name="IFC Schema")
|
||||||
template_file: EnumProperty(items=get_template_file, name="Template File")
|
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):
|
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))
|
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