mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 17:58:20 +00:00
Implement IFC import mesh reuse for mapped representations
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user