mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 17:31:45 +00:00
Safer BlendData access
To avoid issues like #6771 when we by accident find an ID data-block from linked .blend file.
This commit is contained in:
@@ -856,7 +856,7 @@ class IfcImporter:
|
||||
return obj
|
||||
|
||||
def load_existing_meshes(self) -> None:
|
||||
self.meshes.update({m.name: m for m in bpy.data.meshes})
|
||||
self.meshes.update({m.name: m for m in bpy.data.meshes if m.library is None})
|
||||
|
||||
def merge_materials_by_colour(self):
|
||||
cleaned_materials = {}
|
||||
@@ -1075,7 +1075,7 @@ class IfcImporter:
|
||||
# Mesh may already exists (e.g. during representation reimport)
|
||||
# and we assign some suffix to it to prevent Blender from adding '.001' suffix to the new mesh.
|
||||
mesh_name = tool.Loader.get_mesh_name_from_shape(geometry)
|
||||
if old_mesh := bpy.data.meshes.get(mesh_name):
|
||||
if old_mesh := bpy.data.meshes.get((mesh_name, None)):
|
||||
old_mesh.name = mesh_name + ".old"
|
||||
mesh = bpy.data.meshes.new(mesh_name)
|
||||
|
||||
|
||||
@@ -674,7 +674,7 @@ class Geometry(bonsai.core.tool.Geometry):
|
||||
|
||||
@classmethod
|
||||
def get_representation_data(cls, representation: ifcopenshell.entity_instance) -> Union[bpy.types.Mesh, None]:
|
||||
return bpy.data.meshes.get(cls.get_representation_name(representation))
|
||||
return bpy.data.meshes.get((cls.get_representation_name(representation), None))
|
||||
|
||||
@classmethod
|
||||
def get_representation_id(cls, representation: ifcopenshell.entity_instance) -> int:
|
||||
|
||||
Reference in New Issue
Block a user