Copy link to clipboard
Copied
I am able to get the height of the full selection, but I am trying to get the height of the tallest shape in the selection.
Where does my code snippet need to change?
var maxHeight = 0;
// Capture Letter Height
for (var i = 0; i < doc.selection[i].height; i++) {
if (doc.selection[i].height > maxHeight) { var maxHeight = doc.selection[i].height; };
}
var ltrHeight = maxHeight / 72;
Thank you!
Assuming, you have expanded the text. Try the following version.
var maxHeight = 0;
var doc = app.activeDocument;
// Capture Letter Height
for (var i = 0; i < app.selection.length; i++) {
var _item = app.selection[i];
if (_item.height > maxHeight) {
var maxHeight = _item.height;
};
}
var ltrHeight = maxHeight / 72;
Copy link to clipboard
Copied
Could you please post the screen shot from which you want to calculate the height?
Copy link to clipboard
Copied
While I would prefer the "T" at .25" I understand that the lower case "l" is slightly taller
Copy link to clipboard
Copied
and I randomly get this error...
Copy link to clipboard
Copied
Assuming, you have expanded the text. Try the following version.
var maxHeight = 0;
var doc = app.activeDocument;
// Capture Letter Height
for (var i = 0; i < app.selection.length; i++) {
var _item = app.selection[i];
if (_item.height > maxHeight) {
var maxHeight = _item.height;
};
}
var ltrHeight = maxHeight / 72;
Copy link to clipboard
Copied
You probably need to add a Math.max() to your i so it only returns the tallest shape in the loop, not the cumulative values.
Mylenium