mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-19 11:43:53 +00:00
IfcCSV now supports grouping and group operations like concat, sum, min, max, etc.
This commit is contained in:
@@ -81,6 +81,7 @@ class ImportCsvAttributes(bpy.types.Operator):
|
||||
new.name = attribute["name"]
|
||||
new.header = attribute["header"]
|
||||
new.sort = attribute["sort"]
|
||||
new.group = attribute["group"]
|
||||
return {"FINISHED"}
|
||||
|
||||
def invoke(self, context, event):
|
||||
@@ -102,7 +103,9 @@ class ExportCsvAttributes(bpy.types.Operator):
|
||||
|
||||
data = {
|
||||
"query": tool.Search.export_filter_query(props.filter_groups),
|
||||
"attributes": [{"name": a.name, "header": a.header, "sort": a.sort} for a in props.csv_attributes],
|
||||
"attributes": [
|
||||
{"name": a.name, "header": a.header, "sort": a.sort, "group": a.group} for a in props.csv_attributes
|
||||
],
|
||||
}
|
||||
|
||||
with open(self.filepath, "w") as outfile:
|
||||
@@ -148,9 +151,12 @@ class ExportIfcCsv(bpy.types.Operator):
|
||||
headers = [a.header for a in props.csv_attributes]
|
||||
|
||||
sort = []
|
||||
groups = []
|
||||
for attribute in props.csv_attributes:
|
||||
if attribute.sort != "NONE":
|
||||
sort.append({"name": attribute.name, "order": attribute.sort})
|
||||
if attribute.group != "NONE":
|
||||
groups.append({"name": attribute.name, "type": attribute.group, "varies_value": attribute.varies_value})
|
||||
|
||||
sep = props.csv_custom_delimiter if props.csv_delimiter == "CUSTOM" else props.csv_delimiter
|
||||
ifc_csv.export(
|
||||
@@ -167,6 +173,7 @@ class ExportIfcCsv(bpy.types.Operator):
|
||||
bool_true=props.true_value,
|
||||
bool_false=props.false_value,
|
||||
sort=sort,
|
||||
groups=groups,
|
||||
)
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
@@ -36,6 +36,19 @@ class CsvAttribute(PropertyGroup):
|
||||
name: StringProperty(name="Query", default="class")
|
||||
header: StringProperty(name="Header Value", default="IFC Class")
|
||||
sort: EnumProperty(items=[("NONE", "None", ""), ("ASC", "Ascending", ""), ("DESC", "Descending", "")])
|
||||
group: EnumProperty(
|
||||
items=[
|
||||
("NONE", "None", ""),
|
||||
("GROUP", "Group", "All rows where this value is identical will be merged."),
|
||||
("CONCAT", "Concatenation", "Concatenate values if values vary within a group."),
|
||||
("VARIES", "Varies", "Show a custom value if values vary within a group."),
|
||||
("SUM", "Sum", "Sums the total value of rows in a group."),
|
||||
("AVERAGE", "Average", "Averages the total value of rows in a group."),
|
||||
("MIN", "Min", "Gets the minimum value of rows in a group."),
|
||||
("MAX", "Max", "Gets the maximum value of rows in a group."),
|
||||
]
|
||||
)
|
||||
varies_value: StringProperty(default="Varies", name="Varies Value")
|
||||
|
||||
|
||||
class CsvProperties(PropertyGroup):
|
||||
@@ -81,5 +94,6 @@ class CsvProperties(PropertyGroup):
|
||||
)
|
||||
csv_custom_delimiter: StringProperty(default="", name="Custom Delimiter")
|
||||
should_show_settings: BoolProperty(default=False, name="Show Settings")
|
||||
should_show_sort: BoolProperty(default=False, name="Show Sort")
|
||||
should_show_sort: BoolProperty(default=False, name="Show Sorting")
|
||||
should_show_group: BoolProperty(default=False, name="Show Grouping")
|
||||
should_load_from_memory: BoolProperty(default=False, name="Load from Memory")
|
||||
|
||||
@@ -48,6 +48,7 @@ class BIM_PT_ifccsv(Panel):
|
||||
row.operator("bim.import_csv_attributes", icon="IMPORT", text="")
|
||||
row.operator("bim.export_csv_attributes", icon="EXPORT", text="")
|
||||
row.prop(props, "should_show_sort", icon="SORTSIZE", text="")
|
||||
row.prop(props, "should_show_group", icon="OUTLINER_COLLECTION", text="")
|
||||
row.prop(props, "should_show_settings", icon="PREFERENCES", text="")
|
||||
|
||||
if not IfcStore.get_file() or not props.should_load_from_memory:
|
||||
@@ -90,8 +91,11 @@ class BIM_PT_ifccsv(Panel):
|
||||
row.prop(attribute, "name", text="")
|
||||
if props.should_show_sort:
|
||||
row.prop(attribute, "sort", text="")
|
||||
else:
|
||||
row.prop(attribute, "header", text="")
|
||||
if props.should_show_group:
|
||||
row.prop(attribute, "group", text="")
|
||||
if attribute.group == "VARIES":
|
||||
row.prop(attribute, "varies_value", text="")
|
||||
row.prop(attribute, "header", text="")
|
||||
row.operator("bim.remove_csv_attribute", icon="X", text="").index = index
|
||||
|
||||
row = layout.row(align=True)
|
||||
|
||||
Reference in New Issue
Block a user