Announcement

Collapse
No announcement yet.

Importing assets into Unreal 4.20 using python

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    Basic ability to select face/s and perform operations on them, such as detaching to create a new mesh, deleting, or flipping their normals. This helps fix import problems where changing the source data is difficult or impossible. Mobdro
    Last edited by Ashton421; 10-22-2018, 12:38 AM.

    Leave a comment:


  • replied
    Hello, thank you for your help. I have also tried that but it is also not working as expected, I have tried:

    task = unreal.AssetImportTask()
    task.filename = fbxFilePath
    task.destination_path = '/Game/Meshes/Building/pythonTest1/'
    task.automated = True
    task.save = True
    task.replace_existing = True
    task.options = unreal.FbxSceneImportOptions()
    task.options.set_editor_property('hierarchy_type', unreal.FBXSceneOptionsCreateHierarchyType.FBXSOCHT_CREATE_BLUEPRINT)

    tasks = [task, ]
    unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks(tasks)
    fbxScene = tasks[0].imported_object_paths[0]

    This runs however it seems to ignore setting the task.options to FbxSceneImportOptions. If I run it with task.automated=False, it brings up the Fbx Import Options dialog box rather than Fbx Scene Import Options and the hierarchy option is not on the Fbx Import Options box.

    If I have understood this correctly, using task.options = unreal.FbxSceneImportOptions() should be the equivalent of taking me through the File -> Import into Level -> ... process, am I missing something here?

    Thanks again.

    Leave a comment:


  • replied
    Hey, that is odd. As you say, the signature for that function says it wants an AutomatedAssetImportData, but the code is expecting something else.

    Fortunately, you can do the same automated import another way. You create an unreal.AssetImportTask(), set it up with the parameters you need, including `automated = True`, then pass the task inside an array in a call to `unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks(tasks)`.

    For a code example, you can see how our Shotgun integration does it here:

    https://github.com/shotgunsoftware/t...ctions.py#L284

    hope that helps.

    Leave a comment:


  • started a topic Importing assets into Unreal 4.20 using python

    Importing assets into Unreal 4.20 using python

    Hello,

    I am trying to use the Python interface to load in a .fbx file in an automated manner, essentially trying to replace the 'File -> Import into Level -> ...' process. Currently I am trying:

    importInfo = unreal.AutomatedAssetImportData()
    importInfo.destination_path = '/Game/Meshes/Building/pythonTest1/'
    importInfo.factory = unreal.FbxSceneImportFactory()
    importInfo.filenames = [fbxFilePath, ] # This is the file path to the .fbx file
    importInfo.level_to_load = 'temp'
    importInfo.group_name = 'tmp'
    fbxScene = unreal.AssetTools.import_assets_automated(importInfo)

    But this throws the error:
    TypeError: descriptor 'import_assets_automated' requires a 'AssetTools' object but received a 'AutomatedAssetImportData'

    The API suggests that it should be passed an AutomatedAssetImportData (https://api.unrealengine.com/INT/Pyt...ssetTools.html) but this doesn't work. Am I missing something or is this a bug?

    Thanks in advance for your help.
Working...
X