Python error loading fbx file in new project #105045

Closed
opened 2023-12-07 02:39:31 +01:00 by Alfafar · 2 comments

System Information
Operating system: Windows-10-10.0.22621-SP0 64 Bits
Graphics card: NVIDIA GeForce RTX 3060 Laptop GPU/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 531.29

Blender Version
Broken: version: 4.0.2, branch: blender-v4.0-release, commit date: 2023-12-05 07:41, hash: 9be62e85b727
Worked: (newest version of Blender that worked as expected)

Addon Information
Name: FBX format (5, 8, 13)
Author: Campbell Barton, Bastien Montagne, Jens Restemeier, @Mysteryem

Short description of error

A certain FBX file that could be imported in Blender a while ago will generate a Python error after import.
I did not change the content of any FBX file, so the sudden inability to import the file left me very confused.
I tried versions 3.6 and alpha but still couldn't import the fbx file correctly.

Exact steps for others to reproduce the error
Create a new project and import the fbx file from the attachment.

Error feedback in the console:

Python: Traceback (most recent call last):
File "F:\SteamLibrary\steamapps\common\Blender\4.0\scripts\addons\io_scene_fbx_init_.py", line 209, in execute
if import_fbx.load(self, context, filepath=path, **keywords) == {'FINISHED'}:
File "F:\SteamLibrary\steamapps\common\Blender\4.0\scripts\addons\io_scene_fbx\import_fbx.py", line 3464, in load
_(); del _
File "F:\SteamLibrary\steamapps\common\Blender\4.0\scripts\addons\io_scene_fbx\import_fbx.py", line 3458, in _
root_helper.build_hierarchy(fbx_tmpl, settings, scene, view_layer)
File "F:\SteamLibrary\steamapps\common\Blender\4.0\scripts\addons\io_scene_fbx\import_fbx.py", line 2889, in build_hierarchy
child.build_hierarchy(fbx_tmpl, settings, scene, view_layer)
File "F:\SteamLibrary\steamapps\common\Blender\4.0\scripts\addons\io_scene_fbx\import_fbx.py", line 2880, in build_hierarchy
child.build_hierarchy(fbx_tmpl, settings, scene, view_layer)
File "F:\SteamLibrary\steamapps\common\Blender\4.0\scripts\addons\io_scene_fbx\import_fbx.py", line 2880, in build_hierarchy
child.build_hierarchy(fbx_tmpl, settings, scene, view_layer)
File "F:\SteamLibrary\steamapps\common\Blender\4.0\scripts\addons\io_scene_fbx\import_fbx.py", line 2880, in build_hierarchy
child.build_hierarchy(fbx_tmpl, settings, scene, view_layer)
[Previous line repeated 5 more times]
File "F:\SteamLibrary\steamapps\common\Blender\4.0\scripts\addons\io_scene_fbx\import_fbx.py", line 2866, in build_hierarchy
child.set_pose_matrix_and_custom_props(self, settings)
File "F:\SteamLibrary\steamapps\common\Blender\4.0\scripts\addons\io_scene_fbx\import_fbx.py", line 2752, in set_pose_matrix_and_custom_props
child.set_pose_matrix_and_custom_props(arm, settings)
File "F:\SteamLibrary\steamapps\common\Blender\4.0\scripts\addons\io_scene_fbx\import_fbx.py", line 2752, in set_pose_matrix_and_custom_props
child.set_pose_matrix_and_custom_props(arm, settings)
File "F:\SteamLibrary\steamapps\common\Blender\4.0\scripts\addons\io_scene_fbx\import_fbx.py", line 2752, in set_pose_matrix_and_custom_props
child.set_pose_matrix_and_custom_props(arm, settings)
File "F:\SteamLibrary\steamapps\common\Blender\4.0\scripts\addons\io_scene_fbx\import_fbx.py", line 2746, in set_pose_matrix_and_custom_props
blen_read_custom_properties(self.fbx_elem, pose_bone, settings)
File "F:\SteamLibrary\steamapps\common\Blender\4.0\scripts\addons\io_scene_fbx\import_fbx.py", line 319, in blen_read_custom_properties
fbx_obj_props = elem_find_first(fbx_obj, b'Properties70')
File "F:\SteamLibrary\steamapps\common\Blender\4.0\scripts\addons\io_scene_fbx\import_fbx.py", line 84, in elem_find_first
for fbx_item in elem.elems:
AttributeError: 'NoneType' object has no attribute 'elems'

**System Information** Operating system: Windows-10-10.0.22621-SP0 64 Bits Graphics card: NVIDIA GeForce RTX 3060 Laptop GPU/PCIe/SSE2 NVIDIA Corporation 4.6.0 NVIDIA 531.29 **Blender Version** Broken: version: 4.0.2, branch: blender-v4.0-release, commit date: 2023-12-05 07:41, hash: `9be62e85b727` Worked: (newest version of Blender that worked as expected) **Addon Information** Name: FBX format (5, 8, 13) Author: Campbell Barton, Bastien Montagne, Jens Restemeier, @Mysteryem **Short description of error** A certain FBX file that could be imported in Blender a while ago will generate a Python error after import. I did not change the content of any FBX file, so the sudden inability to import the file left me very confused. I tried versions 3.6 and alpha but still couldn't import the fbx file correctly. **Exact steps for others to reproduce the error** Create a new project and import the fbx file from the attachment. Error feedback in the console: Python: Traceback (most recent call last): File "F:\SteamLibrary\steamapps\common\Blender\4.0\scripts\addons\io_scene_fbx\__init__.py", line 209, in execute if import_fbx.load(self, context, filepath=path, **keywords) == {'FINISHED'}: File "F:\SteamLibrary\steamapps\common\Blender\4.0\scripts\addons\io_scene_fbx\import_fbx.py", line 3464, in load _(); del _ File "F:\SteamLibrary\steamapps\common\Blender\4.0\scripts\addons\io_scene_fbx\import_fbx.py", line 3458, in _ root_helper.build_hierarchy(fbx_tmpl, settings, scene, view_layer) File "F:\SteamLibrary\steamapps\common\Blender\4.0\scripts\addons\io_scene_fbx\import_fbx.py", line 2889, in build_hierarchy child.build_hierarchy(fbx_tmpl, settings, scene, view_layer) File "F:\SteamLibrary\steamapps\common\Blender\4.0\scripts\addons\io_scene_fbx\import_fbx.py", line 2880, in build_hierarchy child.build_hierarchy(fbx_tmpl, settings, scene, view_layer) File "F:\SteamLibrary\steamapps\common\Blender\4.0\scripts\addons\io_scene_fbx\import_fbx.py", line 2880, in build_hierarchy child.build_hierarchy(fbx_tmpl, settings, scene, view_layer) File "F:\SteamLibrary\steamapps\common\Blender\4.0\scripts\addons\io_scene_fbx\import_fbx.py", line 2880, in build_hierarchy child.build_hierarchy(fbx_tmpl, settings, scene, view_layer) [Previous line repeated 5 more times] File "F:\SteamLibrary\steamapps\common\Blender\4.0\scripts\addons\io_scene_fbx\import_fbx.py", line 2866, in build_hierarchy child.set_pose_matrix_and_custom_props(self, settings) File "F:\SteamLibrary\steamapps\common\Blender\4.0\scripts\addons\io_scene_fbx\import_fbx.py", line 2752, in set_pose_matrix_and_custom_props child.set_pose_matrix_and_custom_props(arm, settings) File "F:\SteamLibrary\steamapps\common\Blender\4.0\scripts\addons\io_scene_fbx\import_fbx.py", line 2752, in set_pose_matrix_and_custom_props child.set_pose_matrix_and_custom_props(arm, settings) File "F:\SteamLibrary\steamapps\common\Blender\4.0\scripts\addons\io_scene_fbx\import_fbx.py", line 2752, in set_pose_matrix_and_custom_props child.set_pose_matrix_and_custom_props(arm, settings) File "F:\SteamLibrary\steamapps\common\Blender\4.0\scripts\addons\io_scene_fbx\import_fbx.py", line 2746, in set_pose_matrix_and_custom_props blen_read_custom_properties(self.fbx_elem, pose_bone, settings) File "F:\SteamLibrary\steamapps\common\Blender\4.0\scripts\addons\io_scene_fbx\import_fbx.py", line 319, in blen_read_custom_properties fbx_obj_props = elem_find_first(fbx_obj, b'Properties70') File "F:\SteamLibrary\steamapps\common\Blender\4.0\scripts\addons\io_scene_fbx\import_fbx.py", line 84, in elem_find_first for fbx_item in elem.elems: AttributeError: 'NoneType' object has no attribute 'elems'
Alfafar added the
Status
Needs Triage
Priority
Normal
Type
Report
labels 2023-12-07 02:39:32 +01:00
Member

I can confirm. It's caused by 716702b97e, but that change might have identified an issue elsewhere with the attached file because the importer appears to have created bones for NurbsCurve models (a geometry type not supported by FBX IO). If that is correct behaviour in this case, the fbx_elem of the bones has not been set to the NurbsCurve model, so it tries to read the PoseBone custom properties from None.

A simple fix would be to check that fbx_elem is not None before trying to read custom properties from it, but I'm not currently sure if it should be None in the first place.

A workaround for now to import this .fbx is to disable the import of Custom Properties when importing:
image

I can confirm. It's caused by 716702b97e, but that change might have identified an issue elsewhere with the attached file because the importer appears to have created bones for `NurbsCurve` models (a geometry type not supported by FBX IO). If that is correct behaviour in this case, the `fbx_elem` of the bones has not been set to the `NurbsCurve` model, so it tries to read the PoseBone custom properties from `None`. A simple fix would be to check that `fbx_elem` is not `None` before trying to read custom properties from it, but I'm not currently sure if it should be `None` in the first place. A workaround for now to import this .fbx is to disable the import of Custom Properties when importing: ![image](/attachments/a51987ad-f4c6-44e4-b871-371f4974ab9b)
Author

Thank you very much. This has solved all my problems

Thank you very much. This has solved all my problems
Blender Bot added
Status
Archived
and removed
Status
Needs Triage
labels 2023-12-07 04:52:57 +01:00
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#105045
No description provided.