Page MenuHome

Error when exporting FBX (presumably caused by conflicting cached uv customdatalayer)
Confirmed, HighPublic

Description

System Information
Operating system: Windows 10
Graphics card: 1080 Ti

Blender Version
Broken: 2.83.4, 2.82a, rBe4932d1167f4: Fix T80034 Crash using material panel on 2.91.0 alpha
Worked: No Idea

Short description of error

Exact steps for others to reproduce the error
Export the fbx. (Only default settings were tested.)

here is log

FBX export starting... '/Users/me/Downloads/Voiture.fbx'
FBX export prepare: Wrapping Objects...
	Done (0.000301 sec)

FBX export prepare: Wrapping Data (lamps, cameras, empties)...
	Done (0.000074 sec)

FBX export prepare: Wrapping Meshes...
	Done (0.000263 sec)

FBX export prepare: Wrapping ShapeKeys...
	Done (0.000039 sec)

FBX export prepare: Wrapping Armatures...
	Done (0.000043 sec)

FBX export prepare: Wrapping World...
	Done (0.000102 sec)

FBX export prepare: Wrapping Materials...
	Done (0.000359 sec)

FBX export prepare: Wrapping Textures...
	Done (0.001477 sec)

FBX export prepare: Wrapping Animations...
	Done (0.000160 sec)

FBX export prepare: Generating templates...
	Done (0.000093 sec)

FBX export prepare: Generating Connections...
	Done (0.000639 sec)

FBX export fetch empties (0)...
	Done (0.000038 sec)

FBX export fetch lamps (0)...
	Done (0.000030 sec)

FBX export fetch cameras (0)...
	Done (0.000034 sec)

FBX export fetch meshes (5)...
Python: Traceback (most recent call last):
  File "Blender.app/Contents/Resources/2.91/scripts/addons/io_scene_fbx/__init__.py", line 636, in execute
    return export_fbx_bin.save(self, context, **keywords)
  File "Blender.app/Contents/Resources/2.91/scripts/addons/io_scene_fbx/export_fbx_bin.py", line 3198, in save
    ret = save_single(operator, context.scene, depsgraph, filepath, **kwargs_mod)
  File "Blender.app/Contents/Resources/2.91/scripts/addons/io_scene_fbx/export_fbx_bin.py", line 3094, in save_single
    fbx_objects_elements(root, scene_data)
  File "Blender.app/Contents/Resources/2.91/scripts/addons/io_scene_fbx/export_fbx_bin.py", line 2894, in fbx_objects_elements
    fbx_data_mesh_elements(objects, me_obj, scene_data, done_meshes)
  File "Blender.app/Contents/Resources/2.91/scripts/addons/io_scene_fbx/export_fbx_bin.py", line 1174, in fbx_data_mesh_elements
    elem_data_single_int32_array(lay_uv, b"UVIndex", (uv2idx[uv_id] for uv_id in _uvtuples_gen(t_luv, t_lvidx)))
  File "Blender.app/Contents/Resources/2.91/scripts/addons/io_scene_fbx/fbx_utils.py", line 504, in elem_data_single_int32_array
    return _elem_data_single(elem, name, value, "add_int32_array")
  File "Blender.app/Contents/Resources/2.91/scripts/addons/io_scene_fbx/fbx_utils.py", line 451, in _elem_data_single
    getattr(sub_elem, func_name)(value)
  File "Blender.app/Contents/Resources/2.91/scripts/addons/io_scene_fbx/encode_bin.py", line 161, in add_int32_array
    data = array.array(data_types.ARRAY_INT32, data)
  File "Blender.app/Contents/Resources/2.91/scripts/addons/io_scene_fbx/export_fbx_bin.py", line 1174, in <genexpr>
    elem_data_single_int32_array(lay_uv, b"UVIndex", (uv2idx[uv_id] for uv_id in _uvtuples_gen(t_luv, t_lvidx)))
KeyError: ((nan, nan), 819)

location: <unknown location>:-1

Event Timeline

Just Rebuild everything and The exact same problem when exporting, what is going on???

Created a New file, No textures, just the shapes

Traceback (most recent call last):

File "C:\Program Files (x86)\Steam\steamapps\common\Blender\2.83\scripts\addons\io_scene_fbx\__init__.py", line 634, in execute
  return export_fbx_bin.save(self, context, **keywords)
File "C:\Program Files (x86)\Steam\steamapps\common\Blender\2.83\scripts\addons\io_scene_fbx\export_fbx_bin.py", line 3198, in save
  ret = save_single(operator, context.scene, depsgraph, filepath, **kwargs_mod)
File "C:\Program Files (x86)\Steam\steamapps\common\Blender\2.83\scripts\addons\io_scene_fbx\export_fbx_bin.py", line 3094, in save_single
  fbx_objects_elements(root, scene_data)
File "C:\Program Files (x86)\Steam\steamapps\common\Blender\2.83\scripts\addons\io_scene_fbx\export_fbx_bin.py", line 2894, in fbx_objects_elements
  fbx_data_mesh_elements(objects, me_obj, scene_data, done_meshes)
File "C:\Program Files (x86)\Steam\steamapps\common\Blender\2.83\scripts\addons\io_scene_fbx\export_fbx_bin.py", line 1174, in fbx_data_mesh_elements
  elem_data_single_int32_array(lay_uv, b"UVIndex", (uv2idx[uv_id] for uv_id in _uvtuples_gen(t_luv, t_lvidx)))
File "C:\Program Files (x86)\Steam\steamapps\common\Blender\2.83\scripts\addons\io_scene_fbx\fbx_utils.py", line 504, in elem_data_single_int32_array
  return _elem_data_single(elem, name, value, "add_int32_array")
File "C:\Program Files (x86)\Steam\steamapps\common\Blender\2.83\scripts\addons\io_scene_fbx\fbx_utils.py", line 451, in _elem_data_single
  getattr(sub_elem, func_name)(value)
File "C:\Program Files (x86)\Steam\steamapps\common\Blender\2.83\scripts\addons\io_scene_fbx\encode_bin.py", line 161, in add_int32_array
  data = array.array(data_types.ARRAY_INT32, data)
File "C:\Program Files (x86)\Steam\steamapps\common\Blender\2.83\scripts\addons\io_scene_fbx\export_fbx_bin.py", line 1174, in <genexpr>
  elem_data_single_int32_array(lay_uv, b"UVIndex", (uv2idx[uv_id] for uv_id in _uvtuples_gen(t_luv, t_lvidx)))

KeyError: ((nan, nan), 11)

location: <unknown location>:-1

Robert Guetzkow (rjg) changed the task status from Needs Triage to Needs Information from User.Aug 14 2020, 3:28 PM
This comment was removed by Robert Guetzkow (rjg).

(x86)\Steam\steamapps\common\Blender\2.83\

Along with providing a .blend, you might want to test this with the current 2.84 release, preferably from blender.org.

Blender does not need to be installed. You can simply download it, unpack the archive and run it directly.

I can't be spending my time fixing bugs on something as simple as exporting a FBX

It may seem simple when you are clicking Export, but FBX is a *very* complicated format. Worse, it is proprietary which means you need a license from Autodesk to read the specification or use their libraries to read and write the format. Worse still, Autodesk is rumored to change the format regularly to prevent reverse-engineering.

Ankit Meel (ankitm) changed the task status from Needs Information from User to Confirmed.Mon, Aug 24, 2:12 PM
Ankit Meel (ankitm) updated the task description. (Show Details)

Since this is reported often and we keep this report open for it [not sure if we should, usually the "corrupted" meshes are not tracked in the bugtracker, we only do if we can find the source for the corruption within blender tools], I'll drop the following comment here. I guess this is relevant for all of the reported files:

Hi @Germano Cavalcante (mano-wii) , I was able to fix the problem using python. It appears the bug is caused by temp/cached custom data layers. This resolves it:

import bpy

m = bpy.context.object.data
m.validate() #this function has a parameter called clean_customdata which defaults to true and removes any temp/cached custom-data layers like normals and presumably the conflicting cached uv's

Maybe the exporter could loop through the objects being exported and clear their cached data before attempting to export?

import bpy

for ob in bpy.data.objects:
    
    m = ob.data
    if m.validate(verbose=True):
        print("something was fixed with the mesh")
    else:
        print("mesh was fine")
        
    print(" and the cached custom data has been cleared to avoid export issues")

Maybe the fact that this is specifically about the custom-data layers will help us track the issue down further.

Dropping this comment here [might help track down the issue as well]:

So by hiding halfs of the model I narrowed it down to this object after a while:

Tried deleting UVs, clearing custom split data and still not sure what could it be.
Edit1: Found out that if I delete both UV maps it works. But the question is - what is wrong with the UV maps? They look fine.
Edit2: OK so I redid both UV maps again and now it can be exported. The original object had a bevel modifier on it. Wondering if that could cause this.

Here is blend with bevel:

More information:

@Robert Guetzkow (rjg) This issue happened to a coworker of mine, but I'll try to rephrase what they said.
The only noteworthy thing about the creation of this mesh is that they copy-pasted (Ctrl-C, Ctrl-V) the object from one Blender instance to another (both 2.83) and then continued working on the copy. They extruded part of the mesh, and a few of those resulting vertices ended up being broken. The extrusion created new vertices in the mesh, but not in the UV layer -- at least some connections are missing from what I can tell.
Here's a more complete version of the original model with the extruded part clearly emphasized.

What makes this bug even worse is the fact that this broken state is propagated to all vertices created from the broken ones, for example by extruding or loop-cutting them. None of the new vertices will show up in the UV editor.


@Richard Antalik (ISS) Here's the original file. Allegedly, pasting this into a new file and then extruding parts of the door frame was enough to cause the issue at hand. Though, even after a handful of tries I haven't been able to reproduce it, so it might be something else entirely.

@gobb_blend thank you for example file, can you add steps to what exactly should I extrude to cause the bug? also do I have to use specific Blender version?

I copied the object, extruded faces of frame to make "tunnel", exported FBX and I had no issue.

This issue could be caused by some addon as well, so it would be good to check that as well if you can reproduce the issue.

Philipp Oeser (lichtwerk) renamed this task from Error when exporting FBX to Error when exporting FBX (presumably caused by conflicting cached uv customdatalayer).Tue, Sep 15, 10:56 AM

@Richard Antalik (ISS) In our case Blender 2.83.3 was used when the bug occurred. No add-ons besides the ones that are active by default. The artist extruded (E key) the arch above the door into the wall of the building like so:


That's all I can tell you. I personally never encountered this bug, and following these steps as described doesn't cause it for me either.

Philipp Oeser (lichtwerk) triaged this task as High priority.Tue, Sep 15, 6:25 PM

Setting to hig prio since it is reported so often.

Slight amendment to the code I posted above (forgot to check if it's a mesh). If this is run from the text editor prior to export, then the fbx error disappears.

Workaround until the devs find out the root cause.

import bpy

for ob in bpy.data.objects:
    if not ob.type =='MESH':
        print(ob.name,'is not a mesh, skipping\n')
        continue
    print(ob.name,'\n')
    m = ob.data
    if m.validate(verbose=True):
        print("something was fixed with the mesh")
    else:
        print("mesh was fine")
        
    print(" and the cached custom data has been cleared to avoid export issues")