9 Replies Latest reply on Oct 14, 2011 7:58 AM by lukychan

    How to set document "dirty" flag

    lukychan

      Hi I wonder if there is a  simple way to set document "dirty" flag.

      The thing is that I am modifing layer XMP info in action script but this change is not reflected by setting the document to modified state

       

      Lukas

        • 1. Re: How to set document "dirty" flag
          Paul Riggott Level 6

          You could do something like this...

           

           

          activeDocument.info.caption = activeDocument.info.caption + " ";
          
          • 2. Re: How to set document "dirty" flag
            lukychan Level 1

            trouble is,that anytime i use DOM on big documents (>100 layers) it become terribly slow and unusable. Would you know how to do it using action manager?

            • 3. Re: How to set document "dirty" flag
              Paul Riggott Level 6

              Changing the caption should be zero overhead, the problem will be the time accessing layer(s) to add/modify the layer xmp.

              • 4. Re: How to set document "dirty" flag
                lukychan Level 1

                but in this case - modifying caption - you don't access layers and it is slow anyway

                FlashBuilder  profiler shows that set caption takes 97% of time - almost 3000ms in this particular case

                • 5. Re: How to set document "dirty" flag
                  Paul Riggott Level 6

                  I wonder how fast it would be to set the currect layer colour?

                  IE:-

                   

                   

                  layerColour('red')
                  function layerColour(colour) {
                      switch (colour.toLocaleLowerCase()){
                          case 'red': colour = 'Rd  '; break;
                          case 'orange' : colour = 'Orng'; break;
                          case 'yellow' : colour = 'Ylw '; break;
                          case 'yellow' : colour = 'Ylw '; break;
                          case 'green' : colour = 'Grn '; break;
                          case 'blue' : colour = 'Bl  '; break;
                          case 'violet' : colour = 'Vlt '; break;
                          case 'gray' : colour = 'Gry '; break;
                          case 'none' : colour = 'None'; break;
                          default : colour = 'None'; break;
                          }
                      var desc = new ActionDescriptor();
                          var ref = new ActionReference();
                          ref.putEnumerated( charIDToTypeID('Lyr '), charIDToTypeID('Ordn'), charIDToTypeID('Trgt') );
                      desc.putReference( charIDToTypeID('null'), ref );
                          var desc2 = new ActionDescriptor();
                          desc2.putEnumerated( charIDToTypeID('Clr '), charIDToTypeID('Clr '), charIDToTypeID(colour) );
                      desc.putObject( charIDToTypeID('T   '), charIDToTypeID('Lyr '), desc2 );
                      executeAction( charIDToTypeID('setd'), desc, DialogModes.NO );
                  };
                  
                  
                  • 6. Re: How to set document "dirty" flag
                    lukychan Level 1

                    It should be way faster but it is not what I want to do I can't be changing layer color on each change of xmp

                    I found another way how to change caption. It's fast enough just I don't want to modify document such way that I break somebody's else info. It's strange there is no other way how to set this flag

                     

                    var idsetd = charIDToTypeID( "setd" );

                        var desc2 = new ActionDescriptor();

                        var idnull = charIDToTypeID( "null" );

                            var ref1 = new ActionReference();

                            var idPrpr = charIDToTypeID( "Prpr" );

                            var idFlIn = charIDToTypeID( "FlIn" );

                            ref1.putProperty( idPrpr, idFlIn );

                            var idDcmn = charIDToTypeID( "Dcmn" );

                            var idOrdn = charIDToTypeID( "Ordn" );

                            var idTrgt = charIDToTypeID( "Trgt" );

                            ref1.putEnumerated( idDcmn, idOrdn, idTrgt );

                        desc2.putReference( idnull, ref1 );

                        var idT = charIDToTypeID( "T   " );

                            var desc3 = new ActionDescriptor();

                            var idCptn = charIDToTypeID( "Cptn" );

                            desc3.putString( idCptn, "     " );

                        var idFlIn = charIDToTypeID( "FlIn" );

                        desc2.putObject( idT, idFlIn, desc3 );

                    executeAction( idsetd, desc2, DialogModes.NO );

                    • 7. Re: How to set document "dirty" flag
                      Paul Riggott Level 6

                      According to the docs "saved" is read only, so it looks as if some change is required.

                      Layer colour can be set to none as that also makes the document dirty.

                       

                      Hope you find a way that suits your needs.

                      • 8. Re: How to set document "dirty" flag
                        Paul Riggott Level 6

                        Another way to set the document dirty would be to create a guide then remove it.

                        • 9. Re: How to set document "dirty" flag
                          lukychan Level 1

                          I've actually  found one more way which surprisingly works and seem to be the fastest.

                          activeDocument.activeLayer.visible=activeDocument.activeLayer.visible

                           

                          or even quicker

                           

                          var b:Boolean=activeDocument.activeLayer.visible;

                          var des:ActionDescriptor = new ActionDescriptor();

                          var ref:ActionReference = new ActionReference();

                          var lst:ActionList = new ActionList();

                          ref.putEnumerated(lyr, ordn, trgt);

                          lst.putReference(ref);                  

                          des.putList(nul,lst);

                          Photoshop.app.executeAction( b?show:hide, des, DialogModes.NO );