From e1fc7cad44ba92b8ee7b2b81a5f9a5200fc43266 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Mon, 3 Apr 2023 17:42:33 +0500 Subject: [PATCH] Fixed all unit.add_si_unit uses after fd87747 Now they were causing `TypeError: Usecase.__init__() got an unexpected keyword argument 'name'` --- src/blenderbim/scripts/generate_au_library.py | 2 +- .../scripts/generate_furniture_library.py | 3 +-- .../generate_steel_profiles_library.py | 2 +- .../scripts/shape_builder_examples.py | 5 ++-- src/ifc4d/ifc4d/csv2ifc.py | 2 +- src/ifcsverchok/nodes/ifc/create_project.py | 3 +-- src/ifctester/test/test_facet.py | 25 +++++++++++-------- 7 files changed, 22 insertions(+), 20 deletions(-) diff --git a/src/blenderbim/scripts/generate_au_library.py b/src/blenderbim/scripts/generate_au_library.py index 14f3cf0beb..e1895fb44b 100644 --- a/src/blenderbim/scripts/generate_au_library.py +++ b/src/blenderbim/scripts/generate_au_library.py @@ -42,7 +42,7 @@ class LibraryGenerator: ifcopenshell.api.run( "project.assign_declaration", self.file, definition=self.library, relating_context=self.project ) - unit = ifcopenshell.api.run("unit.add_si_unit", self.file, unit_type="LENGTHUNIT", name="METRE", prefix="MILLI") + unit = ifcopenshell.api.run("unit.add_si_unit", self.file, unit_type="LENGTHUNIT", prefix="MILLI") ifcopenshell.api.run("unit.assign_unit", self.file, units=[unit]) model = ifcopenshell.api.run("context.add_context", self.file, context_type="Model") diff --git a/src/blenderbim/scripts/generate_furniture_library.py b/src/blenderbim/scripts/generate_furniture_library.py index 64dbdf37bb..605ce2a2c4 100644 --- a/src/blenderbim/scripts/generate_furniture_library.py +++ b/src/blenderbim/scripts/generate_furniture_library.py @@ -56,7 +56,6 @@ def get_simple_2dcurve_data(coords, fillets=[], fillet_radius=[], closed=True, i for co_i, co in enumerate(coords, 0): current_point = len(points) if co_i in fillets: - r = fillets[co_i] rsb = r * cos(pi / 4) # radius shift big rss = r - rsb # radius shift small @@ -230,7 +229,7 @@ class LibraryGenerator: ifcopenshell.api.run( "project.assign_declaration", self.file, definition=self.library, relating_context=self.project ) - unit = ifcopenshell.api.run("unit.add_si_unit", self.file, unit_type="LENGTHUNIT", name="METRE", prefix="MILLI") + unit = ifcopenshell.api.run("unit.add_si_unit", self.file, unit_type="LENGTHUNIT", prefix="MILLI") ifcopenshell.api.run("unit.assign_unit", self.file, units=[unit]) model = ifcopenshell.api.run("context.add_context", self.file, context_type="Model") diff --git a/src/blenderbim/scripts/generate_steel_profiles_library.py b/src/blenderbim/scripts/generate_steel_profiles_library.py index c192eb3a74..784d6da78c 100644 --- a/src/blenderbim/scripts/generate_steel_profiles_library.py +++ b/src/blenderbim/scripts/generate_steel_profiles_library.py @@ -152,7 +152,7 @@ class LibraryGenerator: ifcopenshell.api.run( "project.assign_declaration", self.file, definition=self.library, relating_context=self.project ) - unit = ifcopenshell.api.run("unit.add_si_unit", self.file, unit_type="LENGTHUNIT", name="METRE", prefix="MILLI") + unit = ifcopenshell.api.run("unit.add_si_unit", self.file, unit_type="LENGTHUNIT", prefix="MILLI") ifcopenshell.api.run("unit.assign_unit", self.file, units=[unit]) model = ifcopenshell.api.run("context.add_context", self.file, context_type="Model") diff --git a/src/blenderbim/scripts/shape_builder_examples.py b/src/blenderbim/scripts/shape_builder_examples.py index fd4ad612c6..f8ba737e74 100644 --- a/src/blenderbim/scripts/shape_builder_examples.py +++ b/src/blenderbim/scripts/shape_builder_examples.py @@ -4,6 +4,7 @@ from mathutils import Vector V = lambda *x: Vector([float(i) for i in x]) + # TODO: move examples to more suitable place def simple_uses(): ifc_file = ifcopenshell.file() @@ -91,7 +92,7 @@ def mirror_placement_test(): "root.create_entity", ifc_file, ifc_class="IfcProjectLibrary", name=f"Non-structural assets library" ) ifcopenshell.api.run("project.assign_declaration", ifc_file, definition=library, relating_context=project) - unit = ifcopenshell.api.run("unit.add_si_unit", ifc_file, unit_type="LENGTHUNIT", name="METRE", prefix="MILLI") + unit = ifcopenshell.api.run("unit.add_si_unit", ifc_file, unit_type="LENGTHUNIT", prefix="MILLI") ifcopenshell.api.run("unit.assign_unit", ifc_file, units=[unit]) model = ifcopenshell.api.run("context.add_context", ifc_file, context_type="Model") plan = ifcopenshell.api.run("context.add_context", ifc_file, context_type="Plan") @@ -165,7 +166,7 @@ def curve_between_two_points_test(): "root.create_entity", ifc_file, ifc_class="IfcProjectLibrary", name=f"Non-structural assets library" ) ifcopenshell.api.run("project.assign_declaration", ifc_file, definition=library, relating_context=project) - unit = ifcopenshell.api.run("unit.add_si_unit", ifc_file, unit_type="LENGTHUNIT", name="METRE", prefix="MILLI") + unit = ifcopenshell.api.run("unit.add_si_unit", ifc_file, unit_type="LENGTHUNIT", prefix="MILLI") ifcopenshell.api.run("unit.assign_unit", ifc_file, units=[unit]) model = ifcopenshell.api.run("context.add_context", ifc_file, context_type="Model") plan = ifcopenshell.api.run("context.add_context", ifc_file, context_type="Plan") diff --git a/src/ifc4d/ifc4d/csv2ifc.py b/src/ifc4d/ifc4d/csv2ifc.py index 108453b3e7..7ef6a8b6d8 100644 --- a/src/ifc4d/ifc4d/csv2ifc.py +++ b/src/ifc4d/ifc4d/csv2ifc.py @@ -138,7 +138,7 @@ class Csv2Ifc: if unit: return unit else: - unit = ifcopenshell.api.run("unit.add_si_unit", self.file, unit_type=unit_type, name=ifcopenshell.util.unit.si_type_names.get(unit_type, None)) + unit = ifcopenshell.api.run("unit.add_si_unit", self.file, unit_type=unit_type) # unit = self.file.createIfcContextDependentUnit( # self.file.createIfcDimensionalExponents(0, 0, 0, 0, 0, 0, 0), "USERDEFINED", symbol # ) diff --git a/src/ifcsverchok/nodes/ifc/create_project.py b/src/ifcsverchok/nodes/ifc/create_project.py index b2db663c5d..e2b9bf3750 100644 --- a/src/ifcsverchok/nodes/ifc/create_project.py +++ b/src/ifcsverchok/nodes/ifc/create_project.py @@ -52,10 +52,9 @@ class SvIfcCreateProject(bpy.types.Node, SverchCustomTreeNode, ifcsverchok.helpe self.process_ifc(file, project_name) def process_ifc(self, file, project_name): - # create project project = ifcopenshell.api.run("root.create_entity", file, ifc_class="IfcProject", name=str(project_name)) - lengthunit = ifcopenshell.api.run("unit.add_si_unit", file, unit_type="LENGTHUNIT", name="METRE") + lengthunit = ifcopenshell.api.run("unit.add_si_unit", file, unit_type="LENGTHUNIT") ifcopenshell.api.run("unit.assign_unit", file, units=[lengthunit]) model = ifcopenshell.api.run("context.add_context", file, context_type="Model") context = ifcopenshell.api.run( diff --git a/src/ifctester/test/test_facet.py b/src/ifctester/test/test_facet.py index 4cde46fb14..a668a2aae8 100644 --- a/src/ifctester/test/test_facet.py +++ b/src/ifctester/test/test_facet.py @@ -652,7 +652,7 @@ class TestAttribute: expected=True, ) - restriction = Restriction(options={"minInclusive": 42, "maxInclusive": 42}, base="decimal") + restriction = Restriction(options={"minInclusive": 42, "maxInclusive": 42}, base="decimal") facet = Attribute(name="RefractionIndex", value=restriction) ifc = ifcopenshell.file() run( @@ -1231,14 +1231,10 @@ class TestProperty: ifc = ifcopenshell.file() ifc.createIfcProject() # Milli prefix used to check measurement conversions - lengthunit = ifcopenshell.api.run("unit.add_si_unit", ifc, unit_type="LENGTHUNIT", name="METRE", prefix="MILLI") - areaunit = ifcopenshell.api.run( - "unit.add_si_unit", ifc, unit_type="AREAUNIT", name="SQUARE_METRE", prefix="MILLI" - ) - volumeunit = ifcopenshell.api.run( - "unit.add_si_unit", ifc, unit_type="VOLUMEUNIT", name="CUBIC_METRE", prefix="MILLI" - ) - timeunit = ifcopenshell.api.run("unit.add_si_unit", ifc, unit_type="TIMEUNIT", name="SECOND") + lengthunit = ifcopenshell.api.run("unit.add_si_unit", ifc, unit_type="LENGTHUNIT", prefix="MILLI") + areaunit = ifcopenshell.api.run("unit.add_si_unit", ifc, unit_type="AREAUNIT", prefix="MILLI") + volumeunit = ifcopenshell.api.run("unit.add_si_unit", ifc, unit_type="VOLUMEUNIT", prefix="MILLI") + timeunit = ifcopenshell.api.run("unit.add_si_unit", ifc, unit_type="TIMEUNIT") ifcopenshell.api.run("unit.assign_unit", ifc, units=[lengthunit, areaunit, volumeunit, timeunit]) return ifc @@ -1455,9 +1451,16 @@ class TestPartOf: element.PredefinedType = "BASESLAB" facet = PartOf(entity="IFCSLAB", predefinedType="BASESLAB", relation="IfcRelAggregates") - run("An aggregate may specify the predefined type of the whole 1/2", facet=facet, inst=subelement, expected=True) + run( + "An aggregate may specify the predefined type of the whole 1/2", facet=facet, inst=subelement, expected=True + ) facet = PartOf(entity="IFCSLAB", predefinedType="SLABRADOR", relation="IfcRelAggregates") - run("An aggregate may specify the predefined type of the whole 2/2", facet=facet, inst=subelement, expected=False) + run( + "An aggregate may specify the predefined type of the whole 2/2", + facet=facet, + inst=subelement, + expected=False, + ) ifc = ifcopenshell.file() element = ifcopenshell.api.run("root.create_entity", ifc, ifc_class="IfcElementAssembly")