Auto Importing FBX via Commandlet
We are working on a commandlet that will check a folder for FBX and texture files and run an automated import on them.
When manually importing a file, the Editor appears to use the functionality in UFbxFactory. I'm wondering if this is what we will need to tap into for the automated import as well and how best to do that.
Before we spend a lot of time potentially heading in the wrong direction, I wanted to see if anyone could offer some guidance (examples would be amazing if you have them:)). Thanks for any help you can give!
asked Sep 02 '14 at 09:40 PM in C++ Programming
It looks like we can't use ImportAssets from a commandline call to a commandlet. The Main() in the commandlet seems to fire before the Editor is fully loaded which is causing eexceptions from GEditor->Broadcast in AssetTools.cpp.
As an alternative, I was able to use FEditorDelegates::OnMapOpened in order to fire my import function automatically, which works since the map is not loaded until the Editor is fully loaded. This seems a bit hacky, but does the job.
I could not find a way to wait for the Editor to fully load with the commandlet. I don't think this is intentional, so it might be a bug with commandlets running editor functions.
You can do this in a commandlet to import assets:
FactoryToUse is optional. If you don't specify one it will figure it out. However the major problem with FBX is that a dialog appears asking for FBX settings. FBX's are complicated and we cant easily determine in all cases what is in the file and what the user wants without asking ( and there could be multiple things in the file). You are going to have to work around this. I suggest constructing your own UFbxFactory instance, passing it in to the method above and adding some method to the UFbxFactory to specify the settings up front and not show the dialog. There is some basic auto-detection of asset type in the FBX file so simply adding a flag to not show the dialog and use the defaults might work out OK for you.
It's in the 4.14 prerelease and sorta buggy at the moment, but there is a new Commandlet coming to do this! It's called ImportAssetCommandlet (see commit) and can be invoked as
answered Nov 14 '16 at 08:00 PM
Digi Labs Dan
I am trying to import FBX file to my project but I got some problem,it bother me for a long time.
but it did not work,
Would you mind show me your .cpp file,this is my e-mail:email@example.com.
Very appreciate your help!
answered Mar 25 '16 at 07:18 AM
I've tried a lot of different ways to get this to work and still nothing is perfect. I've got the commandlet solved but I'd like to make it a new "scene import". Here's a post with all of my code and maybe something will help you. fbx-automated-command-line-import
answered Dec 03 '18 at 04:03 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here