fix loading and unloading linked IFCs with a relative path

This commit is contained in:
Sigma Dimensions (Yass)
2023-08-29 16:30:29 +01:00
parent 68dcbd8e5c
commit e2ab4f1ed8
@@ -850,7 +850,7 @@ class UnloadLink(bpy.types.Operator):
for scene in bpy.data.scenes:
if scene.library and scene.library.filepath == filepath:
bpy.data.scenes.remove(scene)
link = context.scene.BIMProjectProperties.links.get(filepath)
link = context.scene.BIMProjectProperties.links.get(self.filepath)
link.is_loaded = False
return {"FINISHED"}
@@ -866,7 +866,7 @@ class LoadLink(bpy.types.Operator):
filepath = self.filepath
if not os.path.isabs(filepath):
filepath = os.path.abspath(os.path.join(bpy.path.abspath("//"), filepath))
with bpy.data.libraries.load(self.filepath, link=True) as (data_from, data_to):
with bpy.data.libraries.load(filepath, link=True) as (data_from, data_to):
data_to.scenes = data_from.scenes
for scene in bpy.data.scenes:
if not scene.library or scene.library.filepath != filepath:
@@ -875,7 +875,7 @@ class LoadLink(bpy.types.Operator):
if "IfcProject" not in child.name:
continue
bpy.data.scenes[0].collection.children.link(child)
link = context.scene.BIMProjectProperties.links.get(filepath)
link = context.scene.BIMProjectProperties.links.get(self.filepath)
link.is_loaded = True
return {"FINISHED"}