1

I have a piece of code that selects the initial state (snapshot) of the active document.

I wonder if there exist a short way to achieve the same goal.

Here is the actual script:

var myDoc = app.activeDocument.name;
var doc = app.activeDocument.historyStates.length;

alert("History States : " + doc);


function firstStep(enabled, withDialog) {
  if (enabled != undefined && !enabled)
    return;
    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);
    var desc1 = new ActionDescriptor();
    var ref1 = new ActionReference();
    ref1.putName(cTID('SnpS'), myDoc);
    desc1.putReference(cTID('null'), ref1);
    executeAction(cTID('slct'), desc1, dialogMode); 
    alert("Selected Initial State");                
};

firstStep();

Thanks in advance

4

1 回答 1

1

Something along these lines should work for you:

docRef.activeHistoryState = docRef.historyStates.getByName('Snapshot 0');
于 2014-10-12T14:11:43.643 回答