From 0db38ad102bbdbb1a72ff25b434287686af9526d Mon Sep 17 00:00:00 2001 From: Thomas Barlow Date: Thu, 7 Dec 2023 15:30:10 +0000 Subject: [PATCH] Fix #105045: Error importing FBX custom properties on placeholder PoseBones Caused by not understanding an uncommon import case in 716702b97e where a bone can be created without an FBX Node to import custom properties from. A bone in Blender is always created from an FBX Node, so it seemed like all bones should have an FBX Node that custom properties can be imported from. However, FBX allows bone and non-bone Nodes to be parented to one another, which Blender cannot represent exactly due to Armatures only containing bones. In such cases, the non-bone Node is imported as an Object, but a bone with the same name is also created (which the Object is parented to). The newly created bone doesn't have a Node to import custom properties from because the Node belongs to the imported Object instead. --- io_scene_fbx/__init__.py | 2 +- io_scene_fbx/import_fbx.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/io_scene_fbx/__init__.py b/io_scene_fbx/__init__.py index aab0647cb..8996771ca 100644 --- a/io_scene_fbx/__init__.py +++ b/io_scene_fbx/__init__.py @@ -3,7 +3,7 @@ bl_info = { "name": "FBX format", "author": "Campbell Barton, Bastien Montagne, Jens Restemeier, @Mysteryem", - "version": (5, 4, 0), + "version": (5, 4, 1), "blender": (3, 6, 0), "location": "File > Import-Export", "description": "FBX IO meshes, UVs, vertex colors, materials, textures, cameras, lamps and actions", diff --git a/io_scene_fbx/import_fbx.py b/io_scene_fbx/import_fbx.py index 961594417..20acf0c33 100644 --- a/io_scene_fbx/import_fbx.py +++ b/io_scene_fbx/import_fbx.py @@ -2394,7 +2394,13 @@ class FbxImportHelperNode: pose_bone = arm.bl_obj.pose.bones[self.bl_bone] pose_bone.matrix_basis = self.get_bind_matrix().inverted_safe() @ self.get_matrix() - if settings.use_custom_props: + # `self.fbx_elem` can be `None` in cases where the imported hierarchy contains a mix of bone and non-bone FBX + # Nodes parented to one another, e.g. "bone1"->"mesh1"->"bone2". In Blender, an Armature can only consist of + # bones, so to maintain the imported hierarchy, a placeholder bone with the same name as "mesh1" is inserted + # into the Armature and then the imported "mesh1" Object is parented to the placeholder bone. The placeholder + # bone won't have a `self.fbx_elem` because it belongs to the "mesh1" Object instead. + # See FbxImportHelperNode.find_fake_bones(). + if settings.use_custom_props and self.fbx_elem: blen_read_custom_properties(self.fbx_elem, pose_bone, settings) for child in self.children: -- 2.30.2