Copy link to clipboard
Copied
Hello!
This script selects the first history state.
var doc = app.activeDocument;
doc.activeHistoryState = doc.historyStates [0];
independently of the quandity of historical states, how do I select only the last one?
Thank you.
var doc = app.activeDocument; | |
doc.activeHistoryState = doc.historyStates[doc.historyStates.length-1]; |
Copy link to clipboard
Copied
var doc = app.activeDocument; | |
doc.activeHistoryState = doc.historyStates[doc.historyStates.length-1]; |
Copy link to clipboard
Copied
Perfect! Thank you SuperMerlin
Copy link to clipboard
Copied
Any way to add logic to find out what the active history state is? I want to make a conditional toggle, to go from 0 to Max. But it doesn't look like activeHistoryState shows that info.
app.activeDocument.activeHistoryState
------------------------
1) name=Deselect
2) parent=[Document example.psd]
3) snapshot=false
4) typename=HistoryState
Copy link to clipboard
Copied
This seems to function the way I want, it's just a little more binary since I can't lookup the number, but I guess that's not necessarily a bad thing.
//History State 0 is open document
aD = app.activeDocument;
aH = aD.activeHistoryState;
aHL = aD.historyStates.length;
if(aH != aD.historyStates[aHL-1]) aD.activeHistoryState = aD.historyStates[aHL-1];
else{aD.activeHistoryState = aD.historyStates[0]}