mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-12 02:23:34 +00:00
Add export support for CAD presentation layer assignment
This commit is contained in:
@@ -120,6 +120,7 @@ class IfcParser():
|
||||
self.rel_projects_elements = {}
|
||||
self.rel_connects_structural_member = {}
|
||||
self.rel_assigns_to_group = {}
|
||||
self.presentation_layer_assignments = {}
|
||||
self.representations = {}
|
||||
self.type_products = []
|
||||
self.door_attributes = {}
|
||||
@@ -142,6 +143,7 @@ class IfcParser():
|
||||
self.classification_references = self.get_classification_references()
|
||||
self.objectives = self.get_objectives()
|
||||
self.load_representations()
|
||||
self.load_presentation_layer_assignments()
|
||||
self.materials = self.get_materials()
|
||||
self.styled_items = self.get_styled_items()
|
||||
self.spatial_structure_elements = self.get_spatial_structure_elements()
|
||||
@@ -796,6 +798,12 @@ class IfcParser():
|
||||
})
|
||||
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):
|
||||
if not self.ifc_export_settings.has_representations:
|
||||
return
|
||||
@@ -896,6 +904,7 @@ class IfcParser():
|
||||
'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_generated': False,
|
||||
'presentation_layer': mesh.BIMMeshProperties.presentation_layer,
|
||||
'attributes': {'Name': mesh.name}
|
||||
}
|
||||
|
||||
@@ -1126,6 +1135,7 @@ class IfcExporter():
|
||||
self.create_qtos()
|
||||
self.create_products()
|
||||
self.create_styled_items()
|
||||
self.create_presentation_layer_assignments()
|
||||
self.relate_definitions_to_contexts()
|
||||
self.relate_objects_to_objects()
|
||||
self.relate_elements_to_spatial_structures()
|
||||
@@ -1631,6 +1641,11 @@ class IfcExporter():
|
||||
surface_style = self.file.createIfcPresentationStyleAssignment([surface_style])
|
||||
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):
|
||||
for material in self.ifc_parser.materials.values():
|
||||
styled_item = self.create_styled_item(material)
|
||||
|
||||
@@ -779,3 +779,4 @@ class BIMMeshProperties(PropertyGroup):
|
||||
is_swept_solid: BoolProperty(name="Is Swept Solid")
|
||||
swept_solids: CollectionProperty(name="Swept Solids", type=SweptSolid)
|
||||
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.operator('bim.assign_context')
|
||||
|
||||
row = layout.row()
|
||||
row.prop(props, 'presentation_layer')
|
||||
|
||||
row = layout.row()
|
||||
row.prop(props, 'is_parametric')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user