Fix ExportHelper not optional filename_ext #6463 (4594f59)

This commit is contained in:
Andrej730
2025-03-31 12:34:02 +05:00
parent cba6161043
commit 4593e5aea6
6 changed files with 33 additions and 11 deletions
@@ -242,6 +242,8 @@ class SerializeBrick(bpy.types.Operator, ExportHelper):
bl_label = "Serialize Brick"
# Prevents crash on Blender 4.4.0.
bl_description = "Save active Brick project by the provided filepath."
filename_ext = ".ttl"
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"})
@@ -192,8 +192,13 @@ class ExecuteIfcClash(bpy.types.Operator, ExportHelper):
bl_label = "Execute IFC Clash"
bl_description = "Execute clash detection and save the information to a .bcf or .json file"
filter_glob: bpy.props.StringProperty(default="*.bcf;*.json", options={"HIDDEN"})
format: bpy.props.EnumProperty(name="Format", items=[(i, i, "") for i in ("bcf", "json")])
filepath: bpy.props.StringProperty(subtype="FILE_PATH", options={"SKIP_SAVE"})
@property
def filename_ext(self) -> str:
return f".{self.format.lower()}"
def invoke(self, context, event):
if self.filepath:
return self.execute(context)
@@ -181,6 +181,7 @@ class ExportIfcCsv(bpy.types.Operator, ExportHelper):
bl_label = "Export IFC"
bl_description = "Export IFC data as a spreadsheet."
filename_ext = ".csv"
filter_glob: bpy.props.StringProperty(default="*.csv", options={"HIDDEN"})
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
@classmethod
@@ -202,6 +203,8 @@ class ExportIfcCsv(bpy.types.Operator, ExportHelper):
props = tool.Blender.get_csv_props()
if props.format == "web":
return self.execute(context)
self.filter_glob = f"*.{props.format}"
self.filename_ext = f".{props.format}"
return ExportHelper.invoke(self, context, event)
def execute(self, context):
@@ -528,6 +528,7 @@ class PurgeUnusedElementsByClass(bpy.types.Operator, tool.Ifc.Operator, ExportHe
"ALT+CLICK to provide a path where to save the IFC file with the removed elements (note changes will be applied to the current IFC too)"
)
bl_options = {"REGISTER", "UNDO"}
filename_ext = ".ifc"
filepath: bpy.props.StringProperty(subtype="FILE_PATH", options={"SKIP_SAVE"})
filter_glob: bpy.props.StringProperty(default="*.ifc", options={"HIDDEN"})
+21 -11
View File
@@ -31,9 +31,19 @@ class ExecuteIfcFM(bpy.types.Operator, ExportHelper):
bl_idname = "bim.execute_ifcfm"
bl_label = "Execute IfcFM"
bl_description = "Export IfcFM data as a spreadsheet."
file_format: bpy.props.StringProperty()
filter_glob: bpy.props.StringProperty(default="*.csv;*.ods;*.xlsx", options={"HIDDEN"})
@property
def filename_ext(self) -> str:
props = bpy.context.scene.BIMFMProperties
return f".{props.format}"
def draw(self, context):
layout = self.layout
props = context.scene.BIMFMProperties
layout.prop(props, "format")
@classmethod
def poll(cls, context):
props = context.scene.BIMFMProperties
@@ -42,11 +52,6 @@ class ExecuteIfcFM(bpy.types.Operator, ExportHelper):
return False
return True
def invoke(self, context, event):
props = context.scene.BIMFMProperties
self.filepath = bpy.path.ensure_ext(bpy.data.filepath, f".{props.format}")
return ExportHelper.invoke(self, context, event)
def execute(self, context):
props = context.scene.BIMFMProperties
ifc_file = tool.Ifc.get()
@@ -105,6 +110,16 @@ class ExecuteIfcFMFederate(bpy.types.Operator, ExportHelper):
bl_description = "Merge added IfcFM spreadsheets."
filter_glob: bpy.props.StringProperty(default="*.ods;*.xlsx", options={"HIDDEN"})
@property
def filename_ext(self) -> str:
props = bpy.context.scene.BIMFMProperties
return f".{props.format}"
def draw(self, context):
layout = self.layout
props = context.scene.BIMFMProperties
layout.prop(props, "format")
@classmethod
def poll(cls, context):
props = context.scene.BIMFMProperties
@@ -113,11 +128,6 @@ class ExecuteIfcFMFederate(bpy.types.Operator, ExportHelper):
return False
return True
def invoke(self, context, event):
props = context.scene.BIMFMProperties
self.filepath = bpy.path.ensure_ext(bpy.data.filepath, f".{props.format}")
return ExportHelper.invoke(self, context, event)
def execute(self, context):
props = context.scene.BIMFMProperties
parser = ifcfm.Parser(preset=props.engine)
@@ -638,6 +638,7 @@ class RADIANCE_OT_export_material_mappings(bpy.types.Operator, ExportHelper):
bl_description = "Export material mappings to a JSON file"
filename_ext = ".json"
filter_glob: bpy.props.StringProperty(default="*.json", options={"HIDDEN"})
def execute(self, context):
props = context.scene.radiance_exporter_properties