4 Replies Latest reply on Jul 6, 2017 10:24 AM by Joachim Hiller

    suspendHistory does not work by select a layer

    Joachim Hiller Level 1

      Hi,

       

      I use for my scripts suspendHistory  and this works fine. Only when I selecting  one or more layers it doesn't work

       

      For example

       

      app.activeDocument.suspendHistory("Look sunny", 'mergeLayerInGoup("Look")');
      

       

      mergeLayerInGoup = function (groupName) {
      
      
          //Gruppe erstellen
          makeNewGroup(groupName, "green");
      
      
          //ID des Ordners abfragen
          var groupID = getActiveLayerId();
      
      
          //Werte des Gradationskurve setzen
          var points = [
              { name: 'red', points: [[0, 0], [58, 90], [105, 150], [200, 210] ,[255, 240]]},
              { name: 'green', points: [[0, 0], [58, 85], [140, 160], [190, 195], [255, 225]]},
              { name: 'blue', points: [[0, 0], [58, 75],[140, 145], [198, 175], [228, 195], [255, 205]]}
          ];
      
      
          //Erstellen der Gradationskurve
          makeCurvesAdjustmentLayer(null,"normal", 100, "none", points,false);
      
      
          //Ebene umbenennen
          renameOrginalLayerName();
      
      
          //Belichtungs-Einstellungsebene erstellen
          makeExposureAdjustmentlayer(null,"none", 100, "normal", false, 0.05, 0.025, 0.9);
      
      
          //Ebene umbenennen
          renameOrginalLayerName();
      
      
          //Die Gruppe selektieren
          selectLayerById(groupID, false);
      };
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      
      

       

       

      //Ebene anhand der ID selektieren
      selectLayerById = function(id){
          var ref = new ActionReference();
          //ID übergeben
          ref.putIdentifier(charIDToTypeID('Lyr '), id);
          var desc = new ActionDescriptor();
          desc.putReference(charIDToTypeID("null"), ref );
          //Ebene sichtbar machen
          desc.putBoolean( charIDToTypeID( "MkVs" ), true );
          executeAction(charIDToTypeID("slct"), desc, DialogModes.NO );
      };
      

       

      histoy.jpg

       

      Is there a possibility to change that?

        • 1. Re: suspendHistory does not work by select a layer
          JJMack Most Valuable Participant

          I find it impossible to follow what you have written here.  You show three sections of a script so we can not test or see what the script actually does and you show a couple of history states.  State  it does not work if multiple layers are selected. 

           

          What does not work?  I know there is a bug in supendHistory that a script can trigger the will backup history and cause problems. Can not tell if you code triggers the bug though. The bug I reported is in ever version of Photoshop I have installed.  There is one thread in this forum where someone was having a problem with a script and could not find the problem.  Their script triggered the bug to bite three times.

           

          Currently I have CS2, CS6, CC, CC 2014, CC 2015, CC 2015.5 and CC 2017 installed. The supendHistory bug is in all of them. Adobe does not fix all acknowledged bugs. If what you are seeing is this bug or an other bug in Adobe scripting you may need to code around it. Photoshop: Script bug resize layer back document up one history state | Photoshop Family Customer Community

          • 2. Re: suspendHistory does not work by select a layer
            Joachim Hiller Level 1

            Sorry, it is only about what is displayed in the history.

            The code should show only the steps.

            A group is created and contains two layers.

            At the end, the group should be selected.

            With suspendHistory, everything should be displayed as just one step.

            But selecting the group is a separate step.

            I would like to do everything as a single step and asked if that is possible

            • 3. Re: suspendHistory does not work by select a layer
              JJMack Most Valuable Participant

              If you post the script and describe how to use it. We could create the type of document needed then target several layers and see if we see the same problem as you in the version of Photoshop we use. What version of Photoshop do you use and what OS do you use? I have seen only one step recorded when the first thing a does is suspend history an names the current state.  I also do not recognize the history state "Layer Changes"" as a Photoshop step. What state does you document back up to when you activate that history state?  What event recorded that history state.

              • 4. Re: suspendHistory does not work by select a layer
                Joachim Hiller Level 1

                I found the MY mistake.

                I had a "Layer Changed" event in the Script Events Manager.

                Excuse me and thank you for the help