mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-24 09:46:54 +00:00
typing
This commit is contained in:
@@ -20,6 +20,9 @@ import bpy
|
||||
import ifcopenshell
|
||||
import ifcopenshell.api
|
||||
import ifcopenshell.api.aggregate
|
||||
import ifcopenshell.api.feature
|
||||
import ifcopenshell.api.group
|
||||
import ifcopenshell.api.spatial
|
||||
import ifcopenshell.util.element
|
||||
import bonsai.core.tool
|
||||
import bonsai.tool as tool
|
||||
@@ -34,6 +37,7 @@ class TestImplementsTool(NewFile):
|
||||
|
||||
class TestAssign(NewIfc):
|
||||
def test_walls_are_placed_in_its_spatial_collection(self):
|
||||
assert bpy.context.scene
|
||||
wall_obj = bpy.data.objects.new("Object", None)
|
||||
wall_element = tool.Ifc.get().createIfcWall()
|
||||
tool.Ifc.link(wall_element, wall_obj)
|
||||
@@ -48,6 +52,7 @@ class TestAssign(NewIfc):
|
||||
assert "IfcSite" in wall_obj.users_collection[0].name
|
||||
|
||||
def test_walls_are_unsorted_if_not_decomposes(self):
|
||||
assert bpy.context.scene
|
||||
wall_obj = bpy.data.objects.new("Object", None)
|
||||
wall_element = tool.Ifc.get().createIfcWall()
|
||||
tool.Ifc.link(wall_element, wall_obj)
|
||||
@@ -57,6 +62,7 @@ class TestAssign(NewIfc):
|
||||
assert "Unsorted" in wall_obj.users_collection[0].name
|
||||
|
||||
def test_spatial_structure_elements_are_placed_in_a_collection_of_the_same_name(self):
|
||||
assert bpy.context.scene
|
||||
building_obj = bpy.data.objects.new("IfcBuilding/Name", None)
|
||||
building_element = tool.Ifc.get().createIfcBuilding()
|
||||
tool.Ifc.link(building_element, building_obj)
|
||||
@@ -71,6 +77,7 @@ class TestAssign(NewIfc):
|
||||
assert building_obj.users_collection[0].name == building_obj.name
|
||||
|
||||
def test_spaces_are_special_and_are_placed_in_a_spaces_collection(self):
|
||||
assert bpy.context.scene
|
||||
space_obj = bpy.data.objects.new("IfcSpace/Name", None)
|
||||
space_element = tool.Ifc.get().createIfcSpace()
|
||||
tool.Ifc.link(space_element, space_obj)
|
||||
@@ -85,6 +92,7 @@ class TestAssign(NewIfc):
|
||||
assert space_obj.users_collection[0].name == "IfcSpace"
|
||||
|
||||
def test_multiple_assigns_do_not_create_duplicate_spatial_structure_collections(self):
|
||||
assert bpy.context.scene
|
||||
space_obj = bpy.data.objects.new("IfcSpace/Name", None)
|
||||
space_element = tool.Ifc.get().createIfcSpace()
|
||||
tool.Ifc.link(space_element, space_obj)
|
||||
@@ -102,6 +110,7 @@ class TestAssign(NewIfc):
|
||||
assert not bpy.data.collections.get("IfcSite/My Site.001")
|
||||
|
||||
def test_spatial_zone_elements_are_not_placed_in_a_collection_of_the_same_name(self):
|
||||
assert bpy.context.scene
|
||||
space_obj = bpy.data.objects.new("IfcSpaceZone/Name", None)
|
||||
space_element = tool.Ifc.get().createIfcSpatialZone()
|
||||
tool.Ifc.link(space_element, space_obj)
|
||||
@@ -116,6 +125,7 @@ class TestAssign(NewIfc):
|
||||
assert space_obj.users_collection[0].name != space_obj.name
|
||||
|
||||
def test_aggregates_are_also_placed_in_their_container(self):
|
||||
assert bpy.context.scene
|
||||
element_obj = bpy.data.objects.new("IfcElementAssembly/Name", None)
|
||||
element = tool.Ifc.get().createIfcElementAssembly()
|
||||
subelement_obj = bpy.data.objects.new("IfcBeam/Name", None)
|
||||
@@ -142,6 +152,7 @@ class TestAssign(NewIfc):
|
||||
assert "IfcSite" in subelement_obj.users_collection[0].name
|
||||
|
||||
def test_projects_are_placed_in_a_collection_of_the_same_name(self):
|
||||
assert bpy.context.scene
|
||||
tool.Ifc.set(ifcopenshell.file())
|
||||
element_obj = bpy.data.objects.new("IfcProject/Name", None)
|
||||
element = tool.Ifc.get().createIfcProject()
|
||||
@@ -152,6 +163,7 @@ class TestAssign(NewIfc):
|
||||
assert element_obj.users_collection[0].name == element_obj.name
|
||||
|
||||
def test_multiple_assigns_do_not_create_duplicate_collections(self):
|
||||
assert bpy.context.scene
|
||||
tool.Ifc.set(ifcopenshell.file())
|
||||
element_obj = bpy.data.objects.new("IfcProject/Name", None)
|
||||
element = tool.Ifc.get().createIfcProject()
|
||||
@@ -163,6 +175,7 @@ class TestAssign(NewIfc):
|
||||
assert not bpy.data.collections.get("IfcProject/Name.001")
|
||||
|
||||
def test_own_collections_are_retained_and_name_synced(self):
|
||||
assert bpy.context.scene
|
||||
building_obj = bpy.data.objects.new("IfcBuilding/Name", None)
|
||||
building_element = tool.Ifc.get().createIfcBuilding()
|
||||
tool.Ifc.link(building_element, building_obj)
|
||||
@@ -178,22 +191,24 @@ class TestAssign(NewIfc):
|
||||
)
|
||||
subject.assign(building_obj)
|
||||
assert bpy.context.scene.collection.children.find(building_collection.name) != -1
|
||||
assert bpy.data.collections.get("IfcSite/My Site").children.find(building_collection.name) == -1
|
||||
assert bpy.data.collections.get("IfcProject/My Project").children.find(building_collection.name) == -1
|
||||
assert bpy.data.collections["IfcSite/My Site"].children.find(building_collection.name) == -1
|
||||
assert bpy.data.collections["IfcProject/My Project"].children.find(building_collection.name) == -1
|
||||
assert bpy.context.scene.collection.children.find(building_collection.name) != -1
|
||||
assert building_collection.objects.find(building_obj.name) != -1
|
||||
assert building_collection.name == "IfcBuilding/Name"
|
||||
|
||||
def test_types_are_placed_in_the_types_collection(self):
|
||||
assert bpy.context.scene
|
||||
element_obj = bpy.data.objects.new("IfcWallType/Name", None)
|
||||
element = tool.Ifc.get().createIfcWallType()
|
||||
tool.Ifc.link(element, element_obj)
|
||||
bpy.context.scene.collection.objects.link(element_obj)
|
||||
subject.assign(element_obj)
|
||||
assert element_obj.users_collection[0].name == "IfcTypeProduct"
|
||||
assert bpy.data.collections.get("IfcProject/My Project").children.get("IfcTypeProduct")
|
||||
assert bpy.data.collections["IfcProject/My Project"].children.get("IfcTypeProduct")
|
||||
|
||||
def test_openings_are_placed_in_their_voided_elements_container(self):
|
||||
assert bpy.context.scene
|
||||
element_obj = bpy.data.objects.new("IfcOpeningElement/Name", None)
|
||||
element = tool.Ifc.get().createIfcOpeningElement()
|
||||
tool.Ifc.link(element, element_obj)
|
||||
@@ -210,6 +225,7 @@ class TestAssign(NewIfc):
|
||||
assert element_obj.users_collection[0].name == "IfcSite/My Site"
|
||||
|
||||
def test_grids_are_placed_in_their_container(self):
|
||||
assert bpy.context.scene
|
||||
element_obj = bpy.data.objects.new("IfcGrid/Name", None)
|
||||
element = tool.Ifc.get().createIfcGrid()
|
||||
tool.Ifc.link(element, element_obj)
|
||||
@@ -223,6 +239,7 @@ class TestAssign(NewIfc):
|
||||
assert element_obj.users_collection[0].name == "IfcSite/My Site"
|
||||
|
||||
def test_grids_axes_are_placed_in_the_grids_container(self):
|
||||
assert bpy.context.scene
|
||||
element_obj = bpy.data.objects.new("IfcGrid/Name", None)
|
||||
axis_obj = bpy.data.objects.new("IfcGrid/Name", None)
|
||||
axis = tool.Ifc.get().createIfcGridAxis()
|
||||
@@ -250,7 +267,7 @@ class TestAssign(NewIfc):
|
||||
|
||||
subject.assign(element_obj)
|
||||
assert element_obj.users_collection[0].name == "IfcAnnotation/DRAWING"
|
||||
assert bpy.data.collections.get("IfcProject/My Project").children.get("IfcAnnotation/DRAWING")
|
||||
assert bpy.data.collections["IfcProject/My Project"].children.get("IfcAnnotation/DRAWING")
|
||||
|
||||
def test_annotations_are_placed_in_their_drawings_collection(self):
|
||||
self.test_drawings_are_placed_in_their_own_collection()
|
||||
@@ -272,7 +289,7 @@ class TestAssign(NewIfc):
|
||||
tool.Ifc.link(element, element_obj)
|
||||
subject.assign(element_obj)
|
||||
assert element_obj.users_collection[0].name == "IfcStructuralItem"
|
||||
assert bpy.data.collections.get("IfcProject/My Project").children.get("IfcStructuralItem")
|
||||
assert bpy.data.collections["IfcProject/My Project"].children.get("IfcStructuralItem")
|
||||
|
||||
def test_structural_connections_are_placed_in_a_connections_collection(self):
|
||||
element_obj = bpy.data.objects.new("IfcStructuralCurveConnection/Name", None)
|
||||
@@ -280,7 +297,7 @@ class TestAssign(NewIfc):
|
||||
tool.Ifc.link(element, element_obj)
|
||||
subject.assign(element_obj)
|
||||
assert element_obj.users_collection[0].name == "IfcStructuralItem"
|
||||
assert bpy.data.collections.get("IfcProject/My Project").children.get("IfcStructuralItem")
|
||||
assert bpy.data.collections["IfcProject/My Project"].children.get("IfcStructuralItem")
|
||||
|
||||
|
||||
class TestAssignIFC4X3(NewIfc4X3):
|
||||
@@ -290,7 +307,7 @@ class TestAssignIFC4X3(NewIfc4X3):
|
||||
tool.Ifc.link(element, element_obj)
|
||||
subject.assign(element_obj)
|
||||
assert element_obj.users_collection[0].name == "IfcLinearPositioningElement"
|
||||
assert bpy.data.collections.get("IfcProject/My Project").children.get("IfcLinearPositioningElement")
|
||||
assert bpy.data.collections["IfcProject/My Project"].children.get("IfcLinearPositioningElement")
|
||||
|
||||
def test_referents_are_placed_in_a_special_collection(self):
|
||||
element_obj = bpy.data.objects.new("Name", None)
|
||||
@@ -298,4 +315,4 @@ class TestAssignIFC4X3(NewIfc4X3):
|
||||
tool.Ifc.link(element, element_obj)
|
||||
subject.assign(element_obj)
|
||||
assert element_obj.users_collection[0].name == "IfcReferent"
|
||||
assert bpy.data.collections.get("IfcProject/My Project").children.get("IfcReferent")
|
||||
assert bpy.data.collections["IfcProject/My Project"].children.get("IfcReferent")
|
||||
|
||||
Reference in New Issue
Block a user