Add export support for CAD presentation layer assignment

This commit is contained in:
Dion Moult
2020-04-13 18:24:47 +10:00
parent ddc37ab4d1
commit 442ab790d4
3 changed files with 19 additions and 0 deletions
@@ -120,6 +120,7 @@ class IfcParser():
self.rel_projects_elements = {} self.rel_projects_elements = {}
self.rel_connects_structural_member = {} self.rel_connects_structural_member = {}
self.rel_assigns_to_group = {} self.rel_assigns_to_group = {}
self.presentation_layer_assignments = {}
self.representations = {} self.representations = {}
self.type_products = [] self.type_products = []
self.door_attributes = {} self.door_attributes = {}
@@ -142,6 +143,7 @@ class IfcParser():
self.classification_references = self.get_classification_references() self.classification_references = self.get_classification_references()
self.objectives = self.get_objectives() self.objectives = self.get_objectives()
self.load_representations() self.load_representations()
self.load_presentation_layer_assignments()
self.materials = self.get_materials() self.materials = self.get_materials()
self.styled_items = self.get_styled_items() self.styled_items = self.get_styled_items()
self.spatial_structure_elements = self.get_spatial_structure_elements() self.spatial_structure_elements = self.get_spatial_structure_elements()
@@ -796,6 +798,12 @@ class IfcParser():
}) })
return elements return elements
def load_presentation_layer_assignments(self):
for representation in self.representations.values():
if representation['presentation_layer']:
self.presentation_layer_assignments.setdefault(
representation['presentation_layer'], []).append(representation)
def load_representations(self): def load_representations(self):
if not self.ifc_export_settings.has_representations: if not self.ifc_export_settings.has_representations:
return return
@@ -896,6 +904,7 @@ class IfcParser():
'is_wireframe': mesh.BIMMeshProperties.is_wireframe if hasattr(mesh, 'BIMMeshProperties') else False, 'is_wireframe': mesh.BIMMeshProperties.is_wireframe if hasattr(mesh, 'BIMMeshProperties') else False,
'is_swept_solid': mesh.BIMMeshProperties.is_swept_solid if hasattr(mesh, 'BIMMeshProperties') else False, 'is_swept_solid': mesh.BIMMeshProperties.is_swept_solid if hasattr(mesh, 'BIMMeshProperties') else False,
'is_generated': False, 'is_generated': False,
'presentation_layer': mesh.BIMMeshProperties.presentation_layer,
'attributes': {'Name': mesh.name} 'attributes': {'Name': mesh.name}
} }
@@ -1126,6 +1135,7 @@ class IfcExporter():
self.create_qtos() self.create_qtos()
self.create_products() self.create_products()
self.create_styled_items() self.create_styled_items()
self.create_presentation_layer_assignments()
self.relate_definitions_to_contexts() self.relate_definitions_to_contexts()
self.relate_objects_to_objects() self.relate_objects_to_objects()
self.relate_elements_to_spatial_structures() self.relate_elements_to_spatial_structures()
@@ -1631,6 +1641,11 @@ class IfcExporter():
surface_style = self.file.createIfcPresentationStyleAssignment([surface_style]) surface_style = self.file.createIfcPresentationStyleAssignment([surface_style])
return self.file.createIfcStyledItem(representation_item, [surface_style], item['attributes']['Name']) return self.file.createIfcStyledItem(representation_item, [surface_style], item['attributes']['Name'])
def create_presentation_layer_assignments(self):
for name, assigned_items in self.ifc_parser.presentation_layer_assignments.items():
self.file.createIfcPresentationLayerAssignment(
name, None, [i['ifc'].MappedRepresentation for i in assigned_items], None)
def create_materials(self): def create_materials(self):
for material in self.ifc_parser.materials.values(): for material in self.ifc_parser.materials.values():
styled_item = self.create_styled_item(material) styled_item = self.create_styled_item(material)
@@ -779,3 +779,4 @@ class BIMMeshProperties(PropertyGroup):
is_swept_solid: BoolProperty(name="Is Swept Solid") is_swept_solid: BoolProperty(name="Is Swept Solid")
swept_solids: CollectionProperty(name="Swept Solids", type=SweptSolid) swept_solids: CollectionProperty(name="Swept Solids", type=SweptSolid)
is_parametric: BoolProperty(name='Is Parametric', default=False) is_parametric: BoolProperty(name='Is Parametric', default=False)
presentation_layer: StringProperty(name="Presentation Layer")
@@ -159,6 +159,9 @@ class BIM_PT_mesh(Panel):
row = layout.row() row = layout.row()
row.operator('bim.assign_context') row.operator('bim.assign_context')
row = layout.row()
row.prop(props, 'presentation_layer')
row = layout.row() row = layout.row()
row.prop(props, 'is_parametric') row.prop(props, 'is_parametric')