mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-17 14:02:27 +00:00
add configurable suffix for metadata blend file
This commit is contained in:
@@ -1062,10 +1062,15 @@ class LoadProject(bpy.types.Operator, IFCFileSelector, ImportHelper):
|
|||||||
and not self.is_advanced
|
and not self.is_advanced
|
||||||
):
|
):
|
||||||
filepath = self.get_filepath()
|
filepath = self.get_filepath()
|
||||||
metadata_path = Path(str(filepath) + ".metadata.blend")
|
suffix = tool.Blender.get_addon_preferences().metadata_blend_file_suffix
|
||||||
|
if str(filepath).lower().endswith(".ifc"):
|
||||||
|
metadata_path = Path(str(filepath)[:-4] + suffix)
|
||||||
|
else:
|
||||||
|
metadata_path = Path(str(filepath) + suffix)
|
||||||
if metadata_path.exists() and metadata_path.is_file():
|
if metadata_path.exists() and metadata_path.is_file():
|
||||||
try:
|
try:
|
||||||
bpy.ops.bim.load_blend_metadata_and_ifc(filepath=filepath)
|
bpy.ops.bim.load_blend_metadata_and_ifc(filepath=filepath)
|
||||||
|
self.report({"INFO"}, f"Loaded metadata file: {metadata_path.name}")
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.report({"WARNING"}, f"Failed to load metadata file, using regular load: {e}")
|
self.report({"WARNING"}, f"Failed to load metadata file, using regular load: {e}")
|
||||||
@@ -1763,7 +1768,11 @@ class ExportIFC(bpy.types.Operator, ExportHelper):
|
|||||||
if tool.Blender.get_addon_preferences().save_metadata_blend_file:
|
if tool.Blender.get_addon_preferences().save_metadata_blend_file:
|
||||||
try:
|
try:
|
||||||
bpy.ops.bim.save_blend_metadata_file()
|
bpy.ops.bim.save_blend_metadata_file()
|
||||||
blendmetadata_path = output_file + ".metadata.blend"
|
suffix = tool.Blender.get_addon_preferences().metadata_blend_file_suffix
|
||||||
|
if output_file.lower().endswith(".ifc"):
|
||||||
|
blendmetadata_path = output_file[:-4] + suffix
|
||||||
|
else:
|
||||||
|
blendmetadata_path = output_file + suffix
|
||||||
self.report(
|
self.report(
|
||||||
{"INFO"},
|
{"INFO"},
|
||||||
f'IFC Project "{os.path.basename(output_file)}" And Metadata File Saved to: {os.path.basename(blendmetadata_path)}',
|
f'IFC Project "{os.path.basename(output_file)}" And Metadata File Saved to: {os.path.basename(blendmetadata_path)}',
|
||||||
|
|||||||
@@ -332,10 +332,14 @@ class BIM_PT_project(Panel):
|
|||||||
row.operator("bim.select_ifc_file", icon="FILE_FOLDER", text="")
|
row.operator("bim.select_ifc_file", icon="FILE_FOLDER", text="")
|
||||||
|
|
||||||
if tool.Blender.get_addon_preferences().save_metadata_blend_file:
|
if tool.Blender.get_addon_preferences().save_metadata_blend_file:
|
||||||
|
suffix = tool.Blender.get_addon_preferences().metadata_blend_file_suffix
|
||||||
|
if props.ifc_file.lower().endswith(".ifc"):
|
||||||
|
metadata_filename = os.path.basename(props.ifc_file)[:-4] + suffix
|
||||||
|
else:
|
||||||
|
metadata_filename = os.path.basename(props.ifc_file) + suffix
|
||||||
row = self.layout.row(align=True)
|
row = self.layout.row(align=True)
|
||||||
col = row.column()
|
col = row.column()
|
||||||
col.enabled = False
|
col.enabled = False
|
||||||
metadata_filename = os.path.basename(props.ifc_file) + ".metadata.blend"
|
|
||||||
col.label(text=f"Saving session data to: {metadata_filename}")
|
col.label(text=f"Saving session data to: {metadata_filename}")
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -260,7 +260,11 @@ class SaveBlendMetadataFile(bpy.types.Operator):
|
|||||||
self.report({"WARNING"}, "No IFC file path set.")
|
self.report({"WARNING"}, "No IFC file path set.")
|
||||||
return {"CANCELLED"}
|
return {"CANCELLED"}
|
||||||
|
|
||||||
blendmetadata_path = ifc_file + ".metadata.blend"
|
suffix = tool.Blender.get_addon_preferences().metadata_blend_file_suffix
|
||||||
|
if ifc_file.lower().endswith(".ifc"):
|
||||||
|
blendmetadata_path = ifc_file[:-4] + suffix
|
||||||
|
else:
|
||||||
|
blendmetadata_path = ifc_file + suffix
|
||||||
|
|
||||||
ifc_dir = os.path.dirname(ifc_file)
|
ifc_dir = os.path.dirname(ifc_file)
|
||||||
temp_path = os.path.join(ifc_dir, "__temp_blendmetadata.blend")
|
temp_path = os.path.join(ifc_dir, "__temp_blendmetadata.blend")
|
||||||
@@ -376,7 +380,11 @@ class LoadBlendMetadataAndIFC(bpy.types.Operator):
|
|||||||
self.report({"WARNING"}, "No IFC file path set.")
|
self.report({"WARNING"}, "No IFC file path set.")
|
||||||
return {"CANCELLED"}
|
return {"CANCELLED"}
|
||||||
|
|
||||||
metadata_path = ifc_file + ".metadata.blend"
|
suffix = tool.Blender.get_addon_preferences().metadata_blend_file_suffix
|
||||||
|
if ifc_file.lower().endswith(".ifc"):
|
||||||
|
metadata_path = ifc_file[:-4] + suffix
|
||||||
|
else:
|
||||||
|
metadata_path = ifc_file + suffix
|
||||||
# Open the metadata blend file
|
# Open the metadata blend file
|
||||||
bpy.ops.wm.open_mainfile(filepath=metadata_path)
|
bpy.ops.wm.open_mainfile(filepath=metadata_path)
|
||||||
# After loading metadata, clear blend warning (no geometry loaded yet)
|
# After loading metadata, clear blend warning (no geometry loaded yet)
|
||||||
|
|||||||
@@ -715,13 +715,18 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
|
|||||||
)
|
)
|
||||||
|
|
||||||
save_metadata_blend_file: BoolProperty(
|
save_metadata_blend_file: BoolProperty(
|
||||||
name="Save non ifc data to .metadata.blend File",
|
name="Save non ifc data to metadata blend File",
|
||||||
description="Save session data (window layout, settings) to a .metadata.blend file alongside the IFC file. This file is automatically loaded when opening the project.",
|
description="Save session data (window layout, settings) to a metadata blend file alongside the IFC file. This file is automatically loaded when opening the project.",
|
||||||
default=False,
|
default=False,
|
||||||
)
|
)
|
||||||
|
metadata_blend_file_suffix: StringProperty(
|
||||||
|
name="Metadata File Suffix",
|
||||||
|
description="Custom suffix for the metadata blend file. Will be appended to the filename (without .ifc).",
|
||||||
|
default=".ifc.metadata.blend",
|
||||||
|
)
|
||||||
user_ui_customization: BoolProperty(
|
user_ui_customization: BoolProperty(
|
||||||
name="User UI Customization",
|
name="User UI Customization",
|
||||||
description="Enable user interface customization features (hide/show tabs and panels, bookmark panels) and save the session settings as part of the .metadata.blend file",
|
description="Enable user interface customization features (hide/show tabs and panels, bookmark panels) and save the session settings as part of the metadata blend file",
|
||||||
default=False,
|
default=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -958,6 +963,9 @@ class BIM_ADDON_preferences(bpy.types.AddonPreferences):
|
|||||||
row.operator("bim.open_uri", text="", icon="HELP").uri = "https://community.osarch.org/discussion/comment/27030"
|
row.operator("bim.open_uri", text="", icon="HELP").uri = "https://community.osarch.org/discussion/comment/27030"
|
||||||
layout.prop(self, "save_metadata_blend_file")
|
layout.prop(self, "save_metadata_blend_file")
|
||||||
if self.save_metadata_blend_file:
|
if self.save_metadata_blend_file:
|
||||||
|
row = layout.row()
|
||||||
|
row.separator()
|
||||||
|
row.prop(self, "metadata_blend_file_suffix")
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
row.separator()
|
row.separator()
|
||||||
row.prop(self, "user_ui_customization")
|
row.prop(self, "user_ui_customization")
|
||||||
|
|||||||
Reference in New Issue
Block a user