Ejemplo n.º 1
0
 def test_in_decomposition_mode_walls_are_placed_in_the_project_if_not_decomposes(
         self):
     bpy.ops.bim.create_project()
     wall_obj = bpy.data.objects.new("Object", None)
     wall_element = tool.Ifc.get().createIfcWall()
     tool.Ifc.link(wall_element, wall_obj)
     bpy.context.scene.collection.objects.link(wall_obj)
     subject.assign(wall_obj)
     assert len(wall_obj.users_collection) == 1
     assert "IfcProject" in wall_obj.users_collection[0].name
Ejemplo n.º 2
0
 def test_in_decomposition_mode_projects_are_placed_in_a_collection_of_the_same_name(
         self):
     tool.Ifc.set(ifcopenshell.file())
     element_obj = bpy.data.objects.new("IfcProject/Name", None)
     element = tool.Ifc.get().createIfcProject()
     tool.Ifc.link(element, element_obj)
     bpy.context.scene.collection.objects.link(element_obj)
     subject.assign(element_obj)
     assert len(element_obj.users_collection) == 1
     assert element_obj.users_collection[0].name == element_obj.name
Ejemplo n.º 3
0
 def test_in_decomposition_mode_openings_are_placed_in_the_openings_collection(
         self):
     bpy.ops.bim.create_project()
     element_obj = bpy.data.objects.new("IfcOpeningElement/Name", None)
     element = tool.Ifc.get().createIfcOpeningElement()
     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 == "IfcOpeningElements"
     assert bpy.data.collections.get("IfcProject/My Project").children.get(
         "IfcOpeningElements")
Ejemplo n.º 4
0
 def test_in_decomposition_mode_structural_connections_are_placed_in_a_connections_collection(
         self):
     bpy.ops.bim.create_project()
     element_obj = bpy.data.objects.new("IfcStructuralCurveConnection/Name",
                                        None)
     element = tool.Ifc.get().createIfcStructuralCurveConnection()
     tool.Ifc.link(element, element_obj)
     subject.assign(element_obj)
     assert element_obj.users_collection[0].name == "Connections"
     assert bpy.data.collections.get("StructuralItems").children.get(
         "Connections")
     assert bpy.data.collections.get("IfcProject/My Project").children.get(
         "StructuralItems")
Ejemplo n.º 5
0
 def test_in_decomposition_mode_spatial_elements_are_placed_in_a_collection_of_the_same_name(
         self):
     bpy.ops.bim.create_project()
     space_obj = bpy.data.objects.new("IfcSpace/Name", None)
     space_element = tool.Ifc.get().createIfcSpace()
     tool.Ifc.link(space_element, space_obj)
     bpy.context.scene.collection.objects.link(space_obj)
     ifcopenshell.api.run(
         "aggregate.assign_object",
         tool.Ifc.get(),
         relating_object=tool.Ifc.get().by_type("IfcSite")[0],
         product=space_element,
     )
     subject.assign(space_obj)
     assert len(space_obj.users_collection) == 1
     assert space_obj.users_collection[0].name == space_obj.name
Ejemplo n.º 6
0
 def test_in_decomposition_mode_walls_are_placed_in_its_spatial_collection(
         self):
     bpy.ops.bim.create_project()
     wall_obj = bpy.data.objects.new("Object", None)
     wall_element = tool.Ifc.get().createIfcWall()
     tool.Ifc.link(wall_element, wall_obj)
     bpy.context.scene.collection.objects.link(wall_obj)
     ifcopenshell.api.run(
         "spatial.assign_container",
         tool.Ifc.get(),
         product=wall_element,
         relating_structure=tool.Ifc.get().by_type("IfcSite")[0],
     )
     subject.assign(wall_obj)
     assert len(wall_obj.users_collection) == 1
     assert "IfcSite" in wall_obj.users_collection[0].name
Ejemplo n.º 7
0
 def test_in_decomposition_mode_grids_are_placed_in_their_own_collection(
         self):
     bpy.ops.bim.create_project()
     element_obj = bpy.data.objects.new("IfcGrid/Name", None)
     element = tool.Ifc.get().createIfcGrid()
     tool.Ifc.link(element, element_obj)
     ifcopenshell.api.run(
         "spatial.assign_container",
         tool.Ifc.get(),
         product=element,
         relating_structure=tool.Ifc.get().by_type("IfcSite")[0],
     )
     bpy.context.scene.collection.objects.link(element_obj)
     subject.assign(element_obj)
     assert element_obj.users_collection[0].name == "IfcGrid/Name"
     assert bpy.data.collections.get("IfcSite/My Site").children.get(
         "IfcGrid/Name")
Ejemplo n.º 8
0
 def test_in_decomposition_mode_aggregates_are_placed_in_a_collection_of_the_same_name(
         self):
     bpy.ops.bim.create_project()
     element_obj = bpy.data.objects.new("IfcElementAssembly/Name", None)
     element = tool.Ifc.get().createIfcElementAssembly()
     subelement_obj = bpy.data.objects.new("IfcBeam/Name", None)
     subelement = tool.Ifc.get().createIfcBeam()
     tool.Ifc.link(element, element_obj)
     bpy.context.scene.collection.objects.link(element_obj)
     ifcopenshell.api.run(
         "aggregate.assign_object",
         tool.Ifc.get(),
         relating_object=element,
         product=subelement,
     )
     subject.assign(element_obj)
     assert len(element_obj.users_collection) == 1
     assert element_obj.users_collection[0].name == element_obj.name
Ejemplo n.º 9
0
 def test_in_decomposition_mode_annotations_are_placed_in_a_group_in_a_views_collection(
         self):
     bpy.ops.bim.create_project()
     element_obj = bpy.data.objects.new("IfcAnnotation/Name", None)
     element = tool.Ifc.get().createIfcAnnotation()
     tool.Ifc.link(element, element_obj)
     group = ifcopenshell.api.run("group.add_group", tool.Ifc.get())
     group.ObjectType = "DRAWING"
     ifcopenshell.api.run("group.assign_group",
                          tool.Ifc.get(),
                          product=element,
                          group=group)
     subject.assign(element_obj)
     assert element_obj.users_collection[0].name == "IfcGroup/Unnamed"
     assert bpy.data.collections.get("Views").children.get(
         "IfcGroup/Unnamed")
     assert bpy.data.collections.get("IfcProject/My Project").children.get(
         "Views")
Ejemplo n.º 10
0
 def test_in_decomposition_mode_existing_collections_are_reassigned_to_the_correct_place_in_the_hierarchy(
         self):
     bpy.ops.bim.create_project()
     space_obj = bpy.data.objects.new("IfcSpace/Name", None)
     space_element = tool.Ifc.get().createIfcSpace()
     tool.Ifc.link(space_element, space_obj)
     space_collection = bpy.data.collections.new("IfcSpace/Name")
     bpy.context.scene.collection.children.link(space_collection)
     space_collection.objects.link(space_obj)
     ifcopenshell.api.run(
         "aggregate.assign_object",
         tool.Ifc.get(),
         relating_object=tool.Ifc.get().by_type("IfcSite")[0],
         product=space_element,
     )
     subject.assign(space_obj)
     assert bpy.context.scene.collection.children.find(
         space_collection.name) == -1
     assert bpy.data.collections.get("IfcSite/My Site").children.find(
         space_collection.name) != -1
Ejemplo n.º 11
0
 def test_in_decomposition_mode_aggregates_subelements_are_placed_in_the_spatial_collection_as_a_fallback(
         self):
     # The aggregate object may not exist in all scenarios, such as when it is filtered out
     bpy.ops.bim.create_project()
     element = tool.Ifc.get().createIfcElementAssembly()
     subelement_obj = bpy.data.objects.new("IfcBeam/Name", None)
     subelement = tool.Ifc.get().createIfcBeam()
     tool.Ifc.link(subelement, subelement_obj)
     ifcopenshell.api.run(
         "spatial.assign_container",
         tool.Ifc.get(),
         product=element,
         relating_structure=tool.Ifc.get().by_type("IfcSite")[0],
     )
     ifcopenshell.api.run(
         "aggregate.assign_object",
         tool.Ifc.get(),
         relating_object=element,
         product=subelement,
     )
     subject.assign(subelement_obj)
     assert subelement_obj.users_collection[0].name == "IfcSite/My Site"