Python scripting for importing custom assets.

The posts I found on importing with Python seem to all use the stock asset factories that UE Python API offers. I’ve seen:…0-using-python…es-with-python

I wonder how to import a custom asset based on a custom binary/text file, given that the asset factory has been defined in a plugin,
and it works to import the asset into the Editor by hand. Do I have to rebuild the Editor from source to have the factory available to Python?

Found it myself.

Learned from this video:

import unreal as ue

file = '/path/to/'

# Create an importing task

task = ue.AssetImportTask()
task.set_editor_property('automated', True)
task.set_editor_property('destination_name', '')
task.set_editor_property('destination_path', '/Game/My/Destination/Folder')
task.set_editor_property('filename', file)
task.set_editor_property('replace_existing', True)
task.set_editor_property('save', True)

# Run the task


Given that I already have a plugin that defined the factory for *.my. This code should work when executed in the Editor.

For the CLI solution, it should be

 /path/to/UE4Editor-Cmd.exe /path/to/my.uproject -run=pythonscript -script="/path/to/"