Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to detect if a group has been scaled?

New Here ,
Nov 13, 2013 Nov 13, 2013

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!

TOPICS
Actions and scripting
809
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe
New Here ,
Nov 21, 2013 Nov 21, 2013

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 21, 2013 Nov 21, 2013

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 21, 2013 Nov 21, 2013

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. 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guru ,
Nov 21, 2013 Nov 21, 2013

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Nov 21, 2013 Nov 21, 2013
LATEST

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!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines