I have created a pipeline to get geometry from Maya to Unreal via Alembics. Each Alembic file contains multiple objects which show up as multiple tracks in Unreal, but I merge the meshes / tracks to produce a single static mesh for each Alembic file.
Occasionally, new objects could be added to an Alembic file. When my pipeline then imports in the alembic, overwriting the existing static mesh, it only imports in the meshes / tracks that were also in the Alembic previously, but not any new meshes / tracks. If I manually re-import the Alembic file, I can see that it automatically only enables the tracks that were previously in the Alembic and I can manually enable all of the tracks and then all new objects also import it. However, I can’t seem to figure out how to do this in Python.
In short, the Alembic importer by default only imports in tracks that were previously imported in, when re-importing an Alembic file. When doing it manually, you can enable the new tracks. Is there a way to control this automatically in Python, so that all tracks always import in regardless of which tracks were previously imported in?
This is the code that I currently have. Since I couldn’t find any way to control which tracks get imported in, I tried deleting the static mesh first so that it wouldn’t be a “re-import” but just a normal import, but that doesn’t seem to work (at least not always).
def importAlembic(alembicFile : str, assetPath : str) -> unreal.AssetImportTask:
if unreal.EditorAssetLibrary.does_asset_exist(assetPath):
unreal.EditorAssetLibrary.delete_asset(assetPath)
options = unreal.AbcImportSettings()
options.import_type = unreal.AlembicImportType.STATIC_MESH
options.compression_settings.bake_matrix_animation = True
options.compression_settings.merge_meshes = True
options.conversion_settings.rotation = unreal.Vector(90, 0, 0)
options.conversion_settings.scale = unreal.Vector(100.0 / 16.0, -100.0 / 16.0, 100.0 / 16.0)
options.material_settings.create_materials = False
options.material_settings.find_materials = False
options.normal_generation_settings.recompute_normals = False
options.normal_generation_settings.skip_computing_tangents = False
options.static_mesh_settings.merge_meshes = True
options.static_mesh_settings.propagate_matrix_transformations = True
options.static_mesh_settings.generate_lightmap_u_vs = False
import_task = unreal.AssetImportTask()
import_task.filename = alembicFile
import_task.destination_path = os.path.dirname(assetPath)
import_task.destination_name = os.path.basename(assetPath)
import_task.factory = unreal.AlembicImportFactory()
import_task.replace_existing = True
import_task.replace_existing_settings = True
import_task.options = options
import_task.save = True
import_task.automated = True
import_task.async_ = _async
if _async == False:
asset_tools = unreal.AssetToolsHelpers.get_asset_tools()
asset_tools.import_asset_tasks([import_task])
if not import_task.imported_object_paths:
raise RuntimeError("Could not import alembic")
return import_task
I am using UnrealEngine 5.5.1 on Windows 11 (24H2)