ifccsv delimiter

This commit is contained in:
htlcnn
2020-12-28 10:18:55 +07:00
parent 510d756cc4
commit f277733ff5
4 changed files with 17 additions and 1 deletions
@@ -3778,6 +3778,10 @@ class ExportIfcCsv(bpy.types.Operator):
ifc_csv.output = self.filepath
ifc_csv.attributes = [a.name for a in bpy.context.scene.BIMProperties.csv_attributes]
ifc_csv.selector = selector
if bpy.context.scene.BIMProperties.csv_delimiter == "CUSTOM":
ifc_csv.delimiter = bpy.context.scene.BIMProperties.csv_custom_delimiter
else:
ifc_csv.delimiter = bpy.context.scene.BIMProperties.csv_delimiter
ifc_csv.export(ifc_file, results)
return {"FINISHED"}
@@ -1477,6 +1477,12 @@ class BIMProperties(PropertyGroup):
)
ifc_selector: StringProperty(default="", name="IFC Selector")
csv_attributes: CollectionProperty(name="CSV Attributes", type=StrProperty)
csv_delimiter: EnumProperty(
items=[(";", ";", ""), (",", ",", ""), (".", ".", ""), ("CUSTOM", "Custom", ""),],
name="IFC CSV Delimiter",
default=";",
)
csv_custom_delimiter: StringProperty(default="", name="Custom Delimiter")
document_information: CollectionProperty(name="Document Information", type=DocumentInformation)
active_document_information_index: IntProperty(name="Active Document Information Index")
document_references: CollectionProperty(name="Document References", type=DocumentReference)
@@ -1642,6 +1642,11 @@ class BIM_PT_ifccsv(Panel):
row.prop(attribute, "name", text="")
row.operator("bim.remove_csv_attribute", icon="X", text="").index = index
row = layout.row(align=True)
row.prop(props, "csv_delimiter")
row = layout.row(align=True)
row.prop(props, "csv_custom_delimiter")
row = layout.row(align=True)
row.operator("bim.export_ifccsv", icon="EXPORT")
row.operator("bim.import_ifccsv", icon="IMPORT")
+2 -1
View File
@@ -109,6 +109,7 @@ class IfcCsv:
self.attributes = []
self.output = ""
self.selector = None
self.delimiter = ";"
def export(self, ifc_file, elements):
self.ifc_file = ifc_file
@@ -151,7 +152,7 @@ class IfcCsv:
def Import(self, ifc):
ifc_file = ifcopenshell.open(ifc)
with open(self.output, newline="", encoding="utf-8") as f:
reader = csv.reader(f)
reader = csv.reader(f, delimiter=self.delimiter)
headers = []
for row in reader:
if not headers: