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
+1 -1
View File
@@ -54,7 +54,7 @@ class Data:
)
for name, data in sorted(psetqtos.items()):
pset = ifc_file.by_id(data["id"])
pset_uses = ifcopenshell.util.element.get_elements_using_pset(pset)
pset_uses = ifcopenshell.util.element.get_elements_by_pset(pset)
results.append(
{
"id": data["id"],
@@ -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): ...
@@ -65,7 +65,7 @@ class Patcher:
all_psets = self.file.by_type("IfcPropertySetDefinition")
psets: dict[ifcopenshell.entity_instance, set[ifcopenshell.entity_instance]] = {}
for pset in all_psets:
elements = ifcopenshell.util.element.get_elements_using_pset(pset)
elements = ifcopenshell.util.element.get_elements_by_pset(pset)
# Skip non shared psets.
if len(elements) < 2:
continue
+3 -3
View File
@@ -38,7 +38,7 @@ class TestUnsharePsets(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)
@@ -81,13 +81,13 @@ class TestUnsharePsets(test.bootstrap.IFC4):
psets.remove(shared_pset)
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)
assert used_elements == set(elements)
# Leave shared pset untouched as it's not part of the provided query.
assert ifcopenshell.util.element.get_elements_using_pset(shared_pset) == set(shared_pset_elements)
assert ifcopenshell.util.element.get_elements_by_pset(shared_pset) == set(shared_pset_elements)
class TestUnsharePsetsIFC2X3(test.bootstrap.IFC2X3, TestUnsharePsets):