mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-09 09:21:46 +00:00
Fixed issues with linked elements from linked blend files #4081
In #4081 reported the case when during redo (changing param in operator's popup) `Ifc.rebuild_element_maps` was relinking elements without discarding possible linked blender libraries. It end up accidentally linking some library's objects to the current Ifc file leading to errors. Also fixed possible similar issue in couple other places.
This commit is contained in:
@@ -163,8 +163,12 @@ class IfcStore:
|
||||
if not IfcStore.get_file():
|
||||
return
|
||||
for obj in bpy.data.objects:
|
||||
if obj.library:
|
||||
continue
|
||||
IfcStore.relink_object(obj)
|
||||
for obj in bpy.data.materials:
|
||||
if obj.library:
|
||||
continue
|
||||
IfcStore.relink_object(obj)
|
||||
|
||||
@staticmethod
|
||||
|
||||
@@ -670,6 +670,8 @@ class ReloadIfcFile(bpy.types.Operator, tool.Ifc.Operator):
|
||||
# STEP IDs may change, but we assume the GlobalID to be constant
|
||||
obj_map = {}
|
||||
for obj in bpy.data.objects:
|
||||
if obj.library:
|
||||
continue
|
||||
element = tool.Ifc.get_entity(obj)
|
||||
if element and hasattr(element, "GlobalId"):
|
||||
obj_map[obj.name] = element.GlobalId
|
||||
@@ -678,6 +680,8 @@ class ReloadIfcFile(bpy.types.Operator, tool.Ifc.Operator):
|
||||
tool.Ifc.set(new)
|
||||
|
||||
for obj in bpy.data.objects:
|
||||
if obj.library:
|
||||
continue
|
||||
global_id = obj_map.get(obj.name)
|
||||
if global_id:
|
||||
try:
|
||||
|
||||
@@ -118,6 +118,9 @@ class Ifc(blenderbim.core.tool.Ifc):
|
||||
return
|
||||
|
||||
for obj in bpy.data.objects:
|
||||
if obj.library:
|
||||
continue
|
||||
|
||||
bpy.msgbus.clear_by_owner(obj)
|
||||
|
||||
element = cls.get_entity(obj)
|
||||
@@ -134,6 +137,9 @@ class Ifc(blenderbim.core.tool.Ifc):
|
||||
)
|
||||
|
||||
for obj in bpy.data.materials:
|
||||
if obj.library:
|
||||
continue
|
||||
|
||||
bpy.msgbus.clear_by_owner(obj)
|
||||
|
||||
material = cls.get_entity(obj)
|
||||
|
||||
Reference in New Issue
Block a user