Fix #1112. You can now tag material attributes.

This commit is contained in:
Dion Moult
2020-12-02 09:03:18 +11:00
parent aaf9b10a9e
commit c70b41f21a
2 changed files with 20 additions and 0 deletions
@@ -63,6 +63,18 @@ def get_type(element):
return relationship.RelatingType
def get_material(element):
if hasattr(element, "HasAssociations") and element.HasAssociations:
for relationship in element.HasAssociations:
if relationship.is_a("IfcRelAssociatesMaterial"):
return relationship.RelatingMaterial
relating_type = get_type(element)
if hasattr(relating_type, "HasAssociations") and relating_type.HasAssociations:
for relationship in relating_type.HasAssociations:
if relationship.is_a("IfcRelAssociatesMaterial"):
return relationship.RelatingMaterial
def replace_attribute(element, old, new):
for i, attribute in enumerate(element):
if attribute == old:
@@ -219,6 +219,14 @@ class Selector:
except:
return
key = ".".join(key.split(".")[1:])
elif "." in key and key.split(".")[0] == "material":
try:
element = ifcopenshell.util.element.get_material(element)
if not element:
return None
except:
return
key = ".".join(key.split(".")[1:])
info = element.get_info()
if key in info:
return info[key]