# Reimport with New Source using python

**URL:** <https://forums.unrealengine.com/t/reimport-with-new-source-using-python/131487>\
**Category:** Editor Scripting\
**Tags:** unreal-engine\
**Created:** [September 23, 2019, 9:23pm UTC](https://forums.unrealengine.com/t/reimport-with-new-source-using-python/131487 "2019-09-23T21:23:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_cfc18edb](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_cfc18edb](https://forums.unrealengine.com/u/anonymous_user_cfc18edb)\
**Post date:** [September 23, 2019, 9:23pm UTC](https://forums.unrealengine.com/t/reimport-with-new-source-using-python/131487/1 "2019-09-23T21:23:31Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_cfc18edb](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_cfc18edb](https://forums.unrealengine.com/u/anonymous_user_cfc18edb)\
**Post date:** [September 27, 2019, 5:17pm UTC](https://forums.unrealengine.com/t/reimport-with-new-source-using-python/131487/3 "2019-09-27T17:17:24Z")

</div>

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

```auto

 
 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])  
 

```
