2 Replies Latest reply on Oct 3, 2017 3:21 AM by tokuredit

    Snapshot help

    tokuredit Level 1

      Hello friends! How to check if the current document has a snapshot named "Initial Color"? If it already exists, do nothing, and if it does not exist, add it.

        • 1. Re: Snapshot help
          natrev Level 3

          Hi tokuredit,


          Hope this will help..


          var doc = app.activeDocument;
          var hs = doc.historyStates;
          var flg=0;
          for(var a =hs.length-1;a>=0;--a){
              if(hs[a].snapshot) {
                  if(hs[a].name=="Initial Color"){
                      doc.activeHistoryState = hs[a];
          // Put your code here.....
          function delHist() {
              var desc20 = new ActionDescriptor();
              var ref23 = new ActionReference();
              ref23.putProperty( charIDToTypeID('HstS'), charIDToTypeID('CrnH') );
              desc20.putReference( charIDToTypeID('null'), ref23 );
              executeAction( charIDToTypeID('Dlt '), desc20, DialogModes.NO );




          1 person found this helpful
          • 2. Re: Snapshot help
            tokuredit Level 1

            Great, it worked very well! I just removed line 8 and the last 7 to work as I need it! Helped me a lot. Thank you very much natrev