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!
Copy link to clipboard
Copied
When you say "2 actions", do you mean two separate functions or actual items from the Actions palette?
Copy link to clipboard
Copied
I mean two actions, as for instance:
Copy link to clipboard
Copied
> 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