mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-18 06:21:40 +00:00
Add extra formats to output file
This commit is contained in:
@@ -128,12 +128,14 @@ class ExportCsvAttributes(bpy.types.Operator):
|
|||||||
|
|
||||||
class ExportIfcCsv(bpy.types.Operator):
|
class ExportIfcCsv(bpy.types.Operator):
|
||||||
bl_idname = "bim.export_ifccsv"
|
bl_idname = "bim.export_ifccsv"
|
||||||
bl_label = "Export IFC to CSV"
|
bl_label = "Export IFC"
|
||||||
filename_ext = ".csv"
|
#filename_ext = ".csv"
|
||||||
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
|
filepath: bpy.props.StringProperty(subtype="FILE_PATH")
|
||||||
|
|
||||||
|
|
||||||
def invoke(self, context, event):
|
def invoke(self, context, event):
|
||||||
self.filepath = bpy.path.ensure_ext(bpy.data.filepath, ".csv")
|
props = context.scene.CsvProperties
|
||||||
|
self.filepath = bpy.path.ensure_ext(bpy.data.filepath, f".{props.format}")
|
||||||
WindowManager = context.window_manager
|
WindowManager = context.window_manager
|
||||||
WindowManager.fileselect_add(self)
|
WindowManager.fileselect_add(self)
|
||||||
return {"RUNNING_MODAL"}
|
return {"RUNNING_MODAL"}
|
||||||
@@ -142,7 +144,7 @@ class ExportIfcCsv(bpy.types.Operator):
|
|||||||
import ifccsv
|
import ifccsv
|
||||||
|
|
||||||
props = context.scene.CsvProperties
|
props = context.scene.CsvProperties
|
||||||
self.filepath = bpy.path.ensure_ext(self.filepath, ".csv")
|
self.filepath = bpy.path.ensure_ext(self.filepath, f".{props.format}")
|
||||||
if props.should_load_from_memory:
|
if props.should_load_from_memory:
|
||||||
ifc_file = IfcStore.get_file()
|
ifc_file = IfcStore.get_file()
|
||||||
else:
|
else:
|
||||||
@@ -152,7 +154,7 @@ class ExportIfcCsv(bpy.types.Operator):
|
|||||||
ifc_csv = ifccsv.IfcCsv()
|
ifc_csv = ifccsv.IfcCsv()
|
||||||
attributes = [a.name for a in props.csv_attributes]
|
attributes = [a.name for a in props.csv_attributes]
|
||||||
sep = props.csv_custom_delimiter if props.csv_delimiter == "CUSTOM" else props.csv_delimiter
|
sep = props.csv_custom_delimiter if props.csv_delimiter == "CUSTOM" else props.csv_delimiter
|
||||||
ifc_csv.export(ifc_file, results, attributes, output=self.filepath, format="csv", delimiter=sep)
|
ifc_csv.export(ifc_file, results, attributes, output=self.filepath, format=props.format, delimiter=sep)
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -45,5 +45,14 @@ class CsvProperties(PropertyGroup):
|
|||||||
name="IFC CSV Delimiter",
|
name="IFC CSV Delimiter",
|
||||||
default=",",
|
default=",",
|
||||||
)
|
)
|
||||||
|
format: EnumProperty(
|
||||||
|
items=[
|
||||||
|
("csv", "csv", ""),
|
||||||
|
("xlsx", "xlsx", ""),
|
||||||
|
("ods", "ods", ""),
|
||||||
|
],
|
||||||
|
name="Output format",
|
||||||
|
default="csv",
|
||||||
|
)
|
||||||
csv_custom_delimiter: StringProperty(default="", name="Custom Delimiter")
|
csv_custom_delimiter: StringProperty(default="", name="Custom Delimiter")
|
||||||
should_load_from_memory: BoolProperty(default=False, name="Load from Memory")
|
should_load_from_memory: BoolProperty(default=False, name="Load from Memory")
|
||||||
|
|||||||
@@ -62,15 +62,19 @@ class BIM_PT_ifccsv(Panel):
|
|||||||
row.operator("bim.remove_csv_attribute", icon="X", text="").index = index
|
row.operator("bim.remove_csv_attribute", icon="X", text="").index = index
|
||||||
|
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
row.prop(props, "csv_delimiter")
|
row.prop(props, "format")
|
||||||
|
|
||||||
if props.csv_delimiter == "CUSTOM":
|
if props.format == 'csv':
|
||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
row.prop(props, "csv_custom_delimiter")
|
row.prop(props, "csv_delimiter")
|
||||||
|
|
||||||
|
if props.csv_delimiter == "CUSTOM":
|
||||||
|
row = layout.row(align=True)
|
||||||
|
row.prop(props, "csv_custom_delimiter")
|
||||||
|
|
||||||
row = layout.row()
|
row = layout.row()
|
||||||
split = row.split(factor=0.5)
|
split = row.split(factor=0.5)
|
||||||
c = split.column()
|
c = split.column()
|
||||||
c.operator("bim.export_ifccsv", icon="EXPORT")
|
c.operator("bim.export_ifccsv", icon="EXPORT", text="Export IFC to " + props.format.upper())
|
||||||
c = split.column()
|
c = split.column()
|
||||||
c.operator("bim.import_ifccsv", icon="IMPORT")
|
c.operator("bim.import_ifccsv", icon="IMPORT")
|
||||||
|
|||||||
Reference in New Issue
Block a user