11 Replies Latest reply on Jul 2, 2010 5:44 AM by resdesign

    Reset Graphic Tint Document-wide

    lewis_cooper Level 1

      Hi all, I've got another challenge for the scripting Jedi in here!

       

      The problem I have here is a document in which certain graphics have needed to be faded in order to give more focus to other elements.

      All of my graphics were grayscale, so I opted to select each graphic individually within its frame and adjust the [Black] swatch to 20%.

       

      I now need to revert to the point where all the graphics were 100% [Black]. There have been many other changes so using a previously saved version is not an option. And the object style for each frame is set to [None] (helpfully).

       

      On the bright side, there is no need to isolate the changes. I need every single graphic to be 100% [Black] again.

       

      Please help!

        • 1. Re: Reset Graphic Tint Document-wide
          [Jongware] Most Valuable Participant

          Scripting Jedi ... To quote Samuel L. Jackson: "Feel the Force, ****er!"

           for (var g=0; g<app.activeDocument.allGraphics.length; g++)
             try { app.activeDocument.allGraphics[g].fillTint = 70; } catch(_){};
          

           

          The try..catch is necessary because 'allGraphics' may include stuff that can't get a tint (EPSes and such).

          • 2. Re: Reset Graphic Tint Document-wide
            lewis_cooper Level 1

            That's great, thank you so much.

             

            Is there away to do this with Opacity as well? I've just realised that I cheated a few times by fading a few Text Frames and Lines to 20% Opacity.

             

            Thanks again!

            • 3. Re: Reset Graphic Tint Document-wide
              [Jongware] Most Valuable Participant

              Well, you can always try to set all page items to normal opacity:

               

              for (var g=0; g<app.activeDocument.pageItems.length; g++)
                 try { app.activeDocument.pageItems[g].transparencySettings.blendingSettings.opacity = 100; } catch(_){};

               

              -- this will change all page items, so don't use if you want to keep some.

               

              By the way, my previous script sets the filTint to 70%, rather than 100% (so I could see the document change). Just in case you missed that

              • 4. Re: Reset Graphic Tint Document-wide
                lewis_cooper Level 1

                Thanks again Jongware, that did the trick! Saved me an hour or so and a bout of RSI!

                 

                And yep, I noticed the 70% tint too.

                 

                Cheers

                • 5. Re: Reset Graphic Tint Document-wide
                  resdesign Adobe Community Professional & MVP

                  Is there a way for the script to work on anchored objects?

                  • 6. Re: Reset Graphic Tint Document-wide
                    resdesign Adobe Community Professional & MVP

                    I changed pageItems to allPageItems which changes the transparency of all items in the active documents. What if I just wanted eps files' transparency to be changed in the active document? I wish the OMV would have some syntax examples for each items like Flash was when it used to be macromedia.

                    • 7. Re: Reset Graphic Tint Document-wide
                      [Jongware] Most Valuable Participant

                      Yes, the allGraphics(etc.) stuff ought to work. Sorry -- busy with other stuff so I can't double-check.

                       

                      If you insert this line between the for.. and the try.. lines, it ought to only process EPSes

                       

                      if (app.activeDocument.pageItems[g].graphics.length && app.activeDocument.pageItems[g].graphics[0].imageTypeName == "EPS")

                       

                      -- this will first check if the page item "contains" a graphic (i.e., the thing you select with the white arrow), then if its type is "EPS".

                       

                      Yeah. I'm sure it'd need something like this.

                      • 8. Re: Reset Graphic Tint Document-wide
                        resdesign Adobe Community Professional & MVP

                        Did not work.

                        I have another problem. I want to be able to decide what transparency value I want. So I created a dialog box. But the for... try does not pick up the myPercent value. Why?

                         

                        var myDialog = app.dialogs.add({name:"Choose Transparency"});
                        // add a dialog colum,
                            with(myDialog.dialogColumns.add()){
                                // create a title for the box
                                    staticTexts.add({staticLabel:"Choose transparency percentage"});
                            }
                            with(myDialog.dialogColumns.add()){
                                // create a number field to enter the transparency percentage
                                var myPercentageValueField =textEditboxes.add({editContents:"100", minWidth:100});
                                }
                        // show the dialog box
                        var myResult = myDialog.show();
                        // If the user click OK, display one message

                         

                        if (myResult == true){
                                // get the value from the dialog box
                                var myPercentage = myPercentageValueField.editContents;
                                // change the transparency in all the page items
                                myChangethePercentage();
                                }
                            else {
                                // if the user clicked cancel, display a different message
                                alert ("Rerun the script, you need to choose a value");
                                        }
                            // Remove the dialog box from memory
                            myDialog.destroy();
                           
                        function myChangethePercentage(){
                            // check all the page items
                            for (var g=0; g<app.activeDocument.allPageItems.length; g++)
                            try { app.activeDocument.allPageItems[g].transparencySettings.blendingSettings.opacity = myPercentage; }
                            catch(_){
                              }
                        }  

                        • 9. Re: Reset Graphic Tint Document-wide
                          resdesign Adobe Community Professional & MVP

                          Well - so far I changed allPageItems to allGraphics and at least it limits the transparency to the graphcis only.

                          Now, in the code posted above, if I insert a value instead of myPercentage, it works. When I have myPercentage, it does not work. It seems like it should pickup the value inserted in the dialog box. Should I rewrite the code with an integer instead of a string?

                          • 10. Re: Reset Graphic Tint Document-wide
                            resdesign Adobe Community Professional & MVP

                            OK. I change the script from textEditboxes to measurementEditboxes and it works. I tried integerEditboxes but could not make it work.

                            • 11. Re: Reset Graphic Tint Document-wide
                              resdesign Adobe Community Professional & MVP

                              Well, after all integerEditBoxes works. I am not sure what happened before. Thank you for your help.