Fixes long library names

This commit is contained in:
Simone Barbieri 2023-12-21 10:15:05 +00:00
parent 73614e08a8
commit a8b93ec8fe
3 changed files with 18 additions and 3 deletions

View file

@ -61,5 +61,10 @@ class BlendAnimationLoader(plugin.AssetLoader):
bpy.data.objects.remove(container)
library = bpy.data.libraries.get(bpy.path.basename(libpath))
filepath = bpy.path.basename(libpath)
# Blender has a limit of 63 characters for any data name.
# If the filepath is longer, it will be truncated.
if len(filepath) > 63:
filepath = filepath[:63]
library = bpy.data.libraries.get(filepath)
bpy.data.libraries.remove(library)

View file

@ -106,7 +106,12 @@ class BlendLoader(plugin.AssetLoader):
bpy.context.scene.collection.objects.link(obj)
# Remove the library from the blend file
library = bpy.data.libraries.get(bpy.path.basename(libpath))
filepath = bpy.path.basename(libpath)
# Blender has a limit of 63 characters for any data name.
# If the filepath is longer, it will be truncated.
if len(filepath) > 63:
filepath = filepath[:63]
library = bpy.data.libraries.get(filepath)
bpy.data.libraries.remove(library)
return container, members

View file

@ -60,7 +60,12 @@ class BlendSceneLoader(plugin.AssetLoader):
bpy.context.scene.collection.children.link(container)
# Remove the library from the blend file
library = bpy.data.libraries.get(bpy.path.basename(libpath))
filepath = bpy.path.basename(libpath)
# Blender has a limit of 63 characters for any data name.
# If the filepath is longer, it will be truncated.
if len(filepath) > 63:
filepath = filepath[:63]
library = bpy.data.libraries.get(filepath)
bpy.data.libraries.remove(library)
return container, members