Display progress bar during scene export as FBX

Maybe one of you guys can help me with this. I’m looking for a way to display a progress bar in Blender’s info bar during scene export.
image
When we’re exporting assets as FBX files at the studio, Blender sometimes freezes for a minute or more, especially when exporting actions with lots of keyframes. It’s bothering our animators quite a bit, so it would be nice if our custom export addon was able to communicate to them that Blender hasn’t crashed, and the export is at X percent.
Our script basically just runs bpy.ops.export_scene.fbx at the click of a button.

Back when I wrote a texture baking addon, I used ‘INVOKE_DEFAULT’ to display a progress bar during baking, but that doesn’t seem to work here. Is there another soluton?

I see in another addon bpy.context.window_manager.progress_update() that might be worth looking at.

https://docs.blender.org/api/master/bpy.types.WindowManager.html?highlight=progress_begin#bpy.types.WindowManager.progress_begin

1 Like

Thanks for replying! Your approach should temporarily turn the mouse cursor into a little black progress indicator like when you’re exporting a movie file. At least in theory it should.

However, when used in connection with the FBX export process, it’s not working at all. The little black square remains black and (on Win10) even changes to a loading spinner after some time. As soon as the FBX export reaches the step named “Wrapping Animations”, Blender freezes and acts as if it has crashed. Only once the export has fully finished will it suddenly spring back to life.

Hmmm. maybe you have to run it inside a modal so it doesn’t tie up the thread?

A modal behaves exactly the same as a regular one. Unless I’m doing it wrong somehow.

Maybe this?

That was actually my first approach, but in this case it simply does nothing at all.

Why not run Blender Python (via the addon) and spawn a new Blender instance that way in a terminal and export in the terminal so they see the progress. Not so nice looking but at least they do not need to wait for the export and they can see the progress.

1 Like

That solution may not be as pretty as a progress bar, and it will add a couple extra seconds to the whole process, but at least the Blender instance they’re working with is not going to freeze that way. (Or will it?) I’ll keep that in mind as a last resport. Thank you!

I am glad it sounded useful, make sure you save the file in the addon :slight_smile:

Yeah, that immediately struck me as another downside. Normally, I wouldn’t want to force the user to save their file every time they click “export”. So I’m still hoping for someone to post an even better solution.

Though, at the moment it does look like I’m limited by Blender’s actual export code. If the animation wrapping process freezes the software, then that’s just how it is. And unless someone suddenly comes up with another solution in the coming days, I guess that only a patch to the master branch could fix this issue. (And that patch is not going get made.)

Well you can just make a temporary version of the .blend (copy=true) then export from there, they do not have to save it.

Your other option could be to integrate the whole fbx add-on into your own addon and modify it to show better progress.

Ah that is true. FBX export itself IS just another addon. Alas, I don’t think I’m skilled enough to do anything with it, so for now I’ll simply wait and hope for someone else to post another solution that can be done with the regular high level API that everybody understands.