After Effects warning: Undo group mismatch, will attempt to fix
Hey everyone,
I have a script that imports an .aep file into the active composition. The script works, but when I try to undo, After Effects throws this warning:
Undo group mismatch, will attempt to fix.
It happens whenever I use app.executeCommand or other app. methods inside app.beginUndoGroup and app.endUndoGroup.
Code Snippet below;
export const ImportPrecomps = (PrecompName: string, Alpha: number, Theme: number) => {
try {
const comp = getActiveComp();
const myBin = getOrCreateBin("TestBin");
app.beginUndoGroup("Import Precomps");
let precomp = findPrecompInBin(PrecompName, myBin);
if (!precomp) {
const file = new File("/path/to/my.aep");
const importOptions = new ImportOptions(file);
app.project.importFile(importOptions);
// Find the imported precomp
precomp = findPrecompInBin(PrecompName, myBin);
if (precomp) precomp.parentFolder = myBin;
}
if (precomp) {
const newLayer = comp.layers.add(precomp);
newLayer.property("ADBE Layer Overrides").property(1).setValue(Alpha);
newLayer.property("ADBE Layer Overrides").property(2).setValue(Theme);
} else {
alert("Precomp not found: " + PrecompName);
}
} catch (e) {
alert("Error importing precomp: " + e);
} finally {
app.endUndoGroup();
}
};
The script works fine, but undoing throws the “undo group mismatch” warning. I suspect it might be due to app.executeCommand or the import operation affecting the undo stack.
Has anyone faced this issue before? Any suggestions on handling undo groups properly in this scenario?
Thanks in advance!
I tried this with multiple versions of AE. 2022, 2023, 2025 and beta. but no luck.
