Copy link to clipboard
Copied
I'm new to AppleScript and am wondering if there is a way to return the size of all text frames and all image frames in my active document. Essentially, I am trying to calculate the square inches of all text frames and all image frames so that I can compare the two and find the ratio of text to images in the whole book.
I've been able to use geometric bounds to return the bounds of individual text frames, but I can't figure out how to return the bounds of all text frames in the document and all image frames in the document to compare them.
Sorry that this is a very basic question, most of what I've been able to find so far is about changing frame sizes, not finding the area of frames.
Hi jalbert_ecwpress ,
I am not that good at applescript, but this might be solution for you.
...set list_Of_Text_Frame_Area to {}
tell application id "com.adobe.indesign"
tell active document
set every_t to every text frame
set total_W_x_H to 0
repeat with this_TextFrame in every_t
set geo_bounds to 0
set this_W to 0
set this_H to 0
set this_W_x_H to 0
set geo_bounds to geometric bounds of this_TextFrame
set this_H to ((item 3 of geo_bounds) - (item 1 of geo_bounds))
set this_W to ((item 4
Copy link to clipboard
Copied
Hi Jalbert,
Logic of getting area of allImages & textframe is very simple.
You are getting all text frame at that time push that frame/images area by calculating it in a global array.
Your array could be multi dimentional as per your need.
And at the end just return it.
Best
Sunil
Copy link to clipboard
Copied
-- Here's one way to get the total area of all text frames. It could be used as the basis for getting the area of all rectangles.
tell application id "com.adobe.indesign"
tell active document
set every_t to every text frame
set total_W_x_H to 0
repeat with this_TextFrame in every_t
set geo_bounds to 0
set this_W to 0
set this_H to 0
set this_W_x_H to 0
set geo_bounds to geometric bounds of this_TextFrame
-- H
set this_H to ((item 3 of geo_bounds) - (item 1 of geo_bounds))
set this_W to ((item 4 of geo_bounds) - (item 2 of geo_bounds))
set this_W_x_H to (this_H * this_W)
set total_W_x_H to (total_W_x_H + this_W_x_H)
end repeat
return total_W_x_H
end tell
end tell
Copy link to clipboard
Copied
Yes, correct.
Now you are one step behind taking your area of all textframes to a local variable more like an array and return it to main function, you will get array of all textframes area.
Then you can utilize it as per your need going through a loop for each value of array taking one by one the area of your text farmes.
Best
Sunil
Copy link to clipboard
Copied
Hi jalbert_ecwpress ,
I am not that good at applescript, but this might be solution for you.
set list_Of_Text_Frame_Area to {}
tell application id "com.adobe.indesign"
tell active document
set every_t to every text frame
set total_W_x_H to 0
repeat with this_TextFrame in every_t
set geo_bounds to 0
set this_W to 0
set this_H to 0
set this_W_x_H to 0
set geo_bounds to geometric bounds of this_TextFrame
set this_H to ((item 3 of geo_bounds) - (item 1 of geo_bounds))
set this_W to ((item 4 of geo_bounds) - (item 2 of geo_bounds))
set this_W_x_H to (this_H * this_W)
set total_W_x_H to (total_W_x_H + this_W_x_H)
-- copy one by one area into list
copy total_W_x_H to end of list_Of_Text_Frame_Area
----------------
end repeat
end tell
end tell
-- Here you can utilize this list_Of_Text_Frame_Area
Best
Sunil
Copy link to clipboard
Copied
Thank you this worked perfectly.
Copy link to clipboard
Copied
Wow, your Correct Answer code looks a lot like mine.
Copy link to clipboard
Copied
I took your code only just put list into it.
Copy link to clipboard
Copied
Thanks this is what I needed!
Find more inspiration, events, and resources on the new Adobe Community
Explore Now