4 Replies Latest reply on Nov 23, 2011 6:28 AM by MikeBrog

    InDesign graphic opacity


      ID 5.5, Mac Lion, JavaScript


      I used to be able to do:


      var myGraphic = CurrentDoc.allGraphics[0];

      myGraphic.opacity = 30


      Generating following error:

      Error Number: 55

      Error String: Object does not support the property or method 'Opacity'

      Source: myGraphic.opacity = 30


      Is there a fairly simple solution to this?



        • 1. Re: InDesign graphic opacity
          [Jongware] Most Valuable Participant

          MikeBrog wrote:

          [...] Is there a fairly simple solution to this?


          Uh, no


          The new FX in CS4 and higher caused all of this 'simple' settings to disappear, and evolve into separate settings for 'object', fill, and stroke, and in the case of images, also for its contents. All of these can be addressed by (breath in) Bevel and Emboss, blending, directional feathering, drop shadow, featering, gradient feathering, inner glow, inner shadow, outer glow, and satin. It doesn't make it easier they added not just one level, but two.


          Digging through the reference , walking the object tree up and down (and left to right at times) and trying the odd random thing (what, exactly, does changing the contentTransparency do? I see no change but you can "undo" it in the interface), this finally worked.


          myGraphic.transparencySettings.blendingSettings.opacity = 30;


          Admittedly, a far cry from your simple image.opacity line.

          • 2. Re: InDesign graphic opacity
            MikeBrog Level 1

            That worked well.  Thank you!

            • 3. Re: InDesign graphic opacity
              John Hawkinson Level 5

              Uh, no

              Well, you can probably set app.scriptVersion to 4.0 (CS2) to get around this. And then make sure to set it back when you're done, especially if you're in a persistent environment. Something like:


              var myGraphic = CurrentDoc.allGraphics[0],
                    scriptVersion = app.scriptPreferences.version;
              try {
                app.scriptPreferences.version = 4;
                myGraphic.opacity = 30;
              } finally {
                app.scriptPreferences.version = scriptVersion;

              I guess it's not probably not worth the trouble?

              1 person found this helpful
              • 4. Re: InDesign graphic opacity
                MikeBrog Level 1

                John Hawkinson wrote:



                I guess it's not probably not worth the trouble?


                It wasn't worth the trouble for me, but could be for someone who is working with a more complicated script than I am.  This was the only line that failed in the script after we moved from CS2 to CS5.5.  Thanks!