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

Group of action within an UNDO command in UXP plugins

New Here ,
Jan 18, 2024 Jan 18, 2024

Copy link to clipboard

Copied

Hi all,

 

I would like to group together more than 2 actions for them to be part of the same UNDO command.

I have seem some options (begin/endUndoGroup and suspendHistory) but it seems that none of them are available for UXP plugins.

I have read some comments including a proposal to use batchPlay for this.

Is this the unique option for this problem?

Thank you in advance!

 

 

  

TOPICS
Actions and scripting

Views

261

Translate

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
Adobe
Engaged ,
Jan 19, 2024 Jan 19, 2024

Copy link to clipboard

Copied

When you say "2 actions", do you mean two separate functions or actual items from the Actions palette?

Davide Barranca - PS developer and author
www.ps-scripting.com

Votes

Translate

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 ,
Jan 19, 2024 Jan 19, 2024

Copy link to clipboard

Copied

I mean two actions, as for instance:

  • call to "insertImageAsLayer" and then,
  • call to"putSelection"

Votes

Translate

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
Engaged ,
Jan 19, 2024 Jan 19, 2024

Copy link to clipboard

Copied

LATEST

> when you say "2 actions"...
> I mean two actions...

 

LOL

If you want to run two Actions (capital A):

 

const { app } = require("photoshop");
app.activeDocument.suspendHistory(async (context) => {
  await app.actionTree
    .find(({ name }) => name === "Set 1")
    .actions.find(({ name }) => name === "Action 1")
    .play();

  await app.actionTree
    .find(({ name }) => name === "Set 1")
    .actions.find(({ name }) => name === "Action 2")
    .play();

  // Etc.
}, "Running a bunch of Actions");

 

If you want to run multiple ActionJSON descriptors, then BatchPlay supports the array notation:

 

await app.activeDocument.suspendHistory(async () => {
  await batchPlay(
    [
      { /* ... */ },
      { /* ... */ },
    ],
    {}
  );
}, "Custom history string here ");

 

HTH

 

Davide Barranca - PS developer and author
www.ps-scripting.com

Votes

Translate

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