Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now