Allow export of type relations in IFCCSV

This commit is contained in:
Dion Moult
2020-08-08 17:58:45 +10:00
parent 11a66ee181
commit 3292b98080
5 changed files with 32 additions and 200 deletions
@@ -53,6 +53,15 @@ def get_properties(properties):
return results
def get_type(element):
if hasattr(element, 'IsTypedBy') and element.IsTypedBy:
return element.IsTypedBy[0].RelatingType
elif hasattr(element, 'IsDefinedBy') and element.IsDefinedBy: # IFC2X3
for relationship in element.IsDefinedBy:
if relationship.is_a('IfcRelDefinesByType'):
return relationship.RelatingType
def replace_attribute(element, old, new):
for i, attribute in enumerate(element):
if attribute == old:
@@ -210,6 +210,13 @@ class Selector():
return results
def get_element_value(self, element, key):
if '.' in key \
and key.split('.')[0] == 'type':
try:
element = ifcopenshell.util.element.get_type(element)
except:
return
key = '.'.join(key.split('.')[1:])
info = element.get_info()
if key in info:
return info[key]