mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-10 06:00:51 +00:00
typing
This commit is contained in:
@@ -19,6 +19,7 @@
|
||||
import bpy
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.aggregate
|
||||
import ifcopenshell.util.element
|
||||
import bonsai.core.tool
|
||||
import bonsai.tool as tool
|
||||
@@ -167,7 +168,8 @@ class TestAssign(NewIfc):
|
||||
tool.Ifc.link(building_element, building_obj)
|
||||
building_collection = bpy.data.collections.new("Foobar")
|
||||
bpy.context.scene.collection.children.link(building_collection)
|
||||
building_obj.BIMObjectProperties.collection = building_collection
|
||||
props = tool.Blender.get_object_bim_props(building_obj)
|
||||
props.collection = building_collection
|
||||
building_collection.objects.link(building_obj)
|
||||
ifcopenshell.api.aggregate.assign_object(
|
||||
tool.Ifc.get(),
|
||||
|
||||
@@ -319,7 +319,8 @@ class TestGetDrawingCollection(NewFile):
|
||||
collection = bpy.data.collections.new("Collection")
|
||||
bpy.context.scene.collection.children.link(collection)
|
||||
collection.objects.link(obj)
|
||||
obj.BIMObjectProperties.collection = collection
|
||||
props = tool.Blender.get_object_bim_props(obj)
|
||||
props.collection = collection
|
||||
collection.BIMCollectionProperties.obj = obj
|
||||
|
||||
element = ifc.createIfcAnnotation()
|
||||
|
||||
@@ -170,22 +170,25 @@ class TestGetTextLiteral(NewFile):
|
||||
class TestGetCartesianPointCoordinateOffset(NewFile):
|
||||
def test_run(self):
|
||||
obj = bpy.data.objects.new("Object", None)
|
||||
obj.BIMObjectProperties.blender_offset_type = "CARTESIAN_POINT"
|
||||
oprops = tool.Blender.get_object_bim_props(obj)
|
||||
oprops.blender_offset_type = "CARTESIAN_POINT"
|
||||
props = tool.Georeference.get_georeference_props()
|
||||
props.has_blender_offset = True
|
||||
obj.BIMObjectProperties.cartesian_point_offset = "1,2,3"
|
||||
oprops.cartesian_point_offset = "1,2,3"
|
||||
assert np.allclose(subject.get_cartesian_point_offset(obj), np.array((1.0, 2.0, 3.0)))
|
||||
|
||||
def test_get_null_if_not_a_cartesian_point_offset_type(self):
|
||||
obj = bpy.data.objects.new("Object", None)
|
||||
props = tool.Georeference.get_georeference_props()
|
||||
props.has_blender_offset = True
|
||||
obj.BIMObjectProperties.cartesian_point_offset = "1,2,3"
|
||||
oprops = tool.Blender.get_object_bim_props(obj)
|
||||
oprops.cartesian_point_offset = "1,2,3"
|
||||
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"
|
||||
oprops = tool.Blender.get_object_bim_props(obj)
|
||||
oprops.blender_offset_type = "CARTESIAN_POINT"
|
||||
props = tool.Georeference.get_georeference_props()
|
||||
props.has_blender_offset = False
|
||||
assert subject.get_cartesian_point_offset(obj) is None
|
||||
@@ -307,15 +310,16 @@ class TestRecordObjectMaterials(NewFile):
|
||||
material.BIMStyleProperties.ifc_definition_id = style.id()
|
||||
obj.data.materials.append(material)
|
||||
subject.record_object_materials(obj)
|
||||
assert tool.Geometry.get_mesh_props(obj).material_checksum == str([style.id()])
|
||||
assert tool.Geometry.get_mesh_props(obj.data).material_checksum == str([style.id()])
|
||||
|
||||
|
||||
class TestRecordObjectPosition(NewFile):
|
||||
def test_run(self):
|
||||
obj = bpy.data.objects.new("Object", None)
|
||||
props = tool.Blender.get_object_bim_props(obj)
|
||||
subject.record_object_position(obj)
|
||||
assert obj.BIMObjectProperties.location_checksum == repr(np.array(obj.matrix_world.translation).tobytes())
|
||||
assert obj.BIMObjectProperties.rotation_checksum == repr(np.array(obj.matrix_world.to_3x3()).tobytes())
|
||||
assert props.location_checksum == repr(np.array(obj.matrix_world.translation).tobytes())
|
||||
assert props.rotation_checksum == repr(np.array(obj.matrix_world.to_3x3()).tobytes())
|
||||
|
||||
|
||||
class TestRemoveConnection(NewFile):
|
||||
|
||||
@@ -129,14 +129,16 @@ class TestGetEntity(test.bim.bootstrap.NewFile):
|
||||
|
||||
def test_attempting_without_a_file(self):
|
||||
obj = bpy.data.objects.new("Object", None)
|
||||
obj.BIMObjectProperties.ifc_definition_id = 1
|
||||
props = tool.Blender.get_object_bim_props(obj)
|
||||
props.ifc_definition_id = 1
|
||||
assert subject.get_entity(obj) is None
|
||||
|
||||
def test_attempting_to_get_an_invalidly_linked_object(self):
|
||||
ifc = ifcopenshell.file()
|
||||
subject.set(ifc)
|
||||
obj = bpy.data.objects.new("Object", None)
|
||||
obj.BIMObjectProperties.ifc_definition_id = 1
|
||||
props = tool.Blender.get_object_bim_props(obj)
|
||||
props.ifc_definition_id = 1
|
||||
assert subject.get_entity(obj) is None
|
||||
|
||||
|
||||
|
||||
@@ -383,23 +383,26 @@ class TestUsingArrays(NewFile):
|
||||
|
||||
bpy.ops.mesh.primitive_cube_add()
|
||||
obj = bpy.context.active_object
|
||||
assert obj
|
||||
rprops = tool.Root.get_root_props()
|
||||
rprops.ifc_product = "IfcElement"
|
||||
bpy.ops.bim.assign_class(ifc_class="IfcActuator", predefined_type="ELECTRICACTUATOR", userdefined_type="")
|
||||
|
||||
bpy.ops.bim.add_array()
|
||||
bpy.ops.bim.enable_editing_array(item=0)
|
||||
obj.BIMArrayProperties.count = 4
|
||||
obj.BIMArrayProperties.x = 4
|
||||
obj.BIMArrayProperties.sync_children = sync_children
|
||||
props = tool.Model.get_array_props(obj)
|
||||
props.count = 4
|
||||
props.x = 4
|
||||
props.sync_children = sync_children
|
||||
bpy.ops.bim.edit_array(item=0)
|
||||
|
||||
if add_second_layer:
|
||||
bpy.ops.bim.add_array()
|
||||
bpy.ops.bim.enable_editing_array(item=1)
|
||||
obj.BIMArrayProperties.count = 3
|
||||
obj.BIMArrayProperties.y = 4
|
||||
obj.BIMArrayProperties.sync_children = sync_children
|
||||
props = tool.Model.get_array_props(obj)
|
||||
props.count = 3
|
||||
props.y = 4
|
||||
props.sync_children = sync_children
|
||||
bpy.ops.bim.edit_array(item=1)
|
||||
|
||||
def test_remove_array_last_to_first(self):
|
||||
|
||||
@@ -54,6 +54,7 @@ class TestGetGlobalMatrix(test.bim.bootstrap.NewFile):
|
||||
props.blender_x_axis_abscissa = "0"
|
||||
props.blender_x_axis_ordinate = "1"
|
||||
obj = bpy.data.objects.new("Object", None)
|
||||
obj.BIMObjectProperties.blender_offset_type = "OBJECT_PLACEMENT"
|
||||
props = tool.Blender.get_object_bim_props(obj)
|
||||
props.blender_offset_type = "OBJECT_PLACEMENT"
|
||||
matrix = ifcopenshell.util.geolocation.local2global(np.array(obj.matrix_world), 1.0, 2.0, 3.0, 0.0, 1.0)
|
||||
assert (subject.get_absolute_matrix(obj) == matrix).all()
|
||||
|
||||
@@ -240,7 +240,7 @@ class TestImportUnitAttributes(NewFile):
|
||||
assert props.unit_attributes["UnitType"].enum_value == "ABSORBEDDOSEUNIT"
|
||||
assert props.unit_attributes["Prefix"].enum_value == "EXA"
|
||||
assert props.unit_attributes["Name"].enum_value == "AMPERE"
|
||||
assert props.unit_attributes["Dimensions"] is None
|
||||
assert "Dimensions" not in props.unit_attributes
|
||||
|
||||
|
||||
class TestImportUnits(NewFile):
|
||||
|
||||
Reference in New Issue
Block a user