I’m creating an fbx anim import tool in unreal editor using python script and editor utility widget.
My python script only works after I have manually imported some fbx anim.If I call it right after I launch the editor it will throw errors below(not really much info)
here is my python script
import os.path
import unreal
import sys
fbx_dir = sys.argv[1]
target_skeleton = sys.argv[2]
print(fbx_dir)
print(target_skeleton)
# Option
taskoptions = unreal.FbxImportUI()
taskoptions.set_editor_property('Skeleton', unreal.find_asset(target_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.set_editor_property('automated_import_should_detect_type', False)
taskoptions.set_editor_property('mesh_type_to_import', unreal.FBXImportType.FBXIT_ANIMATION)
# Task
tasks = []
for root, dirs, files in os.walk(fbx_dir):
for file in files:
print(file)
target_file = file.replace('.fbx', '')
task = unreal.AssetImportTask()
task.filename = os.path.join(root, file)
task.destination_path = "/Game/Anim/"
task.automated = True
task.save = True
task.replace_existing = True
task.set_editor_property('options', taskoptions)
tasks.append(task)
unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks(tasks)