Assign interchange pipeline at runtime

Is there any way to write a blueprint or c++ utility function to automatically change the interchange stack that given set of UStaticMesh|USkeletalMesh assets are using?

I need to convert a very large number of meshes to use a custom stack instead of the default FBX stack but am not having much luck swapping the interchange stack from code. The only reliable method of changing the stack seems to be from the "Reimport Content’ dialog.

[Image Removed]

The custom interchange stack uses two pipelines, the second one doing additional work post import.

[Image Removed]

I have a Scripted Asset Action that runs on all selected assets, and runs a c++ function on any static or skeletal mesh selected. The c++ then retrieves the UAssetImportData for that asset and tries to convert it to interchange with the correct pipeline stack.

I can get the custom import to run once, but if the asset was imported using the legacy FBX pipeline, the interchange conversion doesn’t “stick”. The next time I do a reimport on the asset, it will revert back to the legacy FBX pipeline unless I manually set the stack using the dialog, which simply doesn’t scale to hundreds of assets.

This is what my code looks like, am I missing something?

There is precious little documentation on the interchange system.

Thanks.

`// Find the desired pipeline stack
const FName OutlinePipelineStack = TEXT(“OutlinedMeshes”);
const UInterchangeProjectSettings* InterchangeProjectSettings = GetDefault();
check(InterchangeProjectSettings);
const FInterchangePipelineStack* Stack = InterchangeProjectSettings->ContentImportSettings.PipelineStacks.Find(OutlinePipelineStack);
check(Stack);

// Retrieve the pipelines from the stack
UInterchangeAssetImportData* InterchangeAssetImportData = UInterchangeAssetImportData::GetFromObject(Mesh);
UAssetImportData* AssetImportData;
if (!InterchangeAssetImportData)
{
if (StaticMesh)
{
AssetImportData = StaticMesh->GetAssetImportData();
}
else
{
AssetImportData = SkeletalMesh->GetAssetImportData();
}
Mesh->Modify();

FImportAssetParameters Params;
Params.ReimportAsset = Mesh;
Params.OverridePipelines = Stack->PerTranslatorPipelines[0].Pipelines; // only one entry in the array for FBX
bool success = UInterchangeManager::GetInterchangeManager().ConvertImportData(AssetImportData, Params);
check(success);
InterchangeAssetImportData = UInterchangeAssetImportData::GetFromObject(Mesh);
}
check(InterchangeAssetImportData);
TArray<UObject*> Pipelines;
for (FSoftObjectPath Path : Stack->Pipelines)
{
UObject* Pipe = Path.ResolveObject();
Pipelines.Add(Pipe);
}

// Set the pipelines
InterchangeAssetImportData->SetPipelines(Pipelines);`

Or, to simplify the question, is there a way to programmatically change the stack preset on an already imported asset so it will always reimport with the NEW stack moving forward and not the one that it was originally imported with?

Hi Stephane,

First of all, my apologies for the very late answer.

If you have a mesh imported with the legacy importer, I recommend to use UInterchangeManager::GetInterchangeManager().ConvertImportData(Mesh, TEXT(“fbx”));

This should take care of everything including replacing the old AssetImportData with the Interchange one. It looks like this was missing.

When importing a new mesh through Interchange FBX, add your own pipeline to the default stack. This pipeline should overwrite the ExecutePostImportPipeline method where it will add your reimport pipeline to the UInterchangeAssetImportData of the newly imported mesh.

Let me know how it goes.

Thanks for your patience.

Regards,

Jean-Luc