Hi!
I’m having problems with my Add-On.
I’m creating a new Collection, making it active, opening up an FBX-Import Window and if selected, loading the FBX File.
After that I would like to join and clean up the data, add materials, etc.
Unfortunately all of the commands after the FBX import are run before the import actually finished.
Here is part of the script:
bpy.ops.import_fbx.read_data('INVOKE_DEFAULT')
print("Import FBX is ready")
The message gets printed before the import process finishes.
If I import an FBX via the UI, Blender hangs as long as it imports.
I though this will be the same with my Add-on but it seems that my import routine is called parallel to the execution of the rest of my script.
(I don’t mind if my Add-On hangs as long as the import is running).
Is there a way to wait until it is finished?
I read some examples about modal operators but I don’t really understand them. In those examples it seems to be important that the UI does not lock up. In the current state of my python experience level, I don’t mind if its locked up as long as it runs in sequence.
I call this as stated above from an interface button:
... other functions run ahead ...
bpy.ops.import_fbx.read_data('INVOKE_DEFAULT')
... other functions should run after but these need to wait until the FBX import is finished...
Can someone help me understand how to modify my functions with the above code sample? Which function should run modal? The read_fbx_data or the Import_Helper?
Thanks for any help.
EDIT:
I was completely wrong. It’s not the FBX converter which runs parallel. It’s the Import_Helper which is {‘RUNNING_MODAL’}. I guess here lies the Problem.
Hard coding the FBX File name and path and only invoking bpy.ops.import_scene.fbx works as it should and executes everything sequentially.
So the question is now, how do I get my script to wait until the ImportHelper is finished?
Thanks for the link! Yesterday evening I was able to solve my problem the same way.
Everything what needs to be done after invoking the ImportHelper must be in the same Class. It’s actually very obvious but as a Blender Python novice I didn’t know that.