mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-23 21:58:46 +00:00
Fix #1112. You can now tag material attributes.
This commit is contained in:
@@ -63,6 +63,18 @@ def get_type(element):
|
|||||||
return relationship.RelatingType
|
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):
|
def replace_attribute(element, old, new):
|
||||||
for i, attribute in enumerate(element):
|
for i, attribute in enumerate(element):
|
||||||
if attribute == old:
|
if attribute == old:
|
||||||
|
|||||||
@@ -219,6 +219,14 @@ class Selector:
|
|||||||
except:
|
except:
|
||||||
return
|
return
|
||||||
key = ".".join(key.split(".")[1:])
|
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()
|
info = element.get_info()
|
||||||
if key in info:
|
if key in info:
|
||||||
return info[key]
|
return info[key]
|
||||||
|
|||||||
Reference in New Issue
Block a user