5 Replies Latest reply on Nov 22, 2013 12:45 AM by Luis Morcillo

    How to detect if a group has been scaled?

    Luis Morcillo Level 1

      I know I've seen this somewhere (in the manual or on some PS Scripting site) a couple of months ago, but I wasn't smart enough to copy the info somewhere >_< 

       

      I wonder if anyone here knows how to detect if a group was scaled, and also how to get the scale factor (horizontal and vertical, I guess).

       

      Thanks beforehand!

        • 1. Re: How to detect if a group has been scaled?
          Luis Morcillo Level 1

          I can ellaborate on this:

           

          -I made a text layer, paragraph type.

          -I duplicated it and scaled it down, half the size. Both font size and box are smaller in the same proportion.

          -Now I want to get the text boxes width and height in pixels. That is: layer.textItem.width.value.

          -The original text width is right (let's say 1000x500), but the duplicate smaller one is exactly the same, 1000x500, when it should be 500x250.

           

          Not sure if that's a bug in scripting variables, or if there's a hidden variable that could give me the actual box dimensions or at least the scale.

          • 2. Re: How to detect if a group has been scaled?
            pixxxel schubser MVP & Adobe Community Professional

            I think you have PS CS6+

            Is this so?

             

            There is a known bug in this version. Here are two possible solutions (written by Paul Riggott).

            Please read the following links:

            http://forums.adobe.com/message/5105288#5105288

            http://forums.adobe.com/message/4899278?tstart=0

             

            Try it and give a response please if it works for you.

            • 3. Re: How to detect if a group has been scaled?
              Chuck Uebele Adobe Community Professional & MVP

              that is odd, I'm getting the same thing.  You can use layer.bounds[2]-layer.bounds[0] to get the actual width of the type. 

              • 4. Re: How to detect if a group has been scaled?
                Michael L Hale Level 5

                It helps that you added you want to get the transform of a text layer. I thought you were referring to a layerSet when you used the word group in your original post.

                 

                var ref = new ActionReference();
                ref.putEnumerated( charIDToTypeID("Lyr "), charIDToTypeID("Ordn"), charIDToTypeID("Trgt") ); 
                var desc = executeActionGet(ref);
                if(desc.hasKey(charIDToTypeID("Txt "))){
                    if(desc.getObjectValue(charIDToTypeID("Txt ")).hasKey(charIDToTypeID("Trnf"))){
                        var transformDesc = desc.getObjectValue(charIDToTypeID("Txt ")).getObjectValue(charIDToTypeID("Trnf"));
                        var transform = [];
                        transform.push(transformDesc.getDouble(stringIDToTypeID('xx')));
                        transform.push(transformDesc.getDouble(stringIDToTypeID('yy')));
                    }
                }
                alert(transform);
                

                 

                Note I tested this in CC as that seems to be where it is needed the most.

                • 5. Re: How to detect if a group has been scaled?
                  Luis Morcillo Level 1

                  Wow, thank you all for the replies

                   

                  @pixxxel schubser: I'm actually using CS5, but yeah, it happens in CS6 as well. Thank you very much for the links. I'm going to give a try to Michael L Hale's code before going into them.

                   

                  @csuebele: that's good for point text, but for paragraph text, it doesn't give the box dimensions, just the layer's bounds.

                   

                  @Michael L Hale: thank you, I'm gonna try that. And yes, my initial explanation was totally bad (I was actually looking for info about groups, but the problem was in texts and I found out later).

                   

                  Back in a little while. Thank you all!

                   

                   

                  EDIT: yessss, it works, Michael! Thank you very much!