Python Fbx Import Animation Sequence only

gloogloox
Tue, 02 Mar 2021 21:50:01 +0000
Editor Scripting

Hey,

Using the Fbx Import UI, it is easy to only import an AnimationSequence, as long as we already have the Skeleton. Just have to uncheck “Import Mesh” and select the proper Skeleton. It will set the importing mode to “Import Animation” automatically:

I’m looking to do the same using the Python API. Here’s the Python code I have been working on. When running it, a SkeletalMesh is created as well as the Animation Sequence, but I want only the Animation Sequence. How would you achieve that?

task = unreal.AssetImportTask()
task.filename = source_fbx
task.destination_path = dest_path
task.destination_name = name

task.replace_existing = True
task.automated = True
task.save = True

task.options = unreal.FbxImportUI()
task.options.import_materials = False
task.options.import_animations = True
task.options.import_as_skeletal = True
task.options.import_mesh = False

task.options.skeleton = unreal.load_asset(skeleton_asset)

task.options.mesh_type_to_import = unreal.FBXImportType.FBXIT_ANIMATION

unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks([task])

2 posts - 1 participant