8 Replies Latest reply on Feb 14, 2017 12:55 AM by Laubender

    Change Blend Mode?

    hopkinsprinting Level 1

      Hello,

       

      Without any objects selected, is there a way to change the blend mode to say, Hard Light, via Javascript?

       

      Thank you,
      jm

        • 1. Re: Change Blend Mode?
          tpk1982 Level 4

          like this..

           

          items= app.activeDocument.pageItems.everyItem().getElements();
          for (i = 0; i < items.length; i++) {
              items[i].transparencySettings.blendingSettings.blendMode = BlendMode.HARD_LIGHT;
               
          }
          
          • 2. Re: Change Blend Mode?
            hopkinsprinting Level 1

            Hi tpk1982,

             

            I apologize for the confusion. In InDesign, let's suppose I open a pre-existing document that contains a combination of text and graphics. Before doing anything (and with nothing selected), I go to the Effects panel and change the blend mode to Hard Light (in a sense, I've just changed the blend mode at the document level). Now, I draw a rectangle. The Effects panel shows that the blend mode of the rectangle is already set to Hard Light.

             

            What I am looking for is a script that will change the blend mode at the document level while no content is selected leaving any content already on the page untouched.

             

            Does this make sense?

             

            Thank you so much,

            JM

            • 3. Re: Change Blend Mode?
              tpk1982 Level 4

              ohh.. but it can be done without script also.. just close all document and change the mode.. open any document and draw a rectangle, you can see it set as default

              • 4. Re: Change Blend Mode?
                hopkinsprinting Level 1

                I know but I want to do this with a script (this particular need is part of a larger script).

                 

                Thank you so much,

                JM

                • 5. Re: Change Blend Mode?
                  tpk1982 Level 4

                  Yes possible.. by using event listener in JS

                  • 6. Re: Change Blend Mode?
                    hopkinsprinting Level 1

                    I am not familiar with this. Can you provide the code that will do what I am looking for?

                     

                    Thank you so much,

                    JM

                    • 7. Re: Change Blend Mode?
                      hopkinsprinting Level 1

                      I figured this out.  Here's the code:

                       

                      var myMenuAction = app.menuActions.item("Clear All Transparency");

                      myMenuAction.invoke();

                       

                      This changes the blending mode at the DOCUMENT level to Normal without changing any pre-existing page content.

                       

                      Cheers,

                      JM

                      • 8. Re: Change Blend Mode?
                        Laubender Adobe Community Professional & MVP

                        Hi,

                        to make that menu action work for all cases you have to check:

                         

                        1. Is the menu action available, check property enabled

                        It's not enabled if no transparency or effects are set in the Effects panel.

                         

                        2. Is the name of the menu action locale independent?

                        Your keystring will not work with my German InDesign.

                        Check with: app.findKeyStrings("keystring name") for locale independent keystrings.

                         

                        Something like that should work on every version of InDesign.
                        Because I'm not absolutely sure, I implemented a check with isValid as well:

                         

                        var clearAllTransparency = app.menuActions.itemByName("$ID/kClearAllTransparency");
                        if(clearAllTransparency.isValid && clearAllTransparency.enabled){clearAllTransparency.invoke()};
                        

                         

                        Regards,
                        Uwe