From 57197cc37ab994ab814cbc1fc8b6368f64165ef7 Mon Sep 17 00:00:00 2001 From: Simone Barbieri Date: Mon, 18 Dec 2023 15:16:10 +0000 Subject: [PATCH 1/6] Use only the final part of folderPath in the instance name --- openpype/hosts/blender/api/plugin.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/openpype/hosts/blender/api/plugin.py b/openpype/hosts/blender/api/plugin.py index 568d8f6695..18d2aa5362 100644 --- a/openpype/hosts/blender/api/plugin.py +++ b/openpype/hosts/blender/api/plugin.py @@ -226,7 +226,7 @@ class BaseCreator(Creator): # Create asset group if AYON_SERVER_ENABLED: - asset_name = instance_data["folderPath"] + asset_name = instance_data["folderPath"].split("/")[-1] else: asset_name = instance_data["asset"] @@ -311,6 +311,8 @@ class BaseCreator(Creator): or asset_name_key in changes.changed_keys ): asset_name = data[asset_name_key] + if AYON_SERVER_ENABLED: + asset_name = asset_name.split("/")[-1] name = prepare_scene_name( asset=asset_name, subset=data["subset"] ) From 73614e08a8de37018b0143edafed558c0cf8e879 Mon Sep 17 00:00:00 2001 From: Simone Barbieri Date: Mon, 18 Dec 2023 16:14:10 +0000 Subject: [PATCH 2/6] Add warning if name is too long for Blender --- openpype/hosts/blender/api/plugin.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/openpype/hosts/blender/api/plugin.py b/openpype/hosts/blender/api/plugin.py index 18d2aa5362..d50bfad53d 100644 --- a/openpype/hosts/blender/api/plugin.py +++ b/openpype/hosts/blender/api/plugin.py @@ -36,6 +36,12 @@ def prepare_scene_name( if namespace: name = f"{name}_{namespace}" name = f"{name}_{subset}" + + # Blender name for a collection or object cannot be longer than 63 + # characters. If the name is longer, it will raise an error. + if len(name) > 63: + raise ValueError(f"Asset name '{name}' is too long.") + return name From a8b93ec8fe5f30f1f15444df90b9bcb7f0d496f0 Mon Sep 17 00:00:00 2001 From: Simone Barbieri Date: Thu, 21 Dec 2023 10:15:05 +0000 Subject: [PATCH 3/6] Fixes long library names --- openpype/hosts/blender/plugins/load/load_animation.py | 7 ++++++- openpype/hosts/blender/plugins/load/load_blend.py | 7 ++++++- openpype/hosts/blender/plugins/load/load_blendscene.py | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/openpype/hosts/blender/plugins/load/load_animation.py b/openpype/hosts/blender/plugins/load/load_animation.py index 3e7f808903..0f968c75e5 100644 --- a/openpype/hosts/blender/plugins/load/load_animation.py +++ b/openpype/hosts/blender/plugins/load/load_animation.py @@ -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) diff --git a/openpype/hosts/blender/plugins/load/load_blend.py b/openpype/hosts/blender/plugins/load/load_blend.py index f437e66795..2d5ac18149 100644 --- a/openpype/hosts/blender/plugins/load/load_blend.py +++ b/openpype/hosts/blender/plugins/load/load_blend.py @@ -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 diff --git a/openpype/hosts/blender/plugins/load/load_blendscene.py b/openpype/hosts/blender/plugins/load/load_blendscene.py index 6cc7f39d03..fba0245af1 100644 --- a/openpype/hosts/blender/plugins/load/load_blendscene.py +++ b/openpype/hosts/blender/plugins/load/load_blendscene.py @@ -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 From b012e169d413eb632fd347cdd8b52325034e7f50 Mon Sep 17 00:00:00 2001 From: Simone Barbieri Date: Thu, 21 Dec 2023 15:23:59 +0000 Subject: [PATCH 4/6] Changed error message Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- openpype/hosts/blender/api/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/hosts/blender/api/plugin.py b/openpype/hosts/blender/api/plugin.py index d50bfad53d..1037854a2d 100644 --- a/openpype/hosts/blender/api/plugin.py +++ b/openpype/hosts/blender/api/plugin.py @@ -40,7 +40,7 @@ def prepare_scene_name( # Blender name for a collection or object cannot be longer than 63 # characters. If the name is longer, it will raise an error. if len(name) > 63: - raise ValueError(f"Asset name '{name}' is too long.") + raise ValueError(f"Scene name '{name}' would be too long.") return name From 0a6edc648c0b5866b6025d82e091494840b17878 Mon Sep 17 00:00:00 2001 From: Simone Barbieri Date: Wed, 10 Jan 2024 12:03:08 +0000 Subject: [PATCH 5/6] Fix problem with AVALON_CONTAINER collection and workfile instance --- openpype/hosts/blender/api/plugin.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openpype/hosts/blender/api/plugin.py b/openpype/hosts/blender/api/plugin.py index 1037854a2d..b1ff3e4a09 100644 --- a/openpype/hosts/blender/api/plugin.py +++ b/openpype/hosts/blender/api/plugin.py @@ -311,11 +311,13 @@ class BaseCreator(Creator): ) return - # Rename the instance node in the scene if subset or asset changed + # Rename the instance node in the scene if subset or asset changed. + # Do not rename the instance if the family is workfile, as the + # workfile instance is included in the AVALON_CONTAINER collection. if ( "subset" in changes.changed_keys or asset_name_key in changes.changed_keys - ): + ) and created_instance.family != "workfile": asset_name = data[asset_name_key] if AYON_SERVER_ENABLED: asset_name = asset_name.split("/")[-1] From e9d38f24f49784021bccd19f18b189fc47e91276 Mon Sep 17 00:00:00 2001 From: Simone Barbieri Date: Fri, 12 Jan 2024 15:03:47 +0000 Subject: [PATCH 6/6] Renamed variable --- openpype/hosts/blender/plugins/load/load_animation.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/openpype/hosts/blender/plugins/load/load_animation.py b/openpype/hosts/blender/plugins/load/load_animation.py index 0f968c75e5..fd087553f0 100644 --- a/openpype/hosts/blender/plugins/load/load_animation.py +++ b/openpype/hosts/blender/plugins/load/load_animation.py @@ -61,10 +61,10 @@ class BlendAnimationLoader(plugin.AssetLoader): bpy.data.objects.remove(container) - filepath = bpy.path.basename(libpath) + filename = 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) + # If the filename is longer, it will be truncated. + if len(filename) > 63: + filename = filename[:63] + library = bpy.data.libraries.get(filename) bpy.data.libraries.remove(library)