From a34588179dfe6d33084afdb292ae46eabd167733 Mon Sep 17 00:00:00 2001 From: Dion Moult Date: Sun, 19 Jan 2020 18:40:39 +1100 Subject: [PATCH] Extract select attributes from XSD into JSON. --- src/ifcblenderexport/getIfcElements.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/ifcblenderexport/getIfcElements.py b/src/ifcblenderexport/getIfcElements.py index b748134f6d..4dcb911e8d 100644 --- a/src/ifcblenderexport/getIfcElements.py +++ b/src/ifcblenderexport/getIfcElements.py @@ -16,14 +16,16 @@ class IFC4Extractor: #self.filters = ['IfcSpatialStructureElement'] #self.filters = ['IfcStructuralActivity', 'IfcStructuralItem'] #self.filters = ['IfcMaterialDefinition'] - self.filters = ['IfcParameterizedProfileDef'] + #self.filters = ['IfcParameterizedProfileDef'] + self.filters = ['IfcBoundaryCondition'] self.filtered_elements = {} def extract(self): for element in self.root.findall("xs:element", self.ns): #if self.is_descendant_from_class(element, "IfcRoot"): #if self.is_descendant_from_class(element, "IfcMaterialDefinition"): - if self.is_descendant_from_class(element, "IfcParameterizedProfileDef"): + #if self.is_descendant_from_class(element, "IfcParameterizedProfileDef"): + if self.is_descendant_from_class(element, "IfcBoundaryCondition"): print('Processing {}'.format(element.attrib['name'])) data = { 'is_abstract': self.is_abstract(element), @@ -93,10 +95,23 @@ class IFC4Extractor: }) else: type_element = attribute.find('./xs:complexType/xs:sequence/xs:element[@ref]', self.ns) + is_select = False + select_types = [] + if not type_element: + # Handle select (i.e. group) attributes + type_element = attribute.find('./xs:complexType/xs:group', self.ns) + if type_element is not None: + is_select = True + select_types = [e.attrib['ref'].replace('ifc:', '') for e in + self.root.findall("./xs:group[@name='{}']/xs:choice/xs:element[@ref]".format( + type_element.attrib['ref'].replace('ifc:', '') + ), self.ns)] if type_element is not None: attributes.append({ 'name': attribute.attrib['name'], - 'type': type_element.attrib['ref'].replace('ifc:', '') + 'type': type_element.attrib['ref'].replace('ifc:', ''), + 'is_select': is_select, + 'select_types': select_types }) return attributes