diff --git a/src/blenderbim/blenderbim/bim/module/csv/__init__.py b/src/blenderbim/blenderbim/bim/module/csv/__init__.py index 1f1502b695..b8cc7d0079 100644 --- a/src/blenderbim/blenderbim/bim/module/csv/__init__.py +++ b/src/blenderbim/blenderbim/bim/module/csv/__init__.py @@ -21,13 +21,14 @@ from . import ui, prop, operator classes = ( operator.AddCsvAttribute, - operator.RemoveCsvAttribute, - operator.RemoveAllCsvAttributes, - operator.ExportIfcCsv, - operator.ImportIfcCsv, - operator.SelectCsvIfcFile, - operator.ImportCsvAttributes, operator.ExportCsvAttributes, + operator.ExportIfcCsv, + operator.ImportCsvAttributes, + operator.ImportIfcCsv, + operator.RemoveAllCsvAttributes, + operator.RemoveCsvAttribute, + operator.ReorderCsvAttribute, + operator.SelectCsvIfcFile, prop.CsvAttribute, prop.CsvProperties, ui.BIM_PT_ifccsv, diff --git a/src/blenderbim/blenderbim/bim/module/csv/operator.py b/src/blenderbim/blenderbim/bim/module/csv/operator.py index ee3e312e29..c1b63e4dd3 100644 --- a/src/blenderbim/blenderbim/bim/module/csv/operator.py +++ b/src/blenderbim/blenderbim/bim/module/csv/operator.py @@ -62,6 +62,24 @@ class RemoveAllCsvAttributes(bpy.types.Operator): return {"FINISHED"} +class ReorderCsvAttribute(bpy.types.Operator): + bl_idname = "bim.reorder_csv_attribute" + bl_label = "Reorder CSV Attribute" + bl_options = {"REGISTER", "UNDO"} + old_index: bpy.props.IntProperty() + new_index: bpy.props.IntProperty() + + def execute(self, context): + old = context.scene.CsvProperties.csv_attributes[self.old_index] + new = context.scene.CsvProperties.csv_attributes[self.new_index] + props = ["name", "header", "sort", "group", "varies_value", "summary"] + for prop in props: + value = getattr(new, prop) + setattr(new, prop, getattr(old, prop)) + setattr(old, prop, value) + return {"FINISHED"} + + class ImportCsvAttributes(bpy.types.Operator): bl_idname = "bim.import_csv_attributes" bl_label = "Load CSV Settings" diff --git a/src/blenderbim/blenderbim/bim/module/csv/ui.py b/src/blenderbim/blenderbim/bim/module/csv/ui.py index d4f4951155..c1e5c93222 100644 --- a/src/blenderbim/blenderbim/bim/module/csv/ui.py +++ b/src/blenderbim/blenderbim/bim/module/csv/ui.py @@ -87,6 +87,7 @@ class BIM_PT_ifccsv(Panel): row.prop(props, "should_show_group", icon="OUTLINER_COLLECTION", text="") row.prop(props, "should_show_summary", icon="SYNTAX_ON", text="") + total = len(props.csv_attributes) for index, attribute in enumerate(props.csv_attributes): row = layout.row(align=True) row.prop(attribute, "name", text="") @@ -99,6 +100,15 @@ class BIM_PT_ifccsv(Panel): row.prop(attribute, "varies_value", text="") if props.should_show_summary: row.prop(attribute, "summary", text="") + if total > 1: + if index != 0: + op = row.operator(f"bim.reorder_csv_attribute", icon="TRIA_UP", text="") + op.old_index = index + op.new_index = index - 1 + if index + 1 != total: + op = row.operator(f"bim.reorder_csv_attribute", icon="TRIA_DOWN", text="") + op.old_index = index + op.new_index = index + 1 row.operator("bim.remove_csv_attribute", icon="X", text="").index = index row = layout.row(align=True)