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

Capture Tallest Shape

Engaged ,
Dec 05, 2022 Dec 05, 2022

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!

TOPICS
Scripting

Views

615

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Expert , Dec 05, 2022 Dec 05, 2022

Hi @BryanPagenkopf 

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;

 

Votes

Translate

Translate
Adobe
Community Expert ,
Dec 05, 2022 Dec 05, 2022

Copy link to clipboard

Copied

Hi @BryanPagenkopf 

Could you please post the screen shot from which you want to calculate the height?

Best regards

Votes

Translate

Translate

Report

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
Engaged ,
Dec 05, 2022 Dec 05, 2022

Copy link to clipboard

Copied

While I would prefer the "T" at .25" I understand that the lower case "l" is slightly taller

BryanPagenkopf_0-1670254468012.png

 

Votes

Translate

Translate

Report

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
Engaged ,
Dec 05, 2022 Dec 05, 2022

Copy link to clipboard

Copied

and I randomly get this error...  

BryanPagenkopf_0-1670256633759.png

 

Votes

Translate

Translate

Report

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 ,
Dec 05, 2022 Dec 05, 2022

Copy link to clipboard

Copied

LATEST

Hi @BryanPagenkopf 

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;

 

Best regards

Votes

Translate

Translate

Report

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
LEGEND ,
Dec 05, 2022 Dec 05, 2022

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

Votes

Translate

Translate

Report

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