by_type now returns tuple - update annotations and fix failing tests

This commit is contained in:
Dion Moult
2026-08-11 16:44:47 +10:00
parent b408e64e5e
commit 6bab0603e6
3 changed files with 4 additions and 4 deletions
@@ -678,7 +678,7 @@ class AddBoundary(bpy.types.Operator, tool.Ifc.Operator):
# Identify all potential building elements
# TODO: don't select everything, use AABB culling in Blender
building_elements = (
building_elements = list(
tool.Ifc.get().by_type("IfcWall")
+ tool.Ifc.get().by_type("IfcSlab")
+ tool.Ifc.get().by_type("IfcVirtualElement")
+2 -2
View File
@@ -728,7 +728,7 @@ class file_mixin:
[self.transaction.store_create(e) for e in reversed(added_elements)]
return result
def by_type(self, type: str, include_subtypes=True) -> list[ifcopenshell.entity_instance]:
def by_type(self, type: str, include_subtypes=True) -> tuple[ifcopenshell.entity_instance, ...]:
"""Return IFC objects filtered by IFC Type and wrapped with the entity_instance class.
If an IFC type class has subclasses, all entities of those subclasses are also returned.
@@ -746,7 +746,7 @@ class file_mixin:
def traverse(
self, inst: ifcopenshell.entity_instance, max_levels: Optional[int] = None, breadth_first: bool = False
) -> list[ifcopenshell.entity_instance]:
) -> tuple[ifcopenshell.entity_instance, ...]:
"""Get a list of all referenced instances for a particular instance including itself
:param inst: The entity instance to get all sub instances
+1 -1
View File
@@ -75,7 +75,7 @@ class TestUnsharePsets(test.bootstrap.IFC4):
rel.RelatedObjects = elements
ifcpatch.execute({"file": self.file, "recipe": "UnsharePsets", "arguments": ["IfcWall"]})
assert len(psets := self.file.by_type("IfcPropertySet")) == 4
assert len(psets := list(self.file.by_type("IfcPropertySet"))) == 4
assert len(self.file.by_type("IfcRelDefinesByProperties")) == 4
psets.remove(shared_pset)