Unity offers a free plugin to export meshes as fbx files from the editor. Yesterday, I tried to find out how to call the export function from code. Finally, I got it running but not during runtime but only from an editor script.
FbxExporters.Editor.ConvertToModel.Convert(target.gameObject, null, savePath, null, null, null);
Whereever, you include this line of code make sure it is in a folder called Editor. Otherwise the class FbxExporters.Editor won’t be visible. Unfortunately, there remains a limitation. You can only write your fbx files to the Assets folder and not to an arbitrary folder on your hard drive. If you figure out how to solve this, please tell me 🙂
Is not difficult to export a mesh (or multiple mesh) by script with this plugin in the editor at the folder you want.
This example shows how: https://docs.unity3d.com/Packages/com.unity.formats.fbx@2.0/manual/devguide.html
The problem, for me, is finding a way to do this even in runtime and not only in Editor, but i don’t know where to start for build a custom exporter with Autodesk.FBX namespace. :/