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);`