Search code examples
pythoncrashblenderbpy

FBX import using bpy suddenly crashing


I have a script that batch processes fbx's for me, and I am having issues where specific meshes aren't importing when calling bpy.ops.import_scene.fbx() (27 of 73). The script will crash suddenly without outputting any error.

I am using blender built as a python module in my script.

Here is an small replicable piece of code that crashes on that same piece.

import bpy

mesh_path = "my/path/here"

print("import started")
bpy.ops.import_scene.fbx(filepath=mesh_path)
print("import finished")

Running that results in:

WARN (bgl): C:\blender-git\blender\source\blender\python\generic\bgl.c:2656 BPyInit_bgl: 'bgl' imported without an OpenGL backend. Please update your add-ons to use the 'gpu' module. In Blender 4.0 'bgl' will be removed.
importing started
FBX version: 7300

Then the process ends with no error or output after that.

I have tried running blender as a normal program and importing that same piece and it has worked as well, the paths between working and broken pieces seem to be identical as well. I'm not sure what other differences there could be other than the meshes themselves, but every mesh I am working with is a giant division of a giant mesh, so settings between them should be identical.

Any help or ideas would be greatly appreciated thank you.

Update: I was able to find that my built bpy module was actually using the newest 3.6.0 alpha build of blender. But the in editor testing I was doing was in 3.5.0, so I built a editor version of 3.6.0 and had the same issue as above but in the editor now, so it must be a bug with that newest build.

I set this build to use 3.5.0, and the import is working! But I am having a weird bug where all mesh polygons I import are returning as a list of 0.

I'm not sure if I should continue the search for a fix here, or if I should create a new question.

Update 2: I was able to import the mesh in editor on my manual 3.5.0 build, but it only imported as vertices. I looked through the build log and found a couple of warnings and one involved the mesh importer. So I tried another build doing "make import" and "make". That ended up working out and the mesh imported correctly, I did the same for the bpy branch and it worked as well.


Solution

  • I had to revert back to 3.5 instead of 3.6.0 alpha on my manual bpy build. And made sure to do "make update" to get the latest revisions on that build. Then I was able to have success and things work again.