mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
Allow export of boundary conditions. See #756.
This commit is contained in:
@@ -356,7 +356,10 @@ class IfcParser():
|
||||
'relating_host': None,
|
||||
'relating_qtos_key': None,
|
||||
'representations': self.get_object_representation_names(obj),
|
||||
'attributes': self.get_object_attributes(obj)
|
||||
'attributes': self.get_object_attributes(obj),
|
||||
'has_boundary_condition': obj.BIMObjectProperties.has_boundary_condition,
|
||||
'boundary_condition_class': None,
|
||||
'boundary_condition_attributes': {}
|
||||
}
|
||||
product['attributes'].update(attribute_override)
|
||||
product.update(metadata_override)
|
||||
@@ -366,6 +369,11 @@ class IfcParser():
|
||||
reference = self.get_type_product_reference(obj.parent.name)
|
||||
self.rel_defines_by_type.setdefault(reference, []).append(self.product_index)
|
||||
|
||||
if product['has_boundary_condition']:
|
||||
product['boundary_condition_class'] = obj.BIMObjectProperties.boundary_condition.name
|
||||
product['boundary_condition_attributes'] = {a.name: a.string_value
|
||||
for a in obj.BIMObjectProperties.boundary_condition.attributes}
|
||||
|
||||
for collection in product['raw'].users_collection:
|
||||
self.parse_product_collection(product, collection)
|
||||
|
||||
@@ -1497,6 +1505,11 @@ class IfcExporter():
|
||||
|
||||
def cast_attributes(self, ifc_class, attributes):
|
||||
for key, value in attributes.items():
|
||||
complex_attribute = self.cast_complex_attribute(ifc_class, key, value)
|
||||
if complex_attribute:
|
||||
attributes[key] = complex_attribute
|
||||
continue
|
||||
|
||||
var_type = self.get_product_attribute_type(ifc_class, key)
|
||||
if var_type is None:
|
||||
continue
|
||||
@@ -1563,13 +1576,25 @@ class IfcExporter():
|
||||
product['up_axis'],
|
||||
product['forward_axis']))
|
||||
|
||||
self.cast_attributes(product['class'], product['attributes'])
|
||||
|
||||
product['attributes'].update({
|
||||
'OwnerHistory': self.owner_history, # TODO: unhardcode
|
||||
'ObjectPlacement': placement,
|
||||
'Representation': self.get_product_shape(product)
|
||||
})
|
||||
|
||||
self.cast_attributes(product['class'], product['attributes'])
|
||||
if product['has_boundary_condition']:
|
||||
ifc_class = product['boundary_condition_class']
|
||||
attributes = product['boundary_condition_attributes']
|
||||
for key, value in attributes.items():
|
||||
if value == 'True' or value == 'False':
|
||||
attributes[key] = bool(value)
|
||||
else:
|
||||
attributes[key] = float(value)
|
||||
self.cast_attributes(ifc_class, attributes)
|
||||
boundary_condition = self.file.create_entity(ifc_class, **attributes)
|
||||
product['attributes']['AppliedCondition'] = boundary_condition
|
||||
|
||||
try:
|
||||
product['ifc'] = self.file.create_entity(product['class'], **product['attributes'])
|
||||
@@ -1588,7 +1613,18 @@ class IfcExporter():
|
||||
return a['type']
|
||||
if element_schema['parent'] in schema.ifc.elements:
|
||||
return self.get_product_attribute_type(element_schema['parent'], attribute_name)
|
||||
return None
|
||||
|
||||
def cast_complex_attribute(self, product_class, attribute_name, attribute_value):
|
||||
element_schema = schema.ifc.elements[product_class]
|
||||
for a in element_schema['complex_attributes']:
|
||||
if a['name'] == attribute_name:
|
||||
if not a['is_select']:
|
||||
return a['type']
|
||||
for select_type in a['select_types']:
|
||||
try:
|
||||
return self.file.create_entity(select_type, attribute_value)
|
||||
except:
|
||||
pass
|
||||
|
||||
def get_product_shape(self, product):
|
||||
try:
|
||||
|
||||
@@ -1,256 +1,256 @@
|
||||
{
|
||||
"IfcBoundaryEdgeCondition": {
|
||||
"is_abstract": false,
|
||||
"parent": "IfcBoundaryCondition",
|
||||
"attributes": [
|
||||
{
|
||||
"name": "Name",
|
||||
"type": "IfcLabel",
|
||||
"is_enum": false,
|
||||
"enum_values": []
|
||||
"enum_values": [],
|
||||
"type": "IfcLabel",
|
||||
"name": "Name",
|
||||
"is_enum": false
|
||||
}
|
||||
],
|
||||
],
|
||||
"is_abstract": false,
|
||||
"complex_attributes": [
|
||||
{
|
||||
"name": "TranslationalStiffnessByLengthX",
|
||||
"type": "IfcModulusOfTranslationalSubgradeReactionSelect",
|
||||
"is_select": true,
|
||||
"select_types": [
|
||||
"IfcBoolean-wrapper",
|
||||
"IfcModulusOfLinearSubgradeReactionMeasure-wrapper"
|
||||
]
|
||||
},
|
||||
"IfcBoolean",
|
||||
"IfcModulusOfLinearSubgradeReactionMeasure"
|
||||
],
|
||||
"type": "IfcModulusOfTranslationalSubgradeReactionSelect",
|
||||
"name": "TranslationalStiffnessByLengthX",
|
||||
"is_select": true
|
||||
},
|
||||
{
|
||||
"name": "TranslationalStiffnessByLengthY",
|
||||
"type": "IfcModulusOfTranslationalSubgradeReactionSelect",
|
||||
"is_select": true,
|
||||
"select_types": [
|
||||
"IfcBoolean-wrapper",
|
||||
"IfcModulusOfLinearSubgradeReactionMeasure-wrapper"
|
||||
]
|
||||
},
|
||||
"IfcBoolean",
|
||||
"IfcModulusOfLinearSubgradeReactionMeasure"
|
||||
],
|
||||
"type": "IfcModulusOfTranslationalSubgradeReactionSelect",
|
||||
"name": "TranslationalStiffnessByLengthY",
|
||||
"is_select": true
|
||||
},
|
||||
{
|
||||
"name": "TranslationalStiffnessByLengthZ",
|
||||
"type": "IfcModulusOfTranslationalSubgradeReactionSelect",
|
||||
"is_select": true,
|
||||
"select_types": [
|
||||
"IfcBoolean-wrapper",
|
||||
"IfcModulusOfLinearSubgradeReactionMeasure-wrapper"
|
||||
]
|
||||
},
|
||||
"IfcBoolean",
|
||||
"IfcModulusOfLinearSubgradeReactionMeasure"
|
||||
],
|
||||
"type": "IfcModulusOfTranslationalSubgradeReactionSelect",
|
||||
"name": "TranslationalStiffnessByLengthZ",
|
||||
"is_select": true
|
||||
},
|
||||
{
|
||||
"name": "RotationalStiffnessByLengthX",
|
||||
"type": "IfcModulusOfRotationalSubgradeReactionSelect",
|
||||
"is_select": true,
|
||||
"select_types": [
|
||||
"IfcBoolean-wrapper",
|
||||
"IfcModulusOfRotationalSubgradeReactionMeasure-wrapper"
|
||||
]
|
||||
},
|
||||
"IfcBoolean",
|
||||
"IfcModulusOfRotationalSubgradeReactionMeasure"
|
||||
],
|
||||
"type": "IfcModulusOfRotationalSubgradeReactionSelect",
|
||||
"name": "RotationalStiffnessByLengthX",
|
||||
"is_select": true
|
||||
},
|
||||
{
|
||||
"name": "RotationalStiffnessByLengthY",
|
||||
"type": "IfcModulusOfRotationalSubgradeReactionSelect",
|
||||
"is_select": true,
|
||||
"select_types": [
|
||||
"IfcBoolean-wrapper",
|
||||
"IfcModulusOfRotationalSubgradeReactionMeasure-wrapper"
|
||||
]
|
||||
},
|
||||
"IfcBoolean",
|
||||
"IfcModulusOfRotationalSubgradeReactionMeasure"
|
||||
],
|
||||
"type": "IfcModulusOfRotationalSubgradeReactionSelect",
|
||||
"name": "RotationalStiffnessByLengthY",
|
||||
"is_select": true
|
||||
},
|
||||
{
|
||||
"name": "RotationalStiffnessByLengthZ",
|
||||
"type": "IfcModulusOfRotationalSubgradeReactionSelect",
|
||||
"is_select": true,
|
||||
"select_types": [
|
||||
"IfcBoolean-wrapper",
|
||||
"IfcModulusOfRotationalSubgradeReactionMeasure-wrapper"
|
||||
]
|
||||
"IfcBoolean",
|
||||
"IfcModulusOfRotationalSubgradeReactionMeasure"
|
||||
],
|
||||
"type": "IfcModulusOfRotationalSubgradeReactionSelect",
|
||||
"name": "RotationalStiffnessByLengthZ",
|
||||
"is_select": true
|
||||
}
|
||||
]
|
||||
},
|
||||
],
|
||||
"parent": "IfcBoundaryCondition"
|
||||
},
|
||||
"IfcBoundaryFaceCondition": {
|
||||
"is_abstract": false,
|
||||
"parent": "IfcBoundaryCondition",
|
||||
"attributes": [
|
||||
{
|
||||
"name": "Name",
|
||||
"type": "IfcLabel",
|
||||
"is_enum": false,
|
||||
"enum_values": []
|
||||
"enum_values": [],
|
||||
"type": "IfcLabel",
|
||||
"name": "Name",
|
||||
"is_enum": false
|
||||
}
|
||||
],
|
||||
],
|
||||
"is_abstract": false,
|
||||
"complex_attributes": [
|
||||
{
|
||||
"name": "TranslationalStiffnessByAreaX",
|
||||
"type": "IfcModulusOfSubgradeReactionSelect",
|
||||
"is_select": true,
|
||||
"select_types": [
|
||||
"IfcBoolean-wrapper",
|
||||
"IfcModulusOfSubgradeReactionMeasure-wrapper"
|
||||
]
|
||||
},
|
||||
"IfcBoolean",
|
||||
"IfcModulusOfSubgradeReactionMeasure"
|
||||
],
|
||||
"type": "IfcModulusOfSubgradeReactionSelect",
|
||||
"name": "TranslationalStiffnessByAreaX",
|
||||
"is_select": true
|
||||
},
|
||||
{
|
||||
"name": "TranslationalStiffnessByAreaY",
|
||||
"type": "IfcModulusOfSubgradeReactionSelect",
|
||||
"is_select": true,
|
||||
"select_types": [
|
||||
"IfcBoolean-wrapper",
|
||||
"IfcModulusOfSubgradeReactionMeasure-wrapper"
|
||||
]
|
||||
},
|
||||
"IfcBoolean",
|
||||
"IfcModulusOfSubgradeReactionMeasure"
|
||||
],
|
||||
"type": "IfcModulusOfSubgradeReactionSelect",
|
||||
"name": "TranslationalStiffnessByAreaY",
|
||||
"is_select": true
|
||||
},
|
||||
{
|
||||
"name": "TranslationalStiffnessByAreaZ",
|
||||
"type": "IfcModulusOfSubgradeReactionSelect",
|
||||
"is_select": true,
|
||||
"select_types": [
|
||||
"IfcBoolean-wrapper",
|
||||
"IfcModulusOfSubgradeReactionMeasure-wrapper"
|
||||
]
|
||||
"IfcBoolean",
|
||||
"IfcModulusOfSubgradeReactionMeasure"
|
||||
],
|
||||
"type": "IfcModulusOfSubgradeReactionSelect",
|
||||
"name": "TranslationalStiffnessByAreaZ",
|
||||
"is_select": true
|
||||
}
|
||||
]
|
||||
},
|
||||
],
|
||||
"parent": "IfcBoundaryCondition"
|
||||
},
|
||||
"IfcBoundaryNodeCondition": {
|
||||
"is_abstract": false,
|
||||
"parent": "IfcBoundaryCondition",
|
||||
"attributes": [
|
||||
{
|
||||
"name": "Name",
|
||||
"type": "IfcLabel",
|
||||
"is_enum": false,
|
||||
"enum_values": []
|
||||
"enum_values": [],
|
||||
"type": "IfcLabel",
|
||||
"name": "Name",
|
||||
"is_enum": false
|
||||
}
|
||||
],
|
||||
],
|
||||
"is_abstract": false,
|
||||
"complex_attributes": [
|
||||
{
|
||||
"name": "TranslationalStiffnessX",
|
||||
"type": "IfcTranslationalStiffnessSelect",
|
||||
"is_select": true,
|
||||
"select_types": [
|
||||
"IfcBoolean-wrapper",
|
||||
"IfcLinearStiffnessMeasure-wrapper"
|
||||
]
|
||||
},
|
||||
"IfcBoolean",
|
||||
"IfcLinearStiffnessMeasure"
|
||||
],
|
||||
"type": "IfcTranslationalStiffnessSelect",
|
||||
"name": "TranslationalStiffnessX",
|
||||
"is_select": true
|
||||
},
|
||||
{
|
||||
"name": "TranslationalStiffnessY",
|
||||
"type": "IfcTranslationalStiffnessSelect",
|
||||
"is_select": true,
|
||||
"select_types": [
|
||||
"IfcBoolean-wrapper",
|
||||
"IfcLinearStiffnessMeasure-wrapper"
|
||||
]
|
||||
},
|
||||
"IfcBoolean",
|
||||
"IfcLinearStiffnessMeasure"
|
||||
],
|
||||
"type": "IfcTranslationalStiffnessSelect",
|
||||
"name": "TranslationalStiffnessY",
|
||||
"is_select": true
|
||||
},
|
||||
{
|
||||
"name": "TranslationalStiffnessZ",
|
||||
"type": "IfcTranslationalStiffnessSelect",
|
||||
"is_select": true,
|
||||
"select_types": [
|
||||
"IfcBoolean-wrapper",
|
||||
"IfcLinearStiffnessMeasure-wrapper"
|
||||
]
|
||||
},
|
||||
"IfcBoolean",
|
||||
"IfcLinearStiffnessMeasure"
|
||||
],
|
||||
"type": "IfcTranslationalStiffnessSelect",
|
||||
"name": "TranslationalStiffnessZ",
|
||||
"is_select": true
|
||||
},
|
||||
{
|
||||
"name": "RotationalStiffnessX",
|
||||
"type": "IfcRotationalStiffnessSelect",
|
||||
"is_select": true,
|
||||
"select_types": [
|
||||
"IfcBoolean-wrapper",
|
||||
"IfcRotationalStiffnessMeasure-wrapper"
|
||||
]
|
||||
},
|
||||
"IfcBoolean",
|
||||
"IfcRotationalStiffnessMeasure"
|
||||
],
|
||||
"type": "IfcRotationalStiffnessSelect",
|
||||
"name": "RotationalStiffnessX",
|
||||
"is_select": true
|
||||
},
|
||||
{
|
||||
"name": "RotationalStiffnessY",
|
||||
"type": "IfcRotationalStiffnessSelect",
|
||||
"is_select": true,
|
||||
"select_types": [
|
||||
"IfcBoolean-wrapper",
|
||||
"IfcRotationalStiffnessMeasure-wrapper"
|
||||
]
|
||||
},
|
||||
"IfcBoolean",
|
||||
"IfcRotationalStiffnessMeasure"
|
||||
],
|
||||
"type": "IfcRotationalStiffnessSelect",
|
||||
"name": "RotationalStiffnessY",
|
||||
"is_select": true
|
||||
},
|
||||
{
|
||||
"name": "RotationalStiffnessZ",
|
||||
"type": "IfcRotationalStiffnessSelect",
|
||||
"is_select": true,
|
||||
"select_types": [
|
||||
"IfcBoolean-wrapper",
|
||||
"IfcRotationalStiffnessMeasure-wrapper"
|
||||
]
|
||||
"IfcBoolean",
|
||||
"IfcRotationalStiffnessMeasure"
|
||||
],
|
||||
"type": "IfcRotationalStiffnessSelect",
|
||||
"name": "RotationalStiffnessZ",
|
||||
"is_select": true
|
||||
}
|
||||
]
|
||||
},
|
||||
],
|
||||
"parent": "IfcBoundaryCondition"
|
||||
},
|
||||
"IfcBoundaryNodeConditionWarping": {
|
||||
"is_abstract": false,
|
||||
"parent": "IfcBoundaryNodeCondition",
|
||||
"attributes": [
|
||||
{
|
||||
"name": "Name",
|
||||
"type": "IfcLabel",
|
||||
"is_enum": false,
|
||||
"enum_values": []
|
||||
"enum_values": [],
|
||||
"type": "IfcLabel",
|
||||
"name": "Name",
|
||||
"is_enum": false
|
||||
}
|
||||
],
|
||||
],
|
||||
"is_abstract": false,
|
||||
"complex_attributes": [
|
||||
{
|
||||
"name": "TranslationalStiffnessX",
|
||||
"type": "IfcTranslationalStiffnessSelect",
|
||||
"is_select": true,
|
||||
"select_types": [
|
||||
"IfcBoolean-wrapper",
|
||||
"IfcLinearStiffnessMeasure-wrapper"
|
||||
]
|
||||
},
|
||||
"IfcBoolean",
|
||||
"IfcLinearStiffnessMeasure"
|
||||
],
|
||||
"type": "IfcTranslationalStiffnessSelect",
|
||||
"name": "TranslationalStiffnessX",
|
||||
"is_select": true
|
||||
},
|
||||
{
|
||||
"name": "TranslationalStiffnessY",
|
||||
"type": "IfcTranslationalStiffnessSelect",
|
||||
"is_select": true,
|
||||
"select_types": [
|
||||
"IfcBoolean-wrapper",
|
||||
"IfcLinearStiffnessMeasure-wrapper"
|
||||
]
|
||||
},
|
||||
"IfcBoolean",
|
||||
"IfcLinearStiffnessMeasure"
|
||||
],
|
||||
"type": "IfcTranslationalStiffnessSelect",
|
||||
"name": "TranslationalStiffnessY",
|
||||
"is_select": true
|
||||
},
|
||||
{
|
||||
"name": "TranslationalStiffnessZ",
|
||||
"type": "IfcTranslationalStiffnessSelect",
|
||||
"is_select": true,
|
||||
"select_types": [
|
||||
"IfcBoolean-wrapper",
|
||||
"IfcLinearStiffnessMeasure-wrapper"
|
||||
]
|
||||
},
|
||||
"IfcBoolean",
|
||||
"IfcLinearStiffnessMeasure"
|
||||
],
|
||||
"type": "IfcTranslationalStiffnessSelect",
|
||||
"name": "TranslationalStiffnessZ",
|
||||
"is_select": true
|
||||
},
|
||||
{
|
||||
"name": "RotationalStiffnessX",
|
||||
"type": "IfcRotationalStiffnessSelect",
|
||||
"is_select": true,
|
||||
"select_types": [
|
||||
"IfcBoolean-wrapper",
|
||||
"IfcRotationalStiffnessMeasure-wrapper"
|
||||
]
|
||||
},
|
||||
"IfcBoolean",
|
||||
"IfcRotationalStiffnessMeasure"
|
||||
],
|
||||
"type": "IfcRotationalStiffnessSelect",
|
||||
"name": "RotationalStiffnessX",
|
||||
"is_select": true
|
||||
},
|
||||
{
|
||||
"name": "RotationalStiffnessY",
|
||||
"type": "IfcRotationalStiffnessSelect",
|
||||
"is_select": true,
|
||||
"select_types": [
|
||||
"IfcBoolean-wrapper",
|
||||
"IfcRotationalStiffnessMeasure-wrapper"
|
||||
]
|
||||
},
|
||||
"IfcBoolean",
|
||||
"IfcRotationalStiffnessMeasure"
|
||||
],
|
||||
"type": "IfcRotationalStiffnessSelect",
|
||||
"name": "RotationalStiffnessY",
|
||||
"is_select": true
|
||||
},
|
||||
{
|
||||
"name": "RotationalStiffnessZ",
|
||||
"type": "IfcRotationalStiffnessSelect",
|
||||
"is_select": true,
|
||||
"select_types": [
|
||||
"IfcBoolean-wrapper",
|
||||
"IfcRotationalStiffnessMeasure-wrapper"
|
||||
]
|
||||
},
|
||||
"IfcBoolean",
|
||||
"IfcRotationalStiffnessMeasure"
|
||||
],
|
||||
"type": "IfcRotationalStiffnessSelect",
|
||||
"name": "RotationalStiffnessZ",
|
||||
"is_select": true
|
||||
},
|
||||
{
|
||||
"name": "WarpingStiffness",
|
||||
"type": "IfcWarpingStiffnessSelect",
|
||||
"is_select": true,
|
||||
"select_types": [
|
||||
"IfcBoolean-wrapper",
|
||||
"IfcWarpingMomentMeasure-wrapper"
|
||||
]
|
||||
"IfcBoolean",
|
||||
"IfcWarpingMomentMeasure"
|
||||
],
|
||||
"type": "IfcWarpingStiffnessSelect",
|
||||
"name": "WarpingStiffness",
|
||||
"is_select": true
|
||||
}
|
||||
]
|
||||
],
|
||||
"parent": "IfcBoundaryNodeCondition"
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -23,12 +23,10 @@
|
||||
"is_abstract": false,
|
||||
"complex_attributes": [
|
||||
{
|
||||
"type": "IfcMaterialProperties",
|
||||
"name": "HasProperties"
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcMaterialDefinitionRepresentation",
|
||||
"name": "HasRepresentation"
|
||||
"name": "HasRepresentation",
|
||||
"is_select": false
|
||||
}
|
||||
],
|
||||
"parent": "IfcMaterialDefinition"
|
||||
@@ -63,12 +61,10 @@
|
||||
"is_abstract": false,
|
||||
"complex_attributes": [
|
||||
{
|
||||
"type": "IfcMaterialProperties",
|
||||
"name": "HasProperties"
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcMaterial",
|
||||
"name": "Material"
|
||||
"name": "Material",
|
||||
"is_select": false
|
||||
}
|
||||
],
|
||||
"parent": "IfcMaterialDefinition"
|
||||
@@ -89,16 +85,7 @@
|
||||
}
|
||||
],
|
||||
"is_abstract": false,
|
||||
"complex_attributes": [
|
||||
{
|
||||
"type": "IfcMaterialProperties",
|
||||
"name": "HasProperties"
|
||||
},
|
||||
{
|
||||
"type": "IfcMaterialConstituent",
|
||||
"name": "MaterialConstituents"
|
||||
}
|
||||
],
|
||||
"complex_attributes": [],
|
||||
"parent": "IfcMaterialDefinition"
|
||||
},
|
||||
"IfcMaterialLayer": {
|
||||
@@ -143,12 +130,10 @@
|
||||
"is_abstract": false,
|
||||
"complex_attributes": [
|
||||
{
|
||||
"type": "IfcMaterialProperties",
|
||||
"name": "HasProperties"
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcMaterial",
|
||||
"name": "Material"
|
||||
"name": "Material",
|
||||
"is_select": false
|
||||
}
|
||||
],
|
||||
"parent": "IfcMaterialDefinition"
|
||||
@@ -169,16 +154,7 @@
|
||||
}
|
||||
],
|
||||
"is_abstract": false,
|
||||
"complex_attributes": [
|
||||
{
|
||||
"type": "IfcMaterialProperties",
|
||||
"name": "HasProperties"
|
||||
},
|
||||
{
|
||||
"type": "IfcMaterialLayer",
|
||||
"name": "MaterialLayers"
|
||||
}
|
||||
],
|
||||
"complex_attributes": [],
|
||||
"parent": "IfcMaterialDefinition"
|
||||
},
|
||||
"IfcMaterialLayerWithOffsets": {
|
||||
@@ -233,12 +209,10 @@
|
||||
"is_abstract": false,
|
||||
"complex_attributes": [
|
||||
{
|
||||
"type": "IfcMaterialProperties",
|
||||
"name": "HasProperties"
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcMaterial",
|
||||
"name": "Material"
|
||||
"name": "Material",
|
||||
"is_select": false
|
||||
}
|
||||
],
|
||||
"parent": "IfcMaterialLayer"
|
||||
@@ -273,16 +247,16 @@
|
||||
"is_abstract": false,
|
||||
"complex_attributes": [
|
||||
{
|
||||
"type": "IfcMaterialProperties",
|
||||
"name": "HasProperties"
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcMaterial",
|
||||
"name": "Material"
|
||||
"name": "Material",
|
||||
"is_select": false
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcProfileDef",
|
||||
"name": "Profile"
|
||||
"name": "Profile",
|
||||
"is_select": false
|
||||
}
|
||||
],
|
||||
"parent": "IfcMaterialDefinition"
|
||||
@@ -305,16 +279,10 @@
|
||||
"is_abstract": false,
|
||||
"complex_attributes": [
|
||||
{
|
||||
"type": "IfcMaterialProperties",
|
||||
"name": "HasProperties"
|
||||
},
|
||||
{
|
||||
"type": "IfcMaterialProfile",
|
||||
"name": "MaterialProfiles"
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcCompositeProfileDef",
|
||||
"name": "CompositeProfile"
|
||||
"name": "CompositeProfile",
|
||||
"is_select": false
|
||||
}
|
||||
],
|
||||
"parent": "IfcMaterialDefinition"
|
||||
@@ -349,16 +317,16 @@
|
||||
"is_abstract": false,
|
||||
"complex_attributes": [
|
||||
{
|
||||
"type": "IfcMaterialProperties",
|
||||
"name": "HasProperties"
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcMaterial",
|
||||
"name": "Material"
|
||||
"name": "Material",
|
||||
"is_select": false
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcProfileDef",
|
||||
"name": "Profile"
|
||||
"name": "Profile",
|
||||
"is_select": false
|
||||
}
|
||||
],
|
||||
"parent": "IfcMaterialProfile"
|
||||
|
||||
@@ -92,12 +92,10 @@
|
||||
"is_abstract": false,
|
||||
"complex_attributes": [
|
||||
{
|
||||
"type": "IfcProfileProperties",
|
||||
"name": "HasProperties"
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcAxis2Placement2D",
|
||||
"name": "Position"
|
||||
"name": "Position",
|
||||
"is_select": false
|
||||
}
|
||||
],
|
||||
"parent": "IfcParameterizedProfileDef"
|
||||
@@ -153,12 +151,10 @@
|
||||
"is_abstract": false,
|
||||
"complex_attributes": [
|
||||
{
|
||||
"type": "IfcProfileProperties",
|
||||
"name": "HasProperties"
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcAxis2Placement2D",
|
||||
"name": "Position"
|
||||
"name": "Position",
|
||||
"is_select": false
|
||||
}
|
||||
],
|
||||
"parent": "IfcParameterizedProfileDef"
|
||||
@@ -196,12 +192,10 @@
|
||||
"is_abstract": false,
|
||||
"complex_attributes": [
|
||||
{
|
||||
"type": "IfcProfileProperties",
|
||||
"name": "HasProperties"
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcAxis2Placement2D",
|
||||
"name": "Position"
|
||||
"name": "Position",
|
||||
"is_select": false
|
||||
}
|
||||
],
|
||||
"parent": "IfcCircleProfileDef"
|
||||
@@ -233,12 +227,10 @@
|
||||
"is_abstract": false,
|
||||
"complex_attributes": [
|
||||
{
|
||||
"type": "IfcProfileProperties",
|
||||
"name": "HasProperties"
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcAxis2Placement2D",
|
||||
"name": "Position"
|
||||
"name": "Position",
|
||||
"is_select": false
|
||||
}
|
||||
],
|
||||
"parent": "IfcParameterizedProfileDef"
|
||||
@@ -276,12 +268,10 @@
|
||||
"is_abstract": false,
|
||||
"complex_attributes": [
|
||||
{
|
||||
"type": "IfcProfileProperties",
|
||||
"name": "HasProperties"
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcAxis2Placement2D",
|
||||
"name": "Position"
|
||||
"name": "Position",
|
||||
"is_select": false
|
||||
}
|
||||
],
|
||||
"parent": "IfcParameterizedProfileDef"
|
||||
@@ -349,12 +339,10 @@
|
||||
"is_abstract": false,
|
||||
"complex_attributes": [
|
||||
{
|
||||
"type": "IfcProfileProperties",
|
||||
"name": "HasProperties"
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcAxis2Placement2D",
|
||||
"name": "Position"
|
||||
"name": "Position",
|
||||
"is_select": false
|
||||
}
|
||||
],
|
||||
"parent": "IfcParameterizedProfileDef"
|
||||
@@ -416,12 +404,10 @@
|
||||
"is_abstract": false,
|
||||
"complex_attributes": [
|
||||
{
|
||||
"type": "IfcProfileProperties",
|
||||
"name": "HasProperties"
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcAxis2Placement2D",
|
||||
"name": "Position"
|
||||
"name": "Position",
|
||||
"is_select": false
|
||||
}
|
||||
],
|
||||
"parent": "IfcParameterizedProfileDef"
|
||||
@@ -477,12 +463,10 @@
|
||||
"is_abstract": false,
|
||||
"complex_attributes": [
|
||||
{
|
||||
"type": "IfcProfileProperties",
|
||||
"name": "HasProperties"
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcAxis2Placement2D",
|
||||
"name": "Position"
|
||||
"name": "Position",
|
||||
"is_select": false
|
||||
}
|
||||
],
|
||||
"parent": "IfcRectangleProfileDef"
|
||||
@@ -520,12 +504,10 @@
|
||||
"is_abstract": false,
|
||||
"complex_attributes": [
|
||||
{
|
||||
"type": "IfcProfileProperties",
|
||||
"name": "HasProperties"
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcAxis2Placement2D",
|
||||
"name": "Position"
|
||||
"name": "Position",
|
||||
"is_select": false
|
||||
}
|
||||
],
|
||||
"parent": "IfcParameterizedProfileDef"
|
||||
@@ -569,12 +551,10 @@
|
||||
"is_abstract": false,
|
||||
"complex_attributes": [
|
||||
{
|
||||
"type": "IfcProfileProperties",
|
||||
"name": "HasProperties"
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcAxis2Placement2D",
|
||||
"name": "Position"
|
||||
"name": "Position",
|
||||
"is_select": false
|
||||
}
|
||||
],
|
||||
"parent": "IfcRectangleProfileDef"
|
||||
@@ -654,12 +634,10 @@
|
||||
"is_abstract": false,
|
||||
"complex_attributes": [
|
||||
{
|
||||
"type": "IfcProfileProperties",
|
||||
"name": "HasProperties"
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcAxis2Placement2D",
|
||||
"name": "Position"
|
||||
"name": "Position",
|
||||
"is_select": false
|
||||
}
|
||||
],
|
||||
"parent": "IfcParameterizedProfileDef"
|
||||
@@ -709,12 +687,10 @@
|
||||
"is_abstract": false,
|
||||
"complex_attributes": [
|
||||
{
|
||||
"type": "IfcProfileProperties",
|
||||
"name": "HasProperties"
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcAxis2Placement2D",
|
||||
"name": "Position"
|
||||
"name": "Position",
|
||||
"is_select": false
|
||||
}
|
||||
],
|
||||
"parent": "IfcParameterizedProfileDef"
|
||||
@@ -782,12 +758,10 @@
|
||||
"is_abstract": false,
|
||||
"complex_attributes": [
|
||||
{
|
||||
"type": "IfcProfileProperties",
|
||||
"name": "HasProperties"
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcAxis2Placement2D",
|
||||
"name": "Position"
|
||||
"name": "Position",
|
||||
"is_select": false
|
||||
}
|
||||
],
|
||||
"parent": "IfcParameterizedProfileDef"
|
||||
@@ -849,12 +823,10 @@
|
||||
"is_abstract": false,
|
||||
"complex_attributes": [
|
||||
{
|
||||
"type": "IfcProfileProperties",
|
||||
"name": "HasProperties"
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcAxis2Placement2D",
|
||||
"name": "Position"
|
||||
"name": "Position",
|
||||
"is_select": false
|
||||
}
|
||||
],
|
||||
"parent": "IfcParameterizedProfileDef"
|
||||
|
||||
@@ -57,48 +57,40 @@
|
||||
"is_abstract": false,
|
||||
"complex_attributes": [
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcOwnerHistory",
|
||||
"name": "OwnerHistory"
|
||||
},
|
||||
{
|
||||
"type": "IfcRelNests",
|
||||
"name": "IsNestedBy"
|
||||
},
|
||||
{
|
||||
"type": "IfcRelAggregates",
|
||||
"name": "IsDecomposedBy"
|
||||
"name": "OwnerHistory",
|
||||
"is_select": false
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcRelDefinesByObject",
|
||||
"name": "IsDeclaredBy"
|
||||
"name": "IsDeclaredBy",
|
||||
"is_select": false
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcRelDefinesByType",
|
||||
"name": "IsTypedBy"
|
||||
},
|
||||
{
|
||||
"type": "IfcRelDefinesByProperties",
|
||||
"name": "IsDefinedBy"
|
||||
"name": "IsTypedBy",
|
||||
"is_select": false
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcObjectPlacement",
|
||||
"name": "ObjectPlacement"
|
||||
"name": "ObjectPlacement",
|
||||
"is_select": false
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcProductRepresentation",
|
||||
"name": "Representation"
|
||||
},
|
||||
{
|
||||
"type": "IfcRelContainedInSpatialStructure",
|
||||
"name": "ContainsElements"
|
||||
},
|
||||
{
|
||||
"type": "IfcRelReferencedInSpatialStructure",
|
||||
"name": "ReferencesElements"
|
||||
"name": "Representation",
|
||||
"is_select": false
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcPostalAddress",
|
||||
"name": "BuildingAddress"
|
||||
"name": "BuildingAddress",
|
||||
"is_select": false
|
||||
}
|
||||
],
|
||||
"parent": "IfcSpatialStructureElement"
|
||||
@@ -155,44 +147,34 @@
|
||||
"is_abstract": false,
|
||||
"complex_attributes": [
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcOwnerHistory",
|
||||
"name": "OwnerHistory"
|
||||
},
|
||||
{
|
||||
"type": "IfcRelNests",
|
||||
"name": "IsNestedBy"
|
||||
},
|
||||
{
|
||||
"type": "IfcRelAggregates",
|
||||
"name": "IsDecomposedBy"
|
||||
"name": "OwnerHistory",
|
||||
"is_select": false
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcRelDefinesByObject",
|
||||
"name": "IsDeclaredBy"
|
||||
"name": "IsDeclaredBy",
|
||||
"is_select": false
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcRelDefinesByType",
|
||||
"name": "IsTypedBy"
|
||||
},
|
||||
{
|
||||
"type": "IfcRelDefinesByProperties",
|
||||
"name": "IsDefinedBy"
|
||||
"name": "IsTypedBy",
|
||||
"is_select": false
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcObjectPlacement",
|
||||
"name": "ObjectPlacement"
|
||||
"name": "ObjectPlacement",
|
||||
"is_select": false
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcProductRepresentation",
|
||||
"name": "Representation"
|
||||
},
|
||||
{
|
||||
"type": "IfcRelContainedInSpatialStructure",
|
||||
"name": "ContainsElements"
|
||||
},
|
||||
{
|
||||
"type": "IfcRelReferencedInSpatialStructure",
|
||||
"name": "ReferencesElements"
|
||||
"name": "Representation",
|
||||
"is_select": false
|
||||
}
|
||||
],
|
||||
"parent": "IfcSpatialStructureElement"
|
||||
@@ -267,48 +249,40 @@
|
||||
"is_abstract": false,
|
||||
"complex_attributes": [
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcOwnerHistory",
|
||||
"name": "OwnerHistory"
|
||||
},
|
||||
{
|
||||
"type": "IfcRelNests",
|
||||
"name": "IsNestedBy"
|
||||
},
|
||||
{
|
||||
"type": "IfcRelAggregates",
|
||||
"name": "IsDecomposedBy"
|
||||
"name": "OwnerHistory",
|
||||
"is_select": false
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcRelDefinesByObject",
|
||||
"name": "IsDeclaredBy"
|
||||
"name": "IsDeclaredBy",
|
||||
"is_select": false
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcRelDefinesByType",
|
||||
"name": "IsTypedBy"
|
||||
},
|
||||
{
|
||||
"type": "IfcRelDefinesByProperties",
|
||||
"name": "IsDefinedBy"
|
||||
"name": "IsTypedBy",
|
||||
"is_select": false
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcObjectPlacement",
|
||||
"name": "ObjectPlacement"
|
||||
"name": "ObjectPlacement",
|
||||
"is_select": false
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcProductRepresentation",
|
||||
"name": "Representation"
|
||||
},
|
||||
{
|
||||
"type": "IfcRelContainedInSpatialStructure",
|
||||
"name": "ContainsElements"
|
||||
},
|
||||
{
|
||||
"type": "IfcRelReferencedInSpatialStructure",
|
||||
"name": "ReferencesElements"
|
||||
"name": "Representation",
|
||||
"is_select": false
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcPostalAddress",
|
||||
"name": "SiteAddress"
|
||||
"name": "SiteAddress",
|
||||
"is_select": false
|
||||
}
|
||||
],
|
||||
"parent": "IfcSpatialStructureElement"
|
||||
@@ -379,44 +353,34 @@
|
||||
"is_abstract": false,
|
||||
"complex_attributes": [
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcOwnerHistory",
|
||||
"name": "OwnerHistory"
|
||||
},
|
||||
{
|
||||
"type": "IfcRelNests",
|
||||
"name": "IsNestedBy"
|
||||
},
|
||||
{
|
||||
"type": "IfcRelAggregates",
|
||||
"name": "IsDecomposedBy"
|
||||
"name": "OwnerHistory",
|
||||
"is_select": false
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcRelDefinesByObject",
|
||||
"name": "IsDeclaredBy"
|
||||
"name": "IsDeclaredBy",
|
||||
"is_select": false
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcRelDefinesByType",
|
||||
"name": "IsTypedBy"
|
||||
},
|
||||
{
|
||||
"type": "IfcRelDefinesByProperties",
|
||||
"name": "IsDefinedBy"
|
||||
"name": "IsTypedBy",
|
||||
"is_select": false
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcObjectPlacement",
|
||||
"name": "ObjectPlacement"
|
||||
"name": "ObjectPlacement",
|
||||
"is_select": false
|
||||
},
|
||||
{
|
||||
"select_types": [],
|
||||
"type": "IfcProductRepresentation",
|
||||
"name": "Representation"
|
||||
},
|
||||
{
|
||||
"type": "IfcRelContainedInSpatialStructure",
|
||||
"name": "ContainsElements"
|
||||
},
|
||||
{
|
||||
"type": "IfcRelReferencedInSpatialStructure",
|
||||
"name": "ReferencesElements"
|
||||
"name": "Representation",
|
||||
"is_select": false
|
||||
}
|
||||
],
|
||||
"parent": "IfcSpatialStructureElement"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -11,38 +11,31 @@ class IFC4Extractor:
|
||||
self.root = tree.getroot()
|
||||
self.ns = {'xs': 'http://www.w3.org/2001/XMLSchema'}
|
||||
self.elements = {}
|
||||
#self.filters = ['IfcBuildingElement']
|
||||
#self.filters = ['IfcElement']
|
||||
#self.filters = ['IfcSpatialStructureElement']
|
||||
#self.filters = ['IfcStructuralActivity', 'IfcStructuralItem']
|
||||
#self.filters = ['IfcMaterialDefinition']
|
||||
#self.filters = ['IfcParameterizedProfileDef']
|
||||
self.filters = ['IfcBoundaryCondition']
|
||||
self.filters = []
|
||||
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, "IfcBoundaryCondition"):
|
||||
print('Processing {}'.format(element.attrib['name']))
|
||||
data = {
|
||||
'is_abstract': self.is_abstract(element),
|
||||
'parent': element.attrib['substitutionGroup'].replace('ifc:', ''),
|
||||
'attributes': self.get_attributes(element),
|
||||
'complex_attributes': self.get_complex_attributes(element)
|
||||
}
|
||||
self.elements[element.attrib['name']] = data
|
||||
for filter in self.filters:
|
||||
if self.is_descendant_from_class(element, filter):
|
||||
self.filtered_elements.setdefault(filter, {})[element.attrib['name']] = data
|
||||
print('Processing {}'.format(element.attrib['name']))
|
||||
if not 'substitutionGroup' in element.attrib \
|
||||
or self.is_descendant_from_class(element, 'uos'):
|
||||
continue
|
||||
data = {
|
||||
'is_abstract': self.is_abstract(element),
|
||||
'parent': element.attrib['substitutionGroup'].replace('ifc:', ''),
|
||||
'attributes': self.get_attributes(element),
|
||||
'complex_attributes': self.get_complex_attributes(element)
|
||||
}
|
||||
self.elements[element.attrib['name']] = data
|
||||
for filter in self.filters:
|
||||
if self.is_descendant_from_class(element, filter):
|
||||
self.filtered_elements.setdefault(filter, {})[element.attrib['name']] = data
|
||||
|
||||
def export(self):
|
||||
def export(self, filename):
|
||||
final = {}
|
||||
for filter in self.filters:
|
||||
final.update(self.filtered_elements[filter])
|
||||
with open("output.json", "w") as file:
|
||||
with open(filename, "w") as file:
|
||||
file.write(json.dumps(collections.OrderedDict(sorted(final.items())), indent=4))
|
||||
|
||||
def is_descendant_from_class(self, element, class_name):
|
||||
@@ -91,7 +84,9 @@ class IFC4Extractor:
|
||||
if 'type' in attribute.attrib:
|
||||
attributes.append({
|
||||
'name': attribute.attrib['name'],
|
||||
'type': attribute.attrib['type'].replace('ifc:', '')
|
||||
'type': attribute.attrib['type'].replace('ifc:', ''),
|
||||
'is_select': False,
|
||||
'select_types': []
|
||||
})
|
||||
else:
|
||||
type_element = attribute.find('./xs:complexType/xs:sequence/xs:element[@ref]', self.ns)
|
||||
@@ -102,7 +97,7 @@ class IFC4Extractor:
|
||||
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
|
||||
select_types = [e.attrib['ref'].replace('ifc:', '').replace('-wrapper', '') for e in
|
||||
self.root.findall("./xs:group[@name='{}']/xs:choice/xs:element[@ref]".format(
|
||||
type_element.attrib['ref'].replace('ifc:', '')
|
||||
), self.ns)]
|
||||
@@ -149,7 +144,18 @@ class IFC2X3Extractor(IFC4Extractor):
|
||||
def get_complex_attributes(self, element, attributes = None):
|
||||
return []
|
||||
|
||||
extractor = IFC4Extractor("IFC4_ADD2.xsd")
|
||||
#extractor = IFC2X3Extractor("IFC2X3.xsd")
|
||||
extractor.extract()
|
||||
extractor.export()
|
||||
filename_filters = {
|
||||
'IfcElement_IFC4.json': ['IfcElement'],
|
||||
'IfcSpatialStructureElement_IFC4.json': ['IfcSpatialStructureElement'],
|
||||
'IfcStructural_IFC4.json': ['IfcStructuralActivity', 'IfcStructuralItem'],
|
||||
'IfcMaterialDefinition_IFC4.json': ['IfcMaterialDefinition'],
|
||||
'IfcParameterizedProfileDef_IFC4.json': ['IfcParameterizedProfileDef'],
|
||||
'IfcBoundaryCondition_IFC4.json': ['IfcBoundaryCondition']
|
||||
}
|
||||
|
||||
for filename, filters in filename_filters.items():
|
||||
extractor = IFC4Extractor("IFC4_ADD2.xsd")
|
||||
extractor.filters = filters
|
||||
#extractor = IFC2X3Extractor("IFC2X3.xsd")
|
||||
extractor.extract()
|
||||
extractor.export(filename)
|
||||
|
||||
Reference in New Issue
Block a user