14 Replies Latest reply on Jul 27, 2013 9:29 AM by Kasyan Servetsky

    Alert for transparency items

    athkini

      Hi Forum,

       

      I got this from forum ,

       

      I need a help to alert, for any type of  "transparency effects" appiled to the pageItems.

       

      Instead of referring, transparencySettings.gradientSettings,

      transparencySettings.opacity,

      fillTransparencySettings,

      objectTransparencySettings.

       

      etc.,

       

       

      items= app.activeDocument.pageItems.everyItem().getElements(); 

      for (i = 0; i < items.length; i++) {

           if(items[i].transparencySettings == true) {

                items[i].itemLayer = app.activeDocument.layers.item("items");

      alert("pageitems has transparency effects")

           } }

       

       

      thanks for your help!

        • 1. Re: Alert for transparency items
          athkini Level 1

          Hi Forum,

           

          On the other side, this is not working for me...

           

          Can you this bit...

           

           

          items= app.activeDocument.pageItems.everyItem().getElements(); 

          for (i = 0; i < items.length; i++) {

               if(items[i].transparencySettings.dropShadowSettings == true) {

                    items[i].itemLayer = app.activeDocument.layers.item("items");

          alert("pageitems has transparency effects")

               } }

           

          if in terms .applied is used, it shows error....

           

          thanks...

          • 2. Re: Alert for transparency items
            athkini Level 1

            Hi Forum,

             

            also i tried with this,,

             

                if (frameArr[i].transparencySettings.dropShadowSettings.blendMode === true) {

             

            but, no result..

             

            Do, i need to add Mode options like Multiply etc., after blendMode..

             

            ???

            • 3. Re: Alert for transparency items
              Jump_Over Level 5

              Hi,

               

              Did you try to define a custom preflightProfile (enable transparency detection)?

              It will alert errors if transparency (any kind) used and even report them...

               

              If defined, your script could try to read:

               

              app.preflightProcesses.item("myTransparencyPreflight").aggregatedResults

               

              which is an array of strings with error descriptions.

               

              Jarek

              • 4. Re: Alert for transparency items
                Laubender Adobe Community Professional & MVP

                You have to look, if a specific transparency setting is applied.

                For basically four different areas:

                 

                ContentTransparencySetting
                FillTransparencySetting
                StrokeTransparencySetting
                TransparencySetting

                 

                The specific ones, that have a "applied" property, are:

                 

                bevelAndEmbossSettings
                blendingSettings
                directionalFeatherSettings
                dropShadowSettings
                featherSettings
                gradientFeatherSettings
                innerGlowSettings
                innerShadowSettings
                outerGlowSettings
                satinSettings

                 

                Nothing more ;-)

                 

                No.  That's not true! It's oversimplistic.
                It depends, if the values of that setting would force "transparency".

                I here imply that you are basically  looking after "transparency" per se…

                The value 100 for opacity combined with BlendMode.NORMAL would not force "transparency"…


                If you are looking for the settings of an object only, you can get a false positive (if you interpreted the results in the wrong way).

                 

                Freshly made, ordinary page items always return "MULTIPLY" for blendMode in the dropShadowSettings of the transparencySettings! That is, if you or the user did not fiddle with app or document(?) preferences or default object styles before… And there is no  "transparency" applied, if you ask a user.

                 

                So, basically I think you are looking for something like "Effective Transparency".

                There is no easy answer here.

                 

                Maybe it would be fruitful to script the preflight functionality and exploit the results…

                 

                Uwe

                • 5. Re: Alert for transparency items
                  athkini Level 1

                  Hi Jarek!

                   

                  Acually im trying to get all the pageItems with effects==>transparency===> applied to a seperate Layer.

                   

                  Sorry for my wrong request...

                   

                  I need to get whatever the transparency effects applied to the pageItems to be seggregated to one Layer.

                   

                  Now I got this,

                   

                   

                  items= app.activeDocument.pageItems.everyItem().getElements(); 

                  for (i = 0; i < items.length; i++) {

                       if(items[i].transparencySettings.dropShadowSettings.mode == ShadowMode.DROP) {

                            items[i].itemLayer = app.activeDocument.layers.item("items");

                  alert("pageitems has transparency effects")

                       } }

                   

                  items= app.activeDocument.pageItems.everyItem().getElements(); 

                  for (i = 0; i < items.length; i++) {

                       if(items[i].transparencySettings.innerShadowSettings.applied == true) {

                            items[i].itemLayer = app.activeDocument.layers.item("items");

                  alert("pageitems has transparency effects")

                       } }

                   

                   

                  but i need to itereate for other options too. Is it possible to state in a simple conditions and not as above......

                  • 6. Re: Alert for transparency items
                    Laubender Adobe Community Professional & MVP

                    Ah! Jarek gave a hint…
                    Thanks!

                     

                    Uwe

                    • 7. Re: Alert for transparency items
                      Jump_Over Level 5

                      Hi,

                       

                      I think preflight way is simplest (with some assumings)

                      Assummed:

                      1. there is a preflight "Transparency" defined with 1 option (transparency not allowed) enabled;

                      2. this preflight is activated

                      3. each pageItem is named originally (script adds numbers at the end of name)

                       

                      If you accept above run this:

                      var mDoc = app.activeDocument,
                      mLayer = mDoc.layers.item("Transparency"),
                      mPref = app.preflightProfiles.item("Transparency"),
                      items = [], mERR, curErr, a, b, k, 
                      mDocItems = mDoc.allPageItems;
                      
                      for (b = mDocItems.length - 1; b >=0; b --) {
                                mDocItems[b].name = mDocItems[b].name.replace(/_no_\d+/, "");
                                mDocItems[b].name += "_no_" + b;
                                }
                      
                      if (!mLayer.isValid) 
                                mLayer = mDoc.layers.add({name: "Transparency"});
                      
                      if (!mPref.isValid) {
                      //~           mPref = app.preflightProfiles.item(0).duplicate();
                      //~           mPref.name = "Transparency";
                      //~           mPref.preflightProfileRules.everyItem().flag = PreflightRuleFlag.RULE_IS_DISABLED;
                      //~           mPref.preflightProfileRules[34].flag = PreflightRuleFlag.RETURN_AS_ERROR;
                                alert ("no preflight found!"); // assumed is defined by user
                                exit();
                                }
                      
                      mERR = app.preflightProcesses[0].aggregatedResults[2];
                      
                      if (mERR.length > 0) {
                                for (k = 0; k < mERR.length; k++) {
                                          curErr = mERR[k];
                                          if (curErr[0]==3) items.push(curErr[1])
                                          }
                                }
                      
                      for (a = 0; a < items.length; a ++)
                                for (b = mDocItems.length - 1; b >=0; b --)
                                if (items[a] == mDocItems[b].name)
                                          mDocItems[b].itemLayer = mLayer;
                      

                       

                      Just as example. Fails if some objects anchored or grouped but it could be modified, I guees.

                       

                      Jarek

                      • 8. Re: Alert for transparency items
                        athkini Level 1

                        The BOSS!!! Jarek!!!..

                         

                        Just a small explanations needed...

                         

                        what is :    mERR = app.preflightProcesses[0].aggregatedResults[2];

                         

                        &&

                         

                        if (mERR.length > 0) {
                                  for (k = 0; k < mERR.length; k++) {
                                            curErr = mERR[k];
                                            if (curErr[0]==3) items.push(curErr[1])  // why do we use 3 and push it to 1.. what is 3 referred here..Jarek!!!!

                                            }
                                  }

                         

                        Many thanks, where i dont know that we can use preflight profiles to move the transparency.....

                        A new thing i have learnt from you Jarek!!!! Excellent...

                        • 9. Re: Alert for transparency items
                          Jump_Over Level 5

                          Hi,

                           

                          app.preflightProcesses[0].aggregatedResults[2];

                           

                          aggregatedResults - this is an array of arrays of strings (you can see its content in preflight panel)

                          This array has 2- (no errors) or 3 elements. So 3rd element is an array with list of errors detected (aggregatedResults[2]).

                           

                          Basically 1 error generates 3 kinds of info:

                          1. error group name

                          2. error description

                          3. name of object which causes this error

                           

                          these numbers are in 1st element of mERR[i] array, thats why code check this value. If == 3   -->   2nd element is the name of object. Script push it to array (items).

                          Later on those names are compared to pageItems.names and specific item is moved to "transparency" layer.

                           

                          Script doesn't check if detected pageItem is anchored or grouped with others, so in this case changing layer will involve an error.

                           

                          This is just to show the way...:)

                           

                          enjoy

                           

                          Jarek

                          • 10. Re: Alert for transparency items
                            athkini Level 1

                             

                             

                            Super Jarek!!!

                             

                            Have taken much effort in explaining to us (forum) and I have gained a new knowledge on this......

                             

                            Excellent.... 100/100 for you....

                             

                            Only one Question.. It would be great to hear, that if we can make true or false the "uses transparency" settings under preflight panel. "Transparency"  == Under Images and Links..

                            • 11. Re: Alert for transparency items
                              athkini Level 1

                              I Jarek!!!

                               

                              I mean any possibility to check and unchek the Uses transparency options through script....

                               

                              I have a little bit to create profile... but checking the options needs is not found in ESTK objects models..

                               

                              var myDocument=app.activeDocument;

                               

                              var profile = app.preflightProfiles.add();

                               

                              profile.name = "Test";

                               

                              profile.description = "Test description";

                               

                              const RULE_NAME = "ADBE_PageSizeOrientation";

                               

                              var rule = profile.preflightProfileRules.add(RULE_NAME);

                              Screen Shot 2013-07-25 at 10.48.04.png

                               

                              Many thanks

                              • 12. Re: Alert for transparency items
                                Jump_Over Level 5

                                Hi,

                                 

                                to create a preflight use:

                                (a list of rules indexes could be useful)

                                mPref = app.preflightProfiles.item(0).duplicate();
                                mPref.name = "Transparency";
                                mPref.preflightProfileRules.everyItem().flag = PreflightRuleFlag.RULE_IS_DISABLED;
                                mPref.preflightProfileRules[34].flag = PreflightRuleFlag.RETURN_AS_ERROR;
                                

                                 

                                to activate mPref use:

                                app.activeDocument.preflightOptions.preflightWorkingProfile = mPref;
                                

                                 

                                Jarek

                                PS:

                                1. some "helpful" or "correct" flag would be appreciated

                                2. activating preflight by script leads to an error I can not manage:

                                ID is continuing checking preflight while script is executed, so no err_report is available.

                                Unfortunatelly preflightProcess[0].waitForProcess() doesnt work...

                                ...on my side only?

                                • 13. Re: Alert for transparency items
                                  athkini Level 1

                                  JAREK!!!   VERY MUCH THANKS & APPRECIATE!!!!  A TON ...

                                  • 14. Re: Alert for transparency items
                                    Kasyan Servetsky Level 5

                                    Long ago I wrote a couple of functions for a script: one checks if a page item is transparent and another if an effect is applied. In fact, I used the approach suggested by Uwe.

                                     

                                    function IsTransparent(pageItem) {
                                        var result = false;
                                        var object = pageItem.transparencySettings.blendingSettings;
                                        var fill = pageItem.fillTransparencySettings.blendingSettings;
                                        var stroke = pageItem.strokeTransparencySettings.blendingSettings;
                                        var content = pageItem.contentTransparencySettings.blendingSettings;
                                        
                                        if (object.blendMode != BlendMode.NORMAL || object.opacity != 100) result = true;
                                        if (fill.blendMode != BlendMode.NORMAL || fill.opacity != 100) result = true;
                                        if (stroke.blendMode != BlendMode.NORMAL || stroke.opacity != 100) result = true;
                                        if (content.blendMode != BlendMode.NORMAL || content.opacity != 100) result = true;
                                        
                                        return result;
                                    }
                                    
                                    function IsEffectApplied(pageItem) {
                                        var currentSettings;    
                                        var result = false;
                                        var allTransparencySettings = [];
                                        allTransparencySettings.push(pageItem.transparencySettings);
                                        allTransparencySettings.push(pageItem.fillTransparencySettings);
                                        allTransparencySettings.push(pageItem.strokeTransparencySettings);
                                        allTransparencySettings.push(pageItem.contentTransparencySettings);
                                        
                                        for (var i = 0; i < allTransparencySettings.length; i++) {
                                            currentSettings = allTransparencySettings[i];
                                            with (currentSettings) {
                                                if (innerShadowSettings.applied) result = true;
                                                if (outerGlowSettings.applied) result = true;
                                                if (innerGlowSettings.applied) result = true;
                                                if (bevelAndEmbossSettings.applied) result = true;
                                                if (satinSettings.applied) result = true;
                                                if (gradientFeatherSettings.applied) result = true;
                                                if (directionalFeatherSettings.applied) result = true;
                                                if (dropShadowSettings.mode == ShadowMode.DROP) result = true;
                                                if (featherSettings.mode == FeatherMode.STANDARD) result = true;
                                            }
                                        }    
                                        return result;
                                    }