mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-24 22:39:58 +00:00
Extract select attributes from XSD into JSON.
This commit is contained in:
@@ -16,14 +16,16 @@ class IFC4Extractor:
|
|||||||
#self.filters = ['IfcSpatialStructureElement']
|
#self.filters = ['IfcSpatialStructureElement']
|
||||||
#self.filters = ['IfcStructuralActivity', 'IfcStructuralItem']
|
#self.filters = ['IfcStructuralActivity', 'IfcStructuralItem']
|
||||||
#self.filters = ['IfcMaterialDefinition']
|
#self.filters = ['IfcMaterialDefinition']
|
||||||
self.filters = ['IfcParameterizedProfileDef']
|
#self.filters = ['IfcParameterizedProfileDef']
|
||||||
|
self.filters = ['IfcBoundaryCondition']
|
||||||
self.filtered_elements = {}
|
self.filtered_elements = {}
|
||||||
|
|
||||||
def extract(self):
|
def extract(self):
|
||||||
for element in self.root.findall("xs:element", self.ns):
|
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, "IfcRoot"):
|
||||||
#if self.is_descendant_from_class(element, "IfcMaterialDefinition"):
|
#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']))
|
print('Processing {}'.format(element.attrib['name']))
|
||||||
data = {
|
data = {
|
||||||
'is_abstract': self.is_abstract(element),
|
'is_abstract': self.is_abstract(element),
|
||||||
@@ -93,10 +95,23 @@ class IFC4Extractor:
|
|||||||
})
|
})
|
||||||
else:
|
else:
|
||||||
type_element = attribute.find('./xs:complexType/xs:sequence/xs:element[@ref]', self.ns)
|
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:
|
if type_element is not None:
|
||||||
attributes.append({
|
attributes.append({
|
||||||
'name': attribute.attrib['name'],
|
'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
|
return attributes
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user