Reimport with New Source using python

Hello,

I have a script which goes through my unreal scene to find all .fbx files, determines if it’s an out of date version, then finds a path to the proper version in our database.
I would like to have a way to call the “Reimport with New Source” function through my python script.

Is this possible?

I see here:
https://docs.unrealengine.com/en-US/PythonAPI/class/AnimSequence.html
that there’s a “retarget_source” function, but when I try to call it, I get an AttributeError saying the function doesn’t exist.

Thanks.

This was the solution I made while the forums were down:


 
 def reimport_animation(anim_sequence, fbx_path):   
     import_task = unreal.AssetImportTask()   
     import_task.destination_name = anim_sequence.get_name()   
     import_task.destination_path = anim_sequence.get_path_name().rpartition("/")[0]   
     import_task.filename = fbx_path   
     import_task.replace_existing = True   
     import_task.automated = True   
     import_task.factory = unreal.FbxFactory()   
     import_task.options = unreal.FbxImportUI()   
     import_task.options.set_editor_property("skeleton", anim_sequence.get_editor_property("skeleton"))   
     import_task.options.import_materials = True   
     import_task.options.import_textures = True   
     import_task.options.import_as_skeletal = False   
     import_task.options.mesh_type_to_import = unreal.FBXImportType.FBXIT_ANIMATION   
     unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks([import_task])  
 

1 Like