I'm writing an Add-on in which I create a new Collection and then invoke the ImportHelper to load an FBX file. After that I would like to process the loaded data. My Problem is, that my script doesn't wait until the ImportHelper is finished.
I defined the Import Helper like this:
class ImportFBXData(bpy.types.Operator, ImportHelper):
bl_idname = "import_fbx.read_data"
bl_label = "Import FBX"
# ImportHelper mixin class uses this
filename_ext = ".fbx"
filter_glob: StringProperty(
default="*.fbx",
options={'HIDDEN'},
maxlen=255,
)
use_setting: BoolProperty(
)
def invoke(self, context, event):
context.window_manager.fileselect_add(self)
return {'RUNNING_MODAL'}
def execute(self, context):
bpy.ops.import_scene.fbx(filepath = self.filepath)
return {'FINISHED'}
I start this inside my Operator:
bpy.ops.import_fbx.read_data('INVOKE_DEFAULT')
Everything in front of this call gets executed properly. The File Browser comes up and I can select a file which is loaded properly. Because the File Browser runs modal, everything after it's call runs immediately but there is no data yet. How can I make the rest of the script to wait until I select a file, the FBX conversion is done and the data is loaded in to Blender?
I don't mind if the UI is locked up until the conversion is finished but I definitely need the file browser to select the FBX file.