Page MenuHome

Python error importing FBX file
Needs Information from User, NormalPublic

Description

System Information
Operating system: Windows 10
Graphics card: NVIDIA GeForce RTX 2070 SUPER

Blender Version
Broken: 2.91, downloaded from blender.org

Importing a FBX model downloaded from Unity asset store causes a Python traceback error and results in an incomplete import.

Exact steps for others to reproduce the error

  1. Purchase the InfinityPBR Dragons asset from the Unity Asset Store, at https://assetstore.unity.com/packages/3d/characters/creatures/dragons-45330 . (Wow, I swear it wasn't that expensive when I got it last year!)
  2. Import it in Unity to extract the files.
  3. Open Blender.
  4. Delete the default cube.
  5. Go to File -> Import -> FBX. Find the dragon model in "\Assets\InfinityPBR\_InfinityPBR - Dragons\Models\Dragon_Master05 DEMO.FBX" under your Unity project and import it.

Expected: This should import.
Observed: It imports about halfway, then throws a Python error. There are no textures and no animations.

Python: Traceback (most recent call last):

File "C:\Program Files\Blender Foundation\Blender 2.91\2.91\scripts\addons\io_scene_fbx\__init__.py", line 216, in execute
  if import_fbx.load(self, context, filepath=path, **keywords) == {'FINISHED'}:
File "C:\Program Files\Blender Foundation\Blender 2.91\2.91\scripts\addons\io_scene_fbx\import_fbx.py", line 2849, in load
  _(); del _
File "C:\Program Files\Blender Foundation\Blender 2.91\2.91\scripts\addons\io_scene_fbx\import_fbx.py", line 2846, in _
  root_helper.link_hierarchy(fbx_tmpl, settings, scene)
File "C:\Program Files\Blender Foundation\Blender 2.91\2.91\scripts\addons\io_scene_fbx\import_fbx.py", line 2341, in link_hierarchy
  child.link_hierarchy(fbx_tmpl, settings, scene)
File "C:\Program Files\Blender Foundation\Blender 2.91\2.91\scripts\addons\io_scene_fbx\import_fbx.py", line 2297, in link_hierarchy
  (mmat, amat) = mesh.armature_setup[self]

KeyError: DragonRoot
location: <unknown location>:-1

(Sorry about the somewhat involved process for obtaining the model. I don't know if there are any simpler models that reproduce the problem, and I can't exactly attach the model to a bug report because copyright.)

Event Timeline

Robert Guetzkow (rjg) changed the task status from Needs Triage to Needs Information from User.Dec 6 2020, 1:57 PM

I'm sorry, we won't be purchasing a model to reproduce the issue. Please try to create a minimal example file that you can share freely.

How exactly am I supposed to create an example, when the problem is in your FBX importer? Are you asking me to purchase Maya?

Robert Guetzkow (rjg) added a comment.EditedDec 6 2020, 9:00 PM

@Mason Wheeler (Stormhunter_Studios) For instance you could try to find another FBX that has the same problem but is freely accessible or inspect the structure of the FBX in another application that is able to open it. Apparently Blender expects a DragonRoot to be part of the armature but is unable to load it properly. This could be because Blender handles the file improperly or because the FBX is not following the specification. You could also try if previous versions of Blender can successfully import the file.

All bug reports need to provide the necessary information and files that allow us to reproduce the issue.

DragonRoot is the root bone of the armature for this model. It's present, and in fact it actually shows up in Blender after the failed import. The file is correctly structured as far as I can tell. It imports without any problems in both Unity and Unreal, at the very least.

I've contacted the author and asked him to weigh in on this. If available, he'd be far more helpful to you on this than I can be.

After speaking with the author, he encouraged me to submit the FBX file here. So here you go. With this you should be able to reproduce the problem. It's literally as simple as running the FBX importer on this file, under the default settings. (Preferably in your Python IDE of choice with the debugger attached.)

@Mason Wheeler (Stormhunter_Studios) Thank you for the file, we will look at this tomorrow.

Robert Guetzkow (rjg) changed the task status from Needs Information from User to Needs Developer to Reproduce.Dec 7 2020, 4:56 PM
Robert Guetzkow (rjg) edited projects, added Add-ons (BF-Blender); removed BF Blender.

I can reproduce the problem with the provided file, I'll investigate.

Robert Guetzkow (rjg) added a comment.EditedDec 7 2020, 7:40 PM

When trying to access mesh.armature_setup[self] in link_hierarchy() the entries for the some keys do not exist when trying to import the provided file. Therefore, accessing the dictionary like this results in the error described in the bug report. The meshes for which an entry is missing, are:

BridleHeadB
HeadA
BridleHeadA
HeadB
HeadC
BridleHeadC

The listed names are the content of their respective .fbx_name. The missing entry for all those meshes is the DragonRoot☺Model. I have yet to identify why these keys aren't set in the dictionary and whether this is an issue with the file or the importer.

There are multiple times where the helper_node.armature is None when entries are created with mesh_node.armature_setup[helper_node.armature] = (mesh_matrix, armature_matrix) in load(). The following helper_nodes have an helper_node.armature of NULL:

LLegToe3
LLegToe31
LLegToe2
LLegToe21
LLegToe1
LLegToe12
RLegToe1
RLegToe12
RLegToe2
RLegToe21
RLegToe3
RLegToe31
English DragonLArmCollarbone
English DragonLArmCollarbone
English DragonLArmCollarbone
English DragonLArmCollarbone
English DragonLArmCollarbone
English DragonLArmCollarbone
English DragonLArmCollarbone
English DragonLArmCollarbone
English DragonLArm1
English DragonLArm1
English DragonLArm1
English DragonLArm1
English DragonLArm1
English DragonLArm1
English DragonLArm2
English DragonLArm2
English DragonLArm2
English DragonLArm3
English DragonLArmPalm
LHandToe3
LHandToe31
LHandToe2
LHandToe21
LHandToe1
LHandToe12
English DragonRArmCollarbone
English DragonRArmCollarbone
English DragonRArmCollarbone
English DragonRArmCollarbone
English DragonRArmCollarbone
English DragonRArmCollarbone
English DragonRArmCollarbone
English DragonRArm1
English DragonRArm1
English DragonRArm1
English DragonRArm1
English DragonRArm1
English DragonRArm2
English DragonRArm2
English DragonRArm2
English DragonRArm3
English DragonRArmPalm
RHandToe1
RHandToe12
RHandToe2
RHandToe21
RHandToe3
RHandToe31
English DragonLWingCollarbone
English DragonLWingCollarbone
English DragonLWingCollarbone
English DragonLWingCollarbone
English DragonLWingCollarbone
English DragonLWingCollarbone
English DragonLWingCollarbone
English DragonLWingCollarbone
English DragonLWing1
English DragonLWing1
English DragonLWing1
English DragonLWing2
English DragonLW11
English DragonLW12
English DragonLW13
English DragonWthumbL
English DragonLW21
English DragonLW22
English DragonLW23
English DragonLW31
English DragonLW32
English DragonLW33
English DragonLW41
English DragonLW42
English DragonLW43
English DragonRWingCollarbone
English DragonRWingCollarbone
English DragonRWingCollarbone
English DragonRWingCollarbone
English DragonRWingCollarbone
English DragonRWingCollarbone
English DragonRWingCollarbone
English DragonRWingCollarbone
English DragonRWingCollarbone
English DragonRWing1
English DragonRWing1
English DragonRWing1
English DragonRWing1
English DragonRWing1
English DragonRWing2
English DragonRW11
English DragonRW12
English DragonRW13
English DragonWthumbR
English DragonRW21
English DragonRW22
English DragonRW23
English DragonRW31
English DragonRW32
English DragonRW33
English DragonRW41
English DragonRW42
English DragonRW43
English DragonNeck1
English DragonNeck1
English DragonNeck1
English DragonNeck1
English DragonNeck1
English DragonNeck1
English DragonNeck1
English DragonNeck1
English DragonNeck1
English DragonNeck2
English DragonNeck2
English DragonNeck2
English DragonNeck2
English DragonNeck2
English DragonNeck2
English DragonNeck2
English DragonNeck3
English DragonNeck3
English DragonNeck3
English DragonNeck3
English DragonNeck3
English DragonNeck3
English DragonNeck3
English DragonNeck4
English DragonNeck4
English DragonNeck4
English DragonNeck4
English DragonNeck4
English DragonNeck4
English DragonNeck4
English DragonNeck5
English DragonNeck5
English DragonNeck5
English DragonNeck5
English DragonNeck5
English DragonNeck5
English DragonNeck5
English DragonNeck5
English DragonNeck5
English DragonNeck5
English DragonNeck5
English DragonNeck5
English DragonNeck5
English DragonHead
English DragonHead
English DragonHead
English DragonHead
English DragonHead
English DragonHead
English DragonHead
English DragonHead
English DragonHead
English DragonHead
English DragonHead
English DragonHead
English DragonHead
English DragonJaw
English DragonJaw
English DragonJaw
English DragonJaw
English DragonJaw
English DragonJaw
Base HumanLCollarbone
Base HumanLCollarbone
Base HumanLUpperarm1
Base HumanLUpperarm1
Base HumanLUpperarm2
Base HumanLUpperarm2
Base HumanLForearm1
Base HumanLForearm1
Base HumanLForearm2
Base HumanLForearm2
Base HumanLForearm3
Base HumanLForearm3
Base HumanLPalm
Base HumanLPalm
Base HumanLThumbL1
Base HumanLThumbL1
Base HumanLThumbL2
Base HumanLThumbL2
Base HumanLThumbL3
Base HumanLThumbL3
Base HumanLFingerL1
Base HumanLFingerL1
Base HumanLFingerL2
Base HumanLFingerL2
Base HumanLFingerL3
Base HumanLFingerL3
Base HumanLFingerIndexL1
Base HumanLFingerIndexL1
Base HumanLFingerIndexL2
Base HumanLFingerIndexL2
Base HumanLFingerIndexL3
Base HumanLFingerIndexL3
Base HumanLFingerRingL1
Base HumanLFingerRingL1
Base HumanLFingerRingL2
Base HumanLFingerRingL2
Base HumanLFingerRingL3
Base HumanLFingerRingL3
Base HumanLFingerPinkieL1
Base HumanLFingerPinkieL1
Base HumanLFingerPinkieL2
Base HumanLFingerPinkieL2
Base HumanLFingerPinkieL3
Base HumanLFingerPinkieL3
Base HumanRCollarbone
Base HumanRCollarbone
Base HumanRUpperarm1
Base HumanRUpperarm1
Base HumanRUpperarm2
Base HumanRUpperarm2
Base HumanRForearm1
Base HumanRForearm1
Base HumanRForearm2
Base HumanRForearm2
Base HumanRForearm3
Base HumanRForearm3
Base HumanRPalm
Base HumanRPalm
Base HumanRThumbR1
Base HumanRThumbR1
Base HumanRThumbR2
Base HumanRThumbR2
Base HumanRThumbR3
Base HumanRThumbR3
Base HumanRFingerR1
Base HumanRFingerR1
Base HumanRFingerR2
Base HumanRFingerR2
Base HumanRFingerR3
Base HumanRFingerR3
Base HumanRFingerIndexR1
Base HumanRFingerIndexR1
Base HumanRFingerIndexR2
Base HumanRFingerIndexR2
Base HumanRFingerIndexR3
Base HumanRFingerIndexR3
Base HumanRFingerRingR1
Base HumanRFingerRingR1
Base HumanRFingerRingR2
Base HumanRFingerRingR2
Base HumanRFingerRingR3
Base HumanRFingerRingR3
Base HumanRFingerPinkieR1
Base HumanRFingerPinkieR1
Base HumanRFingerPinkieR2
Base HumanRFingerPinkieR2
Base HumanRFingerPinkieR3
Base HumanRFingerPinkieR3
Base HumanNeck
Base HumanNeck
Base HumanHead
Base HumanHead
Base HumanJaw
Base HumanJaw
Base HumanMouth_L
Base HumanMouth_L
Base HumanMouth_R
Base HumanMouth_R
Base HumanHair25
Base HumanHair25
Base HumanHair26
Base HumanHair26
Base HumanHair27
Base HumanHair27
Base HumanHair28
Base HumanHair28
Base HumanHair29
Base HumanHair29
Base HumanHair20
Base HumanHair20
Base HumanHair21
Base HumanHair21
Base HumanHair22
Base HumanHair22
Base HumanHair23
Base HumanHair23
Base HumanHair24
Base HumanHair24
Base HumanHair30
Base HumanHair30
Base HumanHair31
Base HumanHair31
Base HumanHair32
Base HumanHair32
Base HumanHair33
Base HumanHair33
Base HumanHair34
Base HumanHair34
Base HumanHair15
Base HumanHair15
Base HumanHair16
Base HumanHair16
Base HumanHair17
Base HumanHair17
Base HumanHair18
Base HumanHair18
Base HumanHair19
Base HumanHair19
Base HumanHair10
Base HumanHair10
Base HumanHair11
Base HumanHair11
Base HumanHair12
Base HumanHair12
Base HumanHair13
Base HumanHair13
Base HumanHair14
Base HumanHair14
Base HumanHair35
Base HumanHair35
Base HumanHair36
Base HumanHair36
Base HumanHair37
Base HumanHair37
Base HumanHair38
Base HumanHair38
Base HumanHair39
Base HumanHair39
Base HumanHair40
Base HumanHair40
Base HumanHair41
Base HumanHair41
Base HumanHair42
Base HumanHair42
Base HumanHair43
Base HumanHair43
Base HumanHair44
Base HumanHair44
Base HumanHair45
Base HumanHair45
Base HumanHair46
Base HumanHair46
Base HumanHair47
Base HumanHair47
Base HumanHair48
Base HumanHair48
Base HumanHair49
Base HumanHair49
Base HumanHair05
Base HumanHair05
Base HumanHair06
Base HumanHair06
Base HumanHair07
Base HumanHair07
Base HumanHair08
Base HumanHair08
Base HumanHair09
Base HumanHair09
Base HumanHair50
Base HumanHair50
Base HumanHair51
Base HumanHair51
Base HumanHair52
Base HumanHair52
Base HumanHair53
Base HumanHair53
Base HumanHair01
Base HumanHair01
Base HumanHair02
Base HumanHair02
Base HumanHair03
Base HumanHair03
Base HumanHair04
Base HumanHair04
Base HumanHair55
Base HumanHair55
Base HumanHair54
Base HumanHair54
Base HumanBrow_L1
Base HumanBrow_L1
Base HumanBrow_L2
Base HumanBrow_L2
Base HumanBrow_L3
Base HumanBrow_L3
Base HumanNose_L
Base HumanNose_L
Base HumanCheek_L
Base HumanCheek_L
Base HumanBrow_R1
Base HumanBrow_R1
Base HumanBrow_R2
Base HumanBrow_R2
Base HumanBrow_R3
Base HumanBrow_R3
Base HumanCheek_R
Base HumanCheek_R
Base HumanNose_R
Base HumanNose_R
Base HumanPonytail1
Base HumanPonytail1
Base HumanPonytail2
Base HumanPonytail2
Base HumanPonytail3
Base HumanPonytail3
Base HumanPonytail4
Base HumanPonytail4
Base HumanPonytail5
Base HumanPonytail5
Base HumanPonytail6
Base HumanPonytail6
Base HumanPonytail7
Base HumanPonytail7
Base HumanPonytail8
Base HumanPonytail8
Base HumanPonytail9
Base HumanPonytail9
Base HumanPonytail10
Base HumanPonytail10
EyeR
EyeR
EyelidBottomR
EyelidBottomR
EyelidTopR
EyelidTopR
EyelidBottomL
EyelidBottomL
EyelidTopL
EyelidTopL
EyeL
EyeL

Edit: This is related to the problem at hand, as for instance when the entries for BridleHeadB should be created with mesh_node.armature_setup[helper_node.armature] = (mesh_matrix, armature_matrix) in load() the English DragonNeck5, English DragonHead and English DragonJaw are used as helper_node, but their .armature returns None.

Maybe this is just a case of differing philosophies, but as a coder myself, it seems to me that if the end-user sees a stack trace from Blender's code for any reason, it's a flaw in Blender's code. If the input file is malformed, it should report that fact to the user with some human-readable explanation as to what's wrong with the file, rather than throw an uncaught exception.

(Yes, I know end users can write their own code for plugins, etc. I'm referring specifically to code that comes from Blender and is fully under your control.)

Robert Guetzkow (rjg) added a comment.EditedDec 7 2020, 8:47 PM

There are even more objects that should get an armature modifier assigned with Object set to DragonRoot, e.g. the Male_Body object, but currently don't.

Robert Guetzkow (rjg) added a comment.EditedDec 7 2020, 8:47 PM

@Mason Wheeler (Stormhunter_Studios) I'm in the process of analyzing this and just shared my notes so other developers don't do the redundant work.

Seems like the support of more complex rigs is limited in Blender's FBX importer. I will give it another look tomorrow and see if I can find the core problem, but based on comments by @Bastien Montagne (mont29) in past reports T70244 and T61011 this is a known limitation.

Bastien Montagne (mont29) changed the task status from Needs Developer to Reproduce to Needs Information from User.Dec 8 2020, 11:01 AM

Such giant FBX file is totally unusable to investigate an issue, we'd need a minimal basic demo file exhibiting it to seriously check on it... But even then, as already said, recursive layers of rigs are not exactly well supported currently, FBX uses Maya/3DSMax kinds of rigs, which are fairly different from Blender ones, and since there is no clear specs for FBX, doing a fully proper conversion is fairly difficult.