Fix failing unit/system/geometry tool tests. Fix regression where object scales weren't applied in the new add element approach.

This commit is contained in:
Dion Moult
2025-02-05 18:50:37 +11:00
parent 590c2e120c
commit f457ce8270
6 changed files with 32 additions and 54 deletions
+3 -30
View File
@@ -174,21 +174,21 @@ class TestGetCartesianPointCoordinateOffset(NewFile):
props = bpy.context.scene.BIMGeoreferenceProperties
props.has_blender_offset = True
obj.BIMObjectProperties.cartesian_point_offset = "1,2,3"
assert subject.get_cartesian_point_coordinate_offset(obj) == Vector((1.0, 2.0, 3.0))
assert np.allclose(subject.get_cartesian_point_offset(obj), np.array((1., 2., 3.)))
def test_get_null_if_not_a_cartesian_point_offset_type(self):
obj = bpy.data.objects.new("Object", None)
props = bpy.context.scene.BIMGeoreferenceProperties
props.has_blender_offset = True
obj.BIMObjectProperties.cartesian_point_offset = "1,2,3"
assert subject.get_cartesian_point_coordinate_offset(obj) is None
assert subject.get_cartesian_point_offset(obj) is None
def test_get_null_if_no_blender_offset(self):
obj = bpy.data.objects.new("Object", None)
obj.BIMObjectProperties.blender_offset_type = "CARTESIAN_POINT"
props = bpy.context.scene.BIMGeoreferenceProperties
props.has_blender_offset = False
assert subject.get_cartesian_point_coordinate_offset(obj) is None
assert subject.get_cartesian_point_offset(obj) is None
class TestGetElementType(NewFile):
@@ -229,33 +229,6 @@ class TestHasDataUsers(NewFile):
assert subject.has_data_users(data) is True
class TestImportRepresentation(NewFile):
def test_importing_a_normal_shape(self):
ifc = ifcopenshell.open("test/files/basic.ifc")
tool.Ifc.set(ifc)
obj = bpy.data.objects.new("Object", bpy.data.meshes.new("Mesh"))
material = bpy.data.materials.new("Material")
material.BIMStyleProperties.ifc_definition_id = 101
element = ifc.by_type("IfcWall")[0]
tool.Ifc.link(element, obj)
representation = element.Representation.Representations[1]
mesh = subject.import_representation(obj, representation)
assert isinstance(mesh, bpy.types.Mesh)
assert len(mesh.polygons) == 12
assert mesh.materials[0] == material
def test_importing_non_body_curves(self):
ifc = ifcopenshell.open("test/files/annotation.ifc")
tool.Ifc.set(ifc)
obj = bpy.data.objects.new("Object", bpy.data.meshes.new("Mesh"))
element = ifc.by_type("IfcWall")[0]
tool.Ifc.link(element, obj)
representation = element.Representation.Representations[0]
mesh = subject.import_representation(obj, representation)
assert len(mesh.polygons) == 0
assert len(mesh.edges) == 4
class TestImportRepresentationParameters(NewFile):
def test_run(self):
ifc = ifcopenshell.file()
+1 -1
View File
@@ -52,7 +52,7 @@ class TestAddPorts(NewFile):
for port, expected_matrix in zip(ports, expected_matrices, strict=True):
port_matrix = tool.Model.get_element_matrix(port)
port_matrix.translation *= si_conversion
assert np.allclose(port_matrix, expected_matrix, atol=1.0e-5)
assert np.allclose(port_matrix, expected_matrix, atol=1.0e-5), f"Matrix does not match:\n{port_matrix}\n{expected_matrix}"
def test_run(self):
# default use
+3 -2
View File
@@ -237,7 +237,7 @@ class TestImportUnitAttributes(NewFile):
class TestImportUnits(NewFile):
def test_importing_multiple_units(self):
ifc = ifcopenshell.file()
ifc = ifcopenshell.api.project.create_file()
tool.Ifc.set(ifc)
unit1 = ifc.createIfcDerivedUnit(UnitType="ANGULARVELOCITYUNIT")
unit2 = ifc.createIfcMonetaryUnit(Currency="Currency")
@@ -245,7 +245,8 @@ class TestImportUnits(NewFile):
unit4 = ifc.createIfcConversionBasedUnit(Name="Name", UnitType="ABSORBEDDOSEUNIT")
unit5 = ifc.createIfcSIUnit(Name="AMPERE", Prefix="MILLI", UnitType="ABSORBEDDOSEUNIT")
unit6 = ifc.createIfcSIUnit(Name="CUBIC_METRE", Prefix="CENTI", UnitType="ABSORBEDDOSEUNIT")
ifc.createIfcUnitAssignment(Units=[unit2])
ifcopenshell.api.root.create_entity(ifc, ifc_class="IfcProject")
ifcopenshell.api.unit.assign_unit(ifc, units=[unit2])
subject.import_units()
props = bpy.context.scene.BIMUnitProperties
assert len(props.units) == 6