Invoke the File Browser inside an Add-On but wait with the rest of the script until it's closed 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 = &quot;import_fbx.read_data&quot;  
bl_label = &quot;Import FBX&quot;

# ImportHelper mixin class uses this
filename_ext = &quot;.fbx&quot;

filter_glob: StringProperty(
    default=&quot;*.fbx&quot;,
    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.
The solution was very simple at the end. Everything what needs to be done with the data which was loaded by the ImportHelper should be part of the execute method of this class.
The invoke method (in my above script) was not needed at the end:
class ImportFBXData(Operator, ImportHelper):
    bl_idname = &quot;import_fbx.read_data&quot;  
    bl_label = &quot;Import FBX&quot;
    
    filter_glob: StringProperty(
        default='*.fbx',
        options={'HIDDEN'})
    
    def execute(self, context):
        # Everything what needs to be done before opening the file browser 
        new_fbx_collection = bpy.data.collections.new(&quot;New COllection&quot;)
        bpy.context.scene.collection.children.link(new_fbx_collection)

        # Open the File Browser and Import the FBX File
        filename, extension = os.path.splitext(self.filepath)
        bpy.ops.import_scene.fbx(filepath = self.filepath)
        
        # Everything what needs to be done after the file browser 
        ...
        obs = [o for o in bpy.data.collections[context.collection.name].all_objects if not o.parent and len(o.children)]
        for o in obs:
            ...
    return {'FINISHED'}

This way my Add-On works perfectly.