rename get_elements_using_pset -> get_elements_by_pset for consistency

To be consistent with other get_elements_by_xxx methods.
This commit is contained in:
Andrej730
2024-09-05 17:38:22 +05:00
parent a03c55d15f
commit a867e72fd3
9 changed files with 16 additions and 16 deletions
@@ -44,19 +44,19 @@ def assign_pset(
element = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
ifcopenshell.api.pset.assign_pset(model, [element], pset)
# Pset is now assigned.
assert ifcopenshell.util.element.get_elements_using_pset(pset) == {element}
assert ifcopenshell.util.element.get_elements_by_pset(pset) == {element}
element1 = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
element2 = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWall")
ifcopenshell.api.pset.assign_pset(model, [element1, element2], pset)
# Pset is now shared by multiple elements.
assert ifcopenshell.util.element.get_elements_using_pset(pset) == {element, element1, element2}
assert ifcopenshell.util.element.get_elements_by_pset(pset) == {element, element1, element2}
# Same for element types.
element_type = ifcopenshell.api.root.create_entity(model, ifc_class="IfcWallType")
ifcopenshell.api.pset.assign_pset(model, [element_type], type_pset)
# Pset is now assigned to the type.
assert ifcopenshell.util.element.get_elements_using_pset(type_pset) == {element_type}
assert ifcopenshell.util.element.get_elements_by_pset(type_pset) == {element_type}
"""
is_ifc2x3 = file.schema == "IFC2X3"
@@ -41,11 +41,11 @@ def unassign_pset(
ifcopenshell.api.pset.assign_pset(self.file, [element1, element2], pset)
# Pset is now shared by 2 elements.
assert ifcopenshell.util.element.get_elements_using_pset(pset) == {element1, element2}
assert ifcopenshell.util.element.get_elements_by_pset(pset) == {element1, element2}
ifcopenshell.api.pset.unassign_pset(self.file, [element2], pset)
# Pset was unassigned from element2.
assert ifcopenshell.util.element.get_elements_using_pset(pset) == {element1}
assert ifcopenshell.util.element.get_elements_by_pset(pset) == {element1}
"""
is_ifc2x3 = file.schema == "IFC2X3"
@@ -45,17 +45,17 @@ def unshare_pset(
ifcopenshell.api.pset.assign_pset(self.file, [element1, element2], pset)
# Pset is now shared by 2 elements.
assert ifcopenshell.util.element.get_elements_using_pset(pset) == {element1, element2}
assert ifcopenshell.util.element.get_elements_by_pset(pset) == {element1, element2}
new_psets = ifcopenshell.api.pset.unshare_pset(self.file, [element2], pset)
# element2 was unassigned from the original pset.
assert ifcopenshell.util.element.get_elements_using_pset(pset) == {element1}
assert ifcopenshell.util.element.get_elements_by_pset(pset) == {element1}
new_pset = new_psets[0]
# New pset was created and was assigned to element2.
assert new_pset != pset
assert ifcopenshell.util.element.get_elements_using_pset(new_pset) == {element2}
assert ifcopenshell.util.element.get_elements_by_pset(new_pset) == {element2}
"""
products_occurrences: set[ifcopenshell.entity_instance] = set()
products_types: set[ifcopenshell.entity_instance] = set()
@@ -441,7 +441,7 @@ def get_properties(
return results
def get_elements_using_pset(pset: ifcopenshell.entity_instance) -> set[ifcopenshell.entity_instance]:
def get_elements_by_pset(pset: ifcopenshell.entity_instance) -> set[ifcopenshell.entity_instance]:
"""Retrieve the elements (or element types) that are using the provided property set."""
is_ifc2x3 = pset.file.schema == "IFC2X3"
elements = set()
@@ -41,7 +41,7 @@ class TestUnsharePset(test.bootstrap.IFC4):
used_elements = set()
for pset in psets:
pset_elements = ifcopenshell.util.element.get_elements_using_pset(pset)
pset_elements = ifcopenshell.util.element.get_elements_by_pset(pset)
assert len(pset_elements) == 1
used_elements.update(pset_elements)
@@ -266,7 +266,7 @@ class TestGetElementsUsingPset(test.bootstrap.IFC4):
element_type = ifcopenshell.api.root.create_entity(self.file, ifc_class="IfcWallType")
pset = self.file.create_entity("IfcPropertySet")
ifcopenshell.api.pset.assign_pset(self.file, [element, element_type], pset)
assert subject.get_elements_using_pset(pset) == {element, element_type}
assert subject.get_elements_by_pset(pset) == {element, element_type}
class TestGetElementsUsingPsetIFC2X3(test.bootstrap.IFC2X3, TestGetElementsUsingPset): ...