Add ability to export parameterised profiles for material profiles.

This commit is contained in:
Dion Moult
2020-01-14 17:38:54 +11:00
parent 8490dc7841
commit 71f836d013
6 changed files with 916 additions and 9 deletions
+15 -6
View File
@@ -1448,12 +1448,21 @@ class IfcExporter():
self.create_material_psets(material)
self.file.createIfcMaterialDefinitionRepresentation(
material['raw'].name, None, [styled_representation], material['ifc'])
if material['material_type'] != 'IfcMaterial':
material_type = material['material_type'][0:-3]
self.cast_attributes(material_type, material['attributes'])
material['attributes']['Material'] = material['ifc']
material['part_ifc'] = self.file.create_entity(material_type,
**material['attributes'])
if material['material_type'] == 'IfcMaterial':
continue
material_type = material['material_type'][0:-3]
self.cast_attributes(material_type, material['attributes'])
material['attributes']['Material'] = material['ifc']
if material_type == 'IfcMaterialProfile':
material['attributes']['Profile'] = self.create_material_profile(material)
material['part_ifc'] = self.file.create_entity(material_type,
**material['attributes'])
def create_material_profile(self, material):
ifc_class = material['raw'].BIMMaterialProperties.profile_def
attributes = {a.name: a.string_value for a in material['raw'].BIMMaterialProperties.profile_attributes}
self.cast_attributes(ifc_class, attributes)
return self.file.create_entity(ifc_class, **attributes)
def cast_attributes(self, ifc_class, attributes):
for key, value in attributes.items():
+18
View File
@@ -22,6 +22,7 @@ ifc_schema = IfcSchema()
diagram_scales_enum = []
products_enum = []
profiledef_enum = []
classes_enum = []
types_enum = []
availablematerialpsets_enum = []
@@ -109,6 +110,13 @@ def getIfcClasses(self, context):
return classes_enum
def getProfileDef(self, context):
global profiledef_enum
if len(profiledef_enum) < 1:
profiledef_enum.extend([(e, e, '') for e in getattr(ifc_schema, 'IfcParameterizedProfileDef')])
return profiledef_enum
def getPersons(self, context):
global persons_enum
if len(persons_enum) < 1:
@@ -219,6 +227,14 @@ def getApplicableMaterialAttributes(self, context):
return materialattributes_enum
def refreshProfileAttributes(self, context):
while len(context.active_object.active_material.BIMMaterialProperties.profile_attributes) > 0:
context.active_object.active_material.BIMMaterialProperties.profile_attributes.remove(0)
for attribute in ifc_schema.IfcParameterizedProfileDef[self.profile_def]['attributes']:
profile_attribute = context.active_object.active_material.BIMMaterialProperties.profile_attributes.add()
profile_attribute.name = attribute['name']
def getApplicableDocuments(self, context):
global documents_enum
documents_enum.clear()
@@ -401,6 +417,8 @@ class BIMMaterialProperties(PropertyGroup):
psets: CollectionProperty(name="Psets", type=Pset)
attributes: CollectionProperty(name="Attributes", type=Attribute)
applicable_attributes: EnumProperty(items=getApplicableMaterialAttributes, name="Attribute Names")
profile_def: EnumProperty(items=getProfileDef, name='Parameterized Profile Def', update=refreshProfileAttributes)
profile_attributes: CollectionProperty(name='Profile Attributes', type=Attribute)
class SweptSolid(PropertyGroup):
+7 -1
View File
@@ -7,7 +7,13 @@ cwd = os.path.dirname(os.path.realpath(__file__))
class IfcSchema():
def __init__(self):
self.schema_dir = os.path.join(cwd, 'schema') # TODO: make configurable
self.products = ['IfcElement', 'IfcSpatialStructureElement', 'IfcStructural', 'IfcMaterialDefinition']
self.products = [
'IfcElement',
'IfcSpatialStructureElement',
'IfcStructural',
'IfcMaterialDefinition',
'IfcParameterizedProfileDef'
]
self.elements = {}
self.property_file = ifcopenshell.open(os.path.join(self.schema_dir, 'IFC4_ADD2.ifc'))
self.psets = {}
@@ -0,0 +1,862 @@
{
"IfcAsymmetricIShapeProfileDef": {
"attributes": [
{
"enum_values": [
"CURVE",
"AREA"
],
"type": "IfcProfileTypeEnum",
"name": "ProfileType",
"is_enum": true
},
{
"enum_values": [],
"type": "IfcLabel",
"name": "ProfileName",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "BottomFlangeWidth",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "OverallDepth",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "WebThickness",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "BottomFlangeThickness",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcNonNegativeLengthMeasure",
"name": "BottomFlangeFilletRadius",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "TopFlangeWidth",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "TopFlangeThickness",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcNonNegativeLengthMeasure",
"name": "TopFlangeFilletRadius",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcNonNegativeLengthMeasure",
"name": "BottomFlangeEdgeRadius",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPlaneAngleMeasure",
"name": "BottomFlangeSlope",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcNonNegativeLengthMeasure",
"name": "TopFlangeEdgeRadius",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPlaneAngleMeasure",
"name": "TopFlangeSlope",
"is_enum": false
}
],
"is_abstract": false,
"complex_attributes": [
{
"type": "IfcProfileProperties",
"name": "HasProperties"
},
{
"type": "IfcAxis2Placement2D",
"name": "Position"
}
],
"parent": "IfcParameterizedProfileDef"
},
"IfcCShapeProfileDef": {
"attributes": [
{
"enum_values": [
"CURVE",
"AREA"
],
"type": "IfcProfileTypeEnum",
"name": "ProfileType",
"is_enum": true
},
{
"enum_values": [],
"type": "IfcLabel",
"name": "ProfileName",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "Depth",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "Width",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "WallThickness",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "Girth",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcNonNegativeLengthMeasure",
"name": "InternalFilletRadius",
"is_enum": false
}
],
"is_abstract": false,
"complex_attributes": [
{
"type": "IfcProfileProperties",
"name": "HasProperties"
},
{
"type": "IfcAxis2Placement2D",
"name": "Position"
}
],
"parent": "IfcParameterizedProfileDef"
},
"IfcCircleHollowProfileDef": {
"attributes": [
{
"enum_values": [
"CURVE",
"AREA"
],
"type": "IfcProfileTypeEnum",
"name": "ProfileType",
"is_enum": true
},
{
"enum_values": [],
"type": "IfcLabel",
"name": "ProfileName",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "Radius",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "WallThickness",
"is_enum": false
}
],
"is_abstract": false,
"complex_attributes": [
{
"type": "IfcProfileProperties",
"name": "HasProperties"
},
{
"type": "IfcAxis2Placement2D",
"name": "Position"
}
],
"parent": "IfcCircleProfileDef"
},
"IfcCircleProfileDef": {
"attributes": [
{
"enum_values": [
"CURVE",
"AREA"
],
"type": "IfcProfileTypeEnum",
"name": "ProfileType",
"is_enum": true
},
{
"enum_values": [],
"type": "IfcLabel",
"name": "ProfileName",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "Radius",
"is_enum": false
}
],
"is_abstract": false,
"complex_attributes": [
{
"type": "IfcProfileProperties",
"name": "HasProperties"
},
{
"type": "IfcAxis2Placement2D",
"name": "Position"
}
],
"parent": "IfcParameterizedProfileDef"
},
"IfcEllipseProfileDef": {
"attributes": [
{
"enum_values": [
"CURVE",
"AREA"
],
"type": "IfcProfileTypeEnum",
"name": "ProfileType",
"is_enum": true
},
{
"enum_values": [],
"type": "IfcLabel",
"name": "ProfileName",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "SemiAxis1",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "SemiAxis2",
"is_enum": false
}
],
"is_abstract": false,
"complex_attributes": [
{
"type": "IfcProfileProperties",
"name": "HasProperties"
},
{
"type": "IfcAxis2Placement2D",
"name": "Position"
}
],
"parent": "IfcParameterizedProfileDef"
},
"IfcIShapeProfileDef": {
"attributes": [
{
"enum_values": [
"CURVE",
"AREA"
],
"type": "IfcProfileTypeEnum",
"name": "ProfileType",
"is_enum": true
},
{
"enum_values": [],
"type": "IfcLabel",
"name": "ProfileName",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "OverallWidth",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "OverallDepth",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "WebThickness",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "FlangeThickness",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcNonNegativeLengthMeasure",
"name": "FilletRadius",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcNonNegativeLengthMeasure",
"name": "FlangeEdgeRadius",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPlaneAngleMeasure",
"name": "FlangeSlope",
"is_enum": false
}
],
"is_abstract": false,
"complex_attributes": [
{
"type": "IfcProfileProperties",
"name": "HasProperties"
},
{
"type": "IfcAxis2Placement2D",
"name": "Position"
}
],
"parent": "IfcParameterizedProfileDef"
},
"IfcLShapeProfileDef": {
"attributes": [
{
"enum_values": [
"CURVE",
"AREA"
],
"type": "IfcProfileTypeEnum",
"name": "ProfileType",
"is_enum": true
},
{
"enum_values": [],
"type": "IfcLabel",
"name": "ProfileName",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "Depth",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "Width",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "Thickness",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcNonNegativeLengthMeasure",
"name": "FilletRadius",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcNonNegativeLengthMeasure",
"name": "EdgeRadius",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPlaneAngleMeasure",
"name": "LegSlope",
"is_enum": false
}
],
"is_abstract": false,
"complex_attributes": [
{
"type": "IfcProfileProperties",
"name": "HasProperties"
},
{
"type": "IfcAxis2Placement2D",
"name": "Position"
}
],
"parent": "IfcParameterizedProfileDef"
},
"IfcRectangleHollowProfileDef": {
"attributes": [
{
"enum_values": [
"CURVE",
"AREA"
],
"type": "IfcProfileTypeEnum",
"name": "ProfileType",
"is_enum": true
},
{
"enum_values": [],
"type": "IfcLabel",
"name": "ProfileName",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "XDim",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "YDim",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "WallThickness",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcNonNegativeLengthMeasure",
"name": "InnerFilletRadius",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcNonNegativeLengthMeasure",
"name": "OuterFilletRadius",
"is_enum": false
}
],
"is_abstract": false,
"complex_attributes": [
{
"type": "IfcProfileProperties",
"name": "HasProperties"
},
{
"type": "IfcAxis2Placement2D",
"name": "Position"
}
],
"parent": "IfcRectangleProfileDef"
},
"IfcRectangleProfileDef": {
"attributes": [
{
"enum_values": [
"CURVE",
"AREA"
],
"type": "IfcProfileTypeEnum",
"name": "ProfileType",
"is_enum": true
},
{
"enum_values": [],
"type": "IfcLabel",
"name": "ProfileName",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "XDim",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "YDim",
"is_enum": false
}
],
"is_abstract": false,
"complex_attributes": [
{
"type": "IfcProfileProperties",
"name": "HasProperties"
},
{
"type": "IfcAxis2Placement2D",
"name": "Position"
}
],
"parent": "IfcParameterizedProfileDef"
},
"IfcRoundedRectangleProfileDef": {
"attributes": [
{
"enum_values": [
"CURVE",
"AREA"
],
"type": "IfcProfileTypeEnum",
"name": "ProfileType",
"is_enum": true
},
{
"enum_values": [],
"type": "IfcLabel",
"name": "ProfileName",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "XDim",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "YDim",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "RoundingRadius",
"is_enum": false
}
],
"is_abstract": false,
"complex_attributes": [
{
"type": "IfcProfileProperties",
"name": "HasProperties"
},
{
"type": "IfcAxis2Placement2D",
"name": "Position"
}
],
"parent": "IfcRectangleProfileDef"
},
"IfcTShapeProfileDef": {
"attributes": [
{
"enum_values": [
"CURVE",
"AREA"
],
"type": "IfcProfileTypeEnum",
"name": "ProfileType",
"is_enum": true
},
{
"enum_values": [],
"type": "IfcLabel",
"name": "ProfileName",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "Depth",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "FlangeWidth",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "WebThickness",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "FlangeThickness",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcNonNegativeLengthMeasure",
"name": "FilletRadius",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcNonNegativeLengthMeasure",
"name": "FlangeEdgeRadius",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcNonNegativeLengthMeasure",
"name": "WebEdgeRadius",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPlaneAngleMeasure",
"name": "WebSlope",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPlaneAngleMeasure",
"name": "FlangeSlope",
"is_enum": false
}
],
"is_abstract": false,
"complex_attributes": [
{
"type": "IfcProfileProperties",
"name": "HasProperties"
},
{
"type": "IfcAxis2Placement2D",
"name": "Position"
}
],
"parent": "IfcParameterizedProfileDef"
},
"IfcTrapeziumProfileDef": {
"attributes": [
{
"enum_values": [
"CURVE",
"AREA"
],
"type": "IfcProfileTypeEnum",
"name": "ProfileType",
"is_enum": true
},
{
"enum_values": [],
"type": "IfcLabel",
"name": "ProfileName",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "BottomXDim",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "TopXDim",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "YDim",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcLengthMeasure",
"name": "TopXOffset",
"is_enum": false
}
],
"is_abstract": false,
"complex_attributes": [
{
"type": "IfcProfileProperties",
"name": "HasProperties"
},
{
"type": "IfcAxis2Placement2D",
"name": "Position"
}
],
"parent": "IfcParameterizedProfileDef"
},
"IfcUShapeProfileDef": {
"attributes": [
{
"enum_values": [
"CURVE",
"AREA"
],
"type": "IfcProfileTypeEnum",
"name": "ProfileType",
"is_enum": true
},
{
"enum_values": [],
"type": "IfcLabel",
"name": "ProfileName",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "Depth",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "FlangeWidth",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "WebThickness",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "FlangeThickness",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcNonNegativeLengthMeasure",
"name": "FilletRadius",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcNonNegativeLengthMeasure",
"name": "EdgeRadius",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPlaneAngleMeasure",
"name": "FlangeSlope",
"is_enum": false
}
],
"is_abstract": false,
"complex_attributes": [
{
"type": "IfcProfileProperties",
"name": "HasProperties"
},
{
"type": "IfcAxis2Placement2D",
"name": "Position"
}
],
"parent": "IfcParameterizedProfileDef"
},
"IfcZShapeProfileDef": {
"attributes": [
{
"enum_values": [
"CURVE",
"AREA"
],
"type": "IfcProfileTypeEnum",
"name": "ProfileType",
"is_enum": true
},
{
"enum_values": [],
"type": "IfcLabel",
"name": "ProfileName",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "Depth",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "FlangeWidth",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "WebThickness",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcPositiveLengthMeasure",
"name": "FlangeThickness",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcNonNegativeLengthMeasure",
"name": "FilletRadius",
"is_enum": false
},
{
"enum_values": [],
"type": "IfcNonNegativeLengthMeasure",
"name": "EdgeRadius",
"is_enum": false
}
],
"is_abstract": false,
"complex_attributes": [
{
"type": "IfcProfileProperties",
"name": "HasProperties"
},
{
"type": "IfcAxis2Placement2D",
"name": "Position"
}
],
"parent": "IfcParameterizedProfileDef"
}
}
+10
View File
@@ -191,6 +191,16 @@ class BIM_PT_material(Panel):
row = layout.row()
row.prop(props, 'psets', text='')
if context.active_object.BIMObjectProperties.material_type == 'IfcMaterialProfileSet':
layout.label(text="Profile Definition:")
row = layout.row()
row.prop(props, 'profile_def')
for index, attribute in enumerate(props.profile_attributes):
row = layout.row(align=True)
row.prop(attribute, 'name', text='')
row.prop(attribute, 'string_value', text='')
class BIM_PT_gis(Panel):
bl_label = 'IFC Georeferencing'
+4 -2
View File
@@ -15,13 +15,15 @@ class IFC4Extractor:
#self.filters = ['IfcElement']
#self.filters = ['IfcSpatialStructureElement']
#self.filters = ['IfcStructuralActivity', 'IfcStructuralItem']
self.filters = ['IfcMaterialDefinition']
#self.filters = ['IfcMaterialDefinition']
self.filters = ['IfcParameterizedProfileDef']
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, "IfcMaterialDefinition"):
if self.is_descendant_from_class(element, "IfcParameterizedProfileDef"):
print('Processing {}'.format(element.attrib['name']))
data = {
'is_abstract': self.is_abstract(element),