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
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
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
Copy link to clipboard
Copied
Thank you Davide, very well explained. I fully understand it now
Copy link to clipboard
Copied
SuspendHistory
how to do same things in C# or VB.net or VBSCript ?....
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...
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?
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?
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.
Copy link to clipboard
Copied
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+"')");