See #3951. IfcCSV now supports list concatenation.

This commit is contained in:
Dion Moult
2023-11-01 22:47:16 +11:00
parent c9dcd70cdb
commit e2b132ba51
5 changed files with 12 additions and 2 deletions
@@ -207,6 +207,7 @@ class ExportIfcCsv(bpy.types.Operator):
empty=props.empty_value, empty=props.empty_value,
bool_true=props.true_value, bool_true=props.true_value,
bool_false=props.false_value, bool_false=props.false_value,
concat=props.concat_value,
sort=sort, sort=sort,
groups=groups, groups=groups,
summaries=summaries, summaries=summaries,
@@ -72,6 +72,7 @@ class CsvProperties(PropertyGroup):
empty_value: StringProperty(default="-", name="Empty String Value") empty_value: StringProperty(default="-", name="Empty String Value")
true_value: StringProperty(default="YES", name="True Value") true_value: StringProperty(default="YES", name="True Value")
false_value: StringProperty(default="NO", name="False Value") false_value: StringProperty(default="NO", name="False Value")
concat_value: StringProperty(default=", ", name="Concat Value")
csv_delimiter: EnumProperty( csv_delimiter: EnumProperty(
items=[ items=[
(";", ";", ""), (";", ";", ""),
@@ -79,6 +79,8 @@ class BIM_PT_ifccsv(Panel):
row.prop(props, "true_value") row.prop(props, "true_value")
row = layout.row() row = layout.row()
row.prop(props, "false_value") row.prop(props, "false_value")
row = layout.row()
row.prop(props, "concat_value")
layout.use_property_split = False layout.use_property_split = False
blenderbim.bim.helper.draw_filter(self.layout, props, SearchData, "csv") blenderbim.bim.helper.draw_filter(self.layout, props, SearchData, "csv")
+5
View File
@@ -73,6 +73,7 @@ class IfcCsv:
empty="", empty="",
bool_true="YES", bool_true="YES",
bool_false="NO", bool_false="NO",
concat=", ",
sort=None, sort=None,
groups=None, groups=None,
summaries=None, summaries=None,
@@ -103,6 +104,8 @@ class IfcCsv:
value = bool_true value = bool_true
elif value is False: elif value is False:
value = bool_false value = bool_false
elif isinstance(value, (list, tuple)) and concat is not None:
value = concat.join(map(str, value))
result.append(value) result.append(value)
self.results.append(result) self.results.append(result)
@@ -453,6 +456,7 @@ if __name__ == "__main__":
) )
parser.add_argument("--bool_true", type=str, default="YES", help="How to represent true values. Defaults to YES.") parser.add_argument("--bool_true", type=str, default="YES", help="How to represent true values. Defaults to YES.")
parser.add_argument("--bool_false", type=str, default="NO", help="How to represent false values. Defaults to NO.") parser.add_argument("--bool_false", type=str, default="NO", help="How to represent false values. Defaults to NO.")
parser.add_argument("--concat", type=str, default=", ", help="How to concatenate lists. Defaults to ', '.")
parser.add_argument("-q", "--query", type=str, default="", help='Specify a IFC query selector, such as "IfcWall"') parser.add_argument("-q", "--query", type=str, default="", help='Specify a IFC query selector, such as "IfcWall"')
parser.add_argument( parser.add_argument(
"-a", "-a",
@@ -486,6 +490,7 @@ if __name__ == "__main__":
empty=args.empty, empty=args.empty,
bool_true=args.bool_true, bool_true=args.bool_true,
bool_false=args.bool_false, bool_false=args.bool_false,
concat=args.concat,
sort=sort, sort=sort,
) )
elif getattr(args, "import"): elif getattr(args, "import"):
+3 -2
View File
@@ -66,8 +66,8 @@ utility:
:: ::
$ python -m ifccsv -h $ python -m ifccsv -h
usage: ifccsv.py [-h] -i IFC [-s SPREADSHEET] [-f FORMAT] [-d DELIMITER] [-n NULL] [-e EMPTY] [--bool_true BOOL_TRUE] [--bool_false BOOL_FALSE] [-q QUERY] [-a ATTRIBUTES [ATTRIBUTES ...]] [--headers HEADERS [HEADERS ...]] usage: ifccsv.py [-h] -i IFC [-s SPREADSHEET] [-f FORMAT] [-d DELIMITER] [-n NULL] [-e EMPTY] [--bool_true BOOL_TRUE] [--bool_false BOOL_FALSE] [--concat CONCAT] [-q QUERY] [-a ATTRIBUTES [ATTRIBUTES ...]]
[--sort SORT [SORT ...]] [--order ORDER [ORDER ...]] [--export] [--import] [--headers HEADERS [HEADERS ...]] [--sort SORT [SORT ...]] [--order ORDER [ORDER ...]] [--export] [--import]
Exports IFC data to and from CSV Exports IFC data to and from CSV
@@ -87,6 +87,7 @@ utility:
How to represent true values. Defaults to YES. How to represent true values. Defaults to YES.
--bool_false BOOL_FALSE --bool_false BOOL_FALSE
How to represent false values. Defaults to NO. How to represent false values. Defaults to NO.
--concat CONCAT How to concatenate lists. Defaults to ', '.
-q QUERY, --query QUERY -q QUERY, --query QUERY
Specify a IFC query selector, such as "IfcWall" Specify a IFC query selector, such as "IfcWall"
-a ATTRIBUTES [ATTRIBUTES ...], --attributes ATTRIBUTES [ATTRIBUTES ...] -a ATTRIBUTES [ATTRIBUTES ...], --attributes ATTRIBUTES [ATTRIBUTES ...]