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

Suspend History States

Contributor ,
Nov 11, 2016 Nov 11, 2016

Copy link to clipboard

Copied

Is there a way to stop the steps in a script showing up in the history.

I have seen other posts talking about suspendHistory but `i am not that familiar with how to use that call

TOPICS
Actions and scripting

Views

5.6K

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

correct answers 1 Correct answer

Advocate , Nov 11, 2016 Nov 11, 2016

Say that you need to run the following code:

var doc = app.activeDocument;

var lay = doc.activeLayer;

var dup = lay.duplicate();

dup.name = "Friday";

dup.applyGaussianBlur (20);

alert("Too much wine");

This leaves 3 steps in the History palette.

The suspendHistory() method accepts two params: the string that is going to appear in the History palette in lieu of the 3 "normal" steps; and the 6 lines of ExtendScript I've written above. E.g.

app.activeDocument.suspendHistory('Swing', 'var doc = app.activeDoc

...

Votes

Translate

Translate
Adobe
Advocate ,
Nov 11, 2016 Nov 11, 2016

Copy link to clipboard

Copied

Say that you need to run the following code:

var doc = app.activeDocument;

var lay = doc.activeLayer;

var dup = lay.duplicate();

dup.name = "Friday";

dup.applyGaussianBlur (20);

alert("Too much wine");

This leaves 3 steps in the History palette.

The suspendHistory() method accepts two params: the string that is going to appear in the History palette in lieu of the 3 "normal" steps; and the 6 lines of ExtendScript I've written above. E.g.

app.activeDocument.suspendHistory('Swing', 'var doc = app.activeDocument; var lay = doc.activeLayer; var dup = lay.duplicate(); dup.name = "Friday"; dup.applyGaussianBlur (20); alert("Too much wine");'

Usually you won't stick that much code into a string, so the following is the usual pattern:

function main() {

  var doc = app.activeDocument;

  var lay = doc.activeLayer;

  var dup = lay.duplicate();

  dup.name = "Friday";

  dup.applyGaussianBlur (20);

  alert("Too much wine");

}

app.activeDocument.suspendHistory ("Swing", "main()");

Hope this helps,

Davide

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
Contributor ,
Nov 11, 2016 Nov 11, 2016

Copy link to clipboard

Copied

Thank you Davide, very well explained. I fully understand it now

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 ,
Oct 14, 2017 Oct 14, 2017

Copy link to clipboard

Copied

SuspendHistory

how to do same things in C# or VB.net or VBSCript ?....

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 ,
Oct 15, 2017 Oct 15, 2017

Copy link to clipboard

Copied

It is documented in the PS javascript reference, so I assumed a similar entry could be found in the VB reference – but it's not, check here: Adobe Photoshop Scripting. I'm afraid I have no better suggestions to share...

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 ,
May 02, 2020 May 02, 2020

Copy link to clipboard

Copied

This worked to get rid of all the layer states from my script but now my script runs again once it completes. What am I doing wrong?

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
Community Expert ,
May 02, 2020 May 02, 2020

Copy link to clipboard

Copied

What would cause your script to be run as second time?  Post your modified  script the changed code for some reason is now  may be running the main function twice. The question was written three years ago so I assuming you have just just now  modicied your existing sectipt to suspend history.  Which is done by using fumction is there more then one use of that function in the scripts code? 

JJMack

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 ,
May 02, 2020 May 02, 2020

Copy link to clipboard

Copied

Yeah I figured it out just now, when I turned my action into a script file (using another script) it was adding this at the end of the code. It ran fine when I tried it at first but was leaving history states and when I added the line of code to suspend history it made the script re-run not sure why so I just deleted this section and added the code to the end to remove the history states and now it works.

};

//=========================================
// Frequency.main
//=========================================
//

Frequency.main = function () {
Frequency();
}

Frequency.main();

// EOF

"Frequency.jsx"
// EOF

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
Advocate ,
Nov 03, 2023 Nov 03, 2023

Copy link to clipboard

Copied

LATEST

Does anyone know how to pass a parameter when we do that suspendHistory?

 

app.activeDocument.suspendHistory(localize(locCreateCustomFrameDialog), 'createCustomFrameDialogMain.Main(createCustomFrame)');

 

this return evalScript error. Tried a couple other method like adding 'createCustomFrame' but that will not work.

 

This also causes evalScript error

app.activeDocument.suspendHistory(localize(locCreateCustomFrameDialog), "createCustomFrameDialogMain('"+createCustomFrame+"')");

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