Import animation without mesh in Unreal 4.22 using python

Hello !
I do a script for import a animation in unreal engine but the parameter FbxImportUI.import_mesh does not work :confused: When I run the script it import the animation and the mesh but I want import only the animation, the mesh already exists in another folder.

This is my code :

import os.path
import unreal

# Option
taskoptions = unreal.FbxImportUI()
taskoptions.set_editor_property('Skeleton', unreal.find_asset(r'/Game/Temp/SK_Armature_Skeleton.SK_Armature_Skeleton'))
taskoptions.set_editor_property('import_materials', False)
taskoptions.set_editor_property('import_textures', False)
taskoptions.set_editor_property('import_animations', True)
taskoptions.set_editor_property('import_mesh', False)
taskoptions.set_editor_property('create_physics_asset',False)
taskoptions.set_editor_property('original_import_type', unreal.FBXImportType.FBXIT_ANIMATION)
taskoptions.skeletal_mesh_import_data.set_editor_property('import_morph_targets', True)

# Task
task = unreal.AssetImportTask()
task.filename = r'D:\MyAnim\ArmatureAction.fbx'
task.destination_path = r'/Game/Temp/Anim'
task.automated = True
task.save = True
task.replace_existing = True
task.set_editor_property('options', taskoptions)

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

I did something wrong? Thank you for your reply !

In unreal you cannot import an animation without a mesh it seems.
I tried many times before.
You cant even import a multi take/animation fbx

You can do it if the skeleton already exists it was enough to select the skeleton and uncheck import mesh. (Like in the picture)
I do the same manipulation with python but it does not work :confused:

You could check if you get the same result with the unofficial Python plugin: GitHub - 20tab/UnrealEnginePython: Embed Python in Unreal Engine 4 (example of importing animations in /Tutorials/YourFirstAutomatedPipeline.md)

If that works fine submit a bug report for the UE4 python plugin.

https://forums.unrealengine.com/development-discussion/python-scripting/1576474-importing-skeletal-meshes-4-21
I find a solution.



options.automated_import_should_detect_type = False


I was facing the same issue as, but your solution doesn’t fix my problem.

I’m trying to import an FBX containing nothing but an animated cylinder.
The corresponding Skeleton, SkeletalMesh and Material have already been imported elsewhere.

Importing the FBX manually with these settings is giving the expected result : just an AnimationSequence.

And now here is my code :
options = unreal.FbxImportUI()
# options.automated_import_should_detect_type = False
options.original_import_type = unreal.FBXImportType.FBXIT_ANIMATION
options.import_animations = True
options.create_physics_asset = False
options.import_mesh = False
options.import_rigid_mesh = False
options.import_materials = False
options.import_textures = False
options.import_as_skeletal = False
options.skeleton = unreal.load_asset(skeleton_path)
return options

The second line (options.automated_import_should_detect_type = False) is giving a StaticMesh.
If I comment or remove it, the import gives a SkeletalMesh + an AnimationSequence, which is better, but I still want to get rid of this SkeletalMesh and I can’t manage to only get the AnimationSequence.

I’ve tried using set_editor_property rather than the direct parameters but it doesn’t change anything.

1 Like

I have found a way, you need to set mesh_type_to_import to unreal.FBXImportType.FBXIT_ANIMATION.

options.set_editor_property('automated_import_should_detect_type', False)
options.set_editor_property('original_import_type', unreal.FBXImportType.FBXIT_SKELETAL_MESH)
options.set_editor_property('mesh_type_to_import', unreal.FBXImportType.FBXIT_ANIMATION)
1 Like

Good job, your answer has fixed my issue!

Hi Guys!

Thank you for all your replies, I had more or less the same problem.
None of these solutions worked for me (I’m working in Unreal 5.2 now),
and I keep getting this error:

FBXImport: Warning: Mesh [Geometry have no name] in the fbx file is not reference by any hierarchy node.
FBXImport: Error: Import failed.

This is my code:

for x in fileNames:
    task.filename = x
    task.destination_path = destination_path
    task.replace_existing = True
    task.automated = True
    task.save = True
    task.options = unreal.FbxImportUI()
    
    
    task.options.automated_import_should_detect_type = False
    task.options.mesh_type_to_import = unreal.FBXImportType.FBXIT_ANIMATION
    task.options.import_materials = False
    task.options.import_textures = False
    task.options.import_animations = True
    task.options.import_mesh = False
    task.options.skeleton = unreal.find_asset('/Game/MetaHumans/Common/Female/Medium/NormalWeight/Body/metahuman_base_skel.uasset')
    
    task.options.skeletal_mesh_import_data.set_editor_property('use_t0_as_ref_pose', True)
    task.options.skeletal_mesh_import_data.set_editor_property('import_meshes_in_bone_hierarchy', False)

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

I’ve tried to set import_meshes_in_bone_hierarchy and use_t0_as_ref_pose, as I read it somewhere, it could help, but unfortunately not.