diff --git a/src/ifcblenderexport/io_export_ifc/import_ifc.py b/src/ifcblenderexport/io_export_ifc/import_ifc.py index 994bba95b9..c0436939d0 100644 --- a/src/ifcblenderexport/io_export_ifc/import_ifc.py +++ b/src/ifcblenderexport/io_export_ifc/import_ifc.py @@ -115,7 +115,8 @@ class IfcImporter(): except: print('Failed to generate shape for {}'.format(element)) return - mesh_name = 'mesh-{}'.format(shape.geometry.id) + representation_id = self.get_representation_id(element) + mesh_name = 'mesh-{}'.format(representation_id) mesh = self.meshes.get(mesh_name) if mesh is None: @@ -148,6 +149,18 @@ class IfcImporter(): else: bpy.context.scene.collection.objects.link(object) + def get_representation_id(self, element): + if not element.Representation: + return None + for representation in element.Representation.Representations: + if not representation.is_a('IfcShapeRepresentation'): + continue + if representation.RepresentationIdentifier == 'Body' \ + and representation.RepresentationType != 'MappedRepresentation': + return representation.id() + elif representation.RepresentationIdentifier == 'Body': + return representation.Items[0].MappingSource.MappedRepresentation.id() + def create_mesh(self, element, shape): try: mesh = bpy.data.meshes.new(shape.geometry.id)