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

Group of action within an UNDO command in UXP plugins

New Here ,
Jan 18, 2024 Jan 18, 2024

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
526
Translate
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
Community Expert ,
Jan 19, 2024 Jan 19, 2024

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
Translate
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

I mean two actions, as for instance:

  • call to "insertImageAsLayer" and then,
  • call to"putSelection"
Translate
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 ,
Jan 19, 2024 Jan 19, 2024
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
Translate
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