Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

After Effects warning: Undo group mismatch, will attempt to fix

New Here ,
Feb 20, 2025 Feb 20, 2025

Copy link to clipboard

Copied

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.

TOPICS
Error or problem , How to , Import and export , Scripting

Views

97
Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Feb 20, 2025 Feb 20, 2025

Copy link to clipboard

Copied

Undo group breaks when you are importing the file

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 20, 2025 Feb 20, 2025

Copy link to clipboard

Copied

Have you tried wrapping your beginUndoGroup() and endUndoGroup() around the entire try/catch/finally structure instead of inside try and finally? It seems like that would be safer.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Feb 20, 2025 Feb 20, 2025

Copy link to clipboard

Copied

LATEST

Hey Dan, thanks for the reply.

I tried wrapping beginUndoGroup() and endUndoGroup() around the entire try/catch/finally structure, but it still throws the undo group mismatch error.

From Alex White's comment, I understand that importing a file breaks the undo group.

I tried a different approach by moving beginUndoGroup() after app.project.importFile(), which seems to fix the error for now. However, I can’t manually undo the file that was imported into the project panel.

Votes

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines