Unreal Python - Export Selected

Hi, I’ve just come across your post and it looks like the solution to my problem but I’m unable to get it to work.

I’ve tried adding it into a ‘Execute Python Script’ node inside of a EditorUtilityWidget and saving it to a .py file and running from the command bar but when I have some Static meshs selected and run the code it get:
“LogPython: Error: SyntaxError: invalid syntax (, line 18)”
and if I comment out the last line I don’t get an error but it doesn’t seem to export anything. Apologies if I’m missing something fundamentally obvious, im not a dev but trying to learn!

Ultimately, I’m trying to write a Editor Utilitiy that will batch export sections of a Datasmith import to .fbx. Everything else works but the “Export Scene” node doesn’t seem to have variables I can set then write to disk, everything I call it, it opens the dialog box for where to save the fbx’s too which is not ideal.

If yourself or the community could offer any insight about where I might be going wrong or have any advise on how I might ‘export selected’ from a Editor Utilitiy that would be greatly appreciated as it would massively speed up my workflow.

Thanks