Fix #4411. Fallback to absolute paths if relative paths fail.

This commit is contained in:
Dion Moult
2024-03-29 15:29:19 +11:00
parent 4abb4d7f63
commit 4f66fdd339
@@ -860,7 +860,10 @@ class LinkIfc(bpy.types.Operator):
continue
new = context.scene.BIMProjectProperties.links.add()
if self.use_relative_path:
filepath = os.path.relpath(filepath, bpy.path.abspath("//")).replace("\\", "/")
try:
filepath = os.path.relpath(filepath, bpy.path.abspath("//")).replace("\\", "/")
except:
pass # Perhaps on another drive or something
new.name = filepath
bpy.ops.bim.load_link(filepath=filepath, false_origin=self.false_origin)
print(f"Finished linking {len(files)} IFCs", time.time() - start)