mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-19 22:50:21 +00:00
Implement IFC import mesh reuse for mapped representations
This commit is contained in:
@@ -115,7 +115,8 @@ class IfcImporter():
|
|||||||
except:
|
except:
|
||||||
print('Failed to generate shape for {}'.format(element))
|
print('Failed to generate shape for {}'.format(element))
|
||||||
return
|
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)
|
mesh = self.meshes.get(mesh_name)
|
||||||
if mesh is None:
|
if mesh is None:
|
||||||
@@ -148,6 +149,18 @@ class IfcImporter():
|
|||||||
else:
|
else:
|
||||||
bpy.context.scene.collection.objects.link(object)
|
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):
|
def create_mesh(self, element, shape):
|
||||||
try:
|
try:
|
||||||
mesh = bpy.data.meshes.new(shape.geometry.id)
|
mesh = bpy.data.meshes.new(shape.geometry.id)
|
||||||
|
|||||||
Reference in New Issue
Block a user