mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 01:41:57 +00:00
Fix #4484. Clarify inheritance rules of predefined types.
This commit is contained in:
@@ -26,10 +26,10 @@ def get_pset(
|
||||
element: ifcopenshell.entity_instance,
|
||||
name: str,
|
||||
prop: Optional[str] = None,
|
||||
psets_only=False,
|
||||
qtos_only=False,
|
||||
should_inherit=True,
|
||||
verbose=False,
|
||||
psets_only: bool = False,
|
||||
qtos_only: bool = False,
|
||||
should_inherit: bool = True,
|
||||
verbose: bool = False,
|
||||
) -> Union[Any, dict[str, Any]]:
|
||||
"""Retrieve a single property set or single property
|
||||
|
||||
@@ -429,8 +429,7 @@ def get_predefined_type(element: ifcopenshell.entity_instance) -> str:
|
||||
element = ifcopenshell.by_type("IfcWall")[0]
|
||||
predefined_type = ifcopenshell.util.element.get_predefined_type(element)
|
||||
"""
|
||||
element_type = get_type(element)
|
||||
if element_type:
|
||||
if element_type := get_type(element):
|
||||
predefined_type = getattr(element_type, "PredefinedType", None)
|
||||
if predefined_type == "USERDEFINED" or not predefined_type:
|
||||
predefined_type = getattr(element_type, "ElementType", ...)
|
||||
@@ -563,7 +562,9 @@ def get_material(
|
||||
return get_material(relating_type, should_skip_usage)
|
||||
|
||||
|
||||
def get_materials(element: ifcopenshell.entity_instance, should_inherit=True) -> list[ifcopenshell.entity_instance]:
|
||||
def get_materials(
|
||||
element: ifcopenshell.entity_instance, should_inherit: bool = True
|
||||
) -> list[ifcopenshell.entity_instance]:
|
||||
"""Gets individual materials of an element
|
||||
|
||||
If the element has a material set, the individual materials of that set are
|
||||
@@ -826,7 +827,7 @@ def get_layers(
|
||||
|
||||
|
||||
def get_container(
|
||||
element: ifcopenshell.entity_instance, should_get_direct=False, ifc_class: Optional[str] = None
|
||||
element: ifcopenshell.entity_instance, should_get_direct: bool = False, ifc_class: Optional[str] = None
|
||||
) -> ifcopenshell.entity_instance:
|
||||
"""
|
||||
Retrieves the spatial structure container of an element.
|
||||
|
||||
@@ -291,6 +291,16 @@ class TestGetPredefinedTypeIFC4(test.bootstrap.IFC4):
|
||||
element_type.ProcessType = "FOOBAR"
|
||||
assert subject.get_predefined_type(element) == "FOOBAR"
|
||||
|
||||
def test_getting_an_element_type_predefined_type(self):
|
||||
element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element_type.PredefinedType = "PARTITIONING"
|
||||
assert subject.get_predefined_type(element_type) == "PARTITIONING"
|
||||
|
||||
def test_getting_an_element_type_null_predefined_type(self):
|
||||
element_type = ifcopenshell.api.run("root.create_entity", self.file, ifc_class="IfcWallType")
|
||||
element_type.PredefinedType = "NOTDEFINED"
|
||||
assert subject.get_predefined_type(element_type) == "NOTDEFINED"
|
||||
|
||||
|
||||
class TestGetTypeIFC4(test.bootstrap.IFC4):
|
||||
def test_getting_the_type_of_a_product(self):
|
||||
|
||||
Reference in New Issue
Block a user