Download

Import Mesh LODs through Python

Hello, I’ve got a python script which will import/re-import static meshes. The problem is that setting Import Mesh LODs to True doesn’t seem to work.

I had this issue when trying to set the vertex color import option, but deleting the asset first resolved that. Deleting the asset first doesn’t seem to resolve this.

    import_task = unreal.AssetImportTask()
    import_task.destination_name = static_mesh_name
    import_task.destination_path = static_mesh_path
    import_task.filename = publish_path
    import_task.automated = automate_import
    import_task.replace_existing = True
    import_task.save = True

    options = unreal.FbxImportUI()
    options.set_editor_property('import_mesh', True)
    options.mesh_type_to_import = unreal.FBXImportType.FBXIT_STATIC_MESH
    options.set_editor_property("import_materials", False)
    options.set_editor_property("import_textures", False)
    options.set_editor_property("import_as_skeletal", False)
    options.set_editor_property('create_physics_asset', False)
    options.set_editor_property('automated_import_should_detect_type', False)
    options.set_editor_property('import_animations', False)

    static_mesh_import_data = unreal.FbxStaticMeshImportData()
    static_mesh_import_data.set_editor_property("combine_meshes", True)
    static_mesh_import_data.set_editor_property("reorder_material_to_fbx_order", True)
    static_mesh_import_data.set_editor_property("remove_degenerates", remove_degenerates)
    static_mesh_import_data.set_editor_property("import_mesh_lo_ds", import_mesh_lods)
    if replace_vertex_color:
        static_mesh_import_data.set_editor_property("vertex_color_import_option", unreal.VertexColorImportOption.REPLACE)

    options.set_editor_property("static_mesh_import_data", static_mesh_import_data)

    import_task.set_editor_property('options', options)

    unreal.AssetToolsHelpers.get_asset_tools().import_asset_tasks([import_task])

When I print the value of “import_mesh_lo_ds”, it’s being set to True properly, but the checkbox isn’t ticked when I open the asset after.