Allow export of IFC class into CSV

This commit is contained in:
Dion Moult
2020-04-26 14:40:33 +10:00
parent 011c50a042
commit 753fdae0d4
+13 -11
View File
@@ -143,7 +143,9 @@ class IfcSelectorParser():
class IfcAttributeExtractor(): class IfcAttributeExtractor():
@staticmethod @staticmethod
def get_element_key(element, key): def get_element_key(element, key):
if hasattr(element, key): if key == 'IfcClass':
return element.is_a()
elif hasattr(element, key):
return getattr(element, key) return getattr(element, key)
elif '.' not in key: elif '.' not in key:
return None return None
@@ -161,19 +163,19 @@ class IfcAttributeExtractor():
@staticmethod @staticmethod
def set_element_key(element, key, value): def set_element_key(element, key, value):
if '.' not in key \ if hasattr(element, key):
and hasattr(element, key): return setattr(element, key, value)
setattr(element, key, value) if '.' not in key:
elif key[0:3] == 'Qto': return
if key[0:3] == 'Qto':
qto, prop = key.split('.') qto, prop = key.split('.')
qto = IfcAttributeExtractor.get_element_qto(element, qto_name) qto = IfcAttributeExtractor.get_element_qto(element, qto_name)
if qto: if qto:
IfcAttributeExtractor.set_qto_property(qto, prop, value) return IfcAttributeExtractor.set_qto_property(qto, prop, value)
else: pset_name, prop = key.split('.')
pset_name, prop = key.split('.') pset = IfcAttributeExtractor.get_element_pset(element, pset_name)
pset = IfcAttributeExtractor.get_element_pset(element, pset_name) if pset:
if pset: return IfcAttributeExtractor.set_pset_property(pset, prop, value)
return IfcAttributeExtractor.set_pset_property(pset, prop, value)
@staticmethod @staticmethod
def get_element_qto(element, name): def get_element_qto(element, name):