• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Indesign CS5 - getting width and height of selection?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Indesign CS5 - getting width and height of selection?


  • Subject: Re: Indesign CS5 - getting width and height of selection?
  • From: Michael Tompsett <email@hidden>
  • Date: Wed, 08 Feb 2012 13:40:45 +0100

This works for finding out the width height WITHOUT grouping.

It basically looks at each item in the selection in turn to finds the most extreme co-orndinates for the top left and bottom right. From these co-ordinates it can then calculate the overall size.

The script is a little messy and I am sure there is are better ways to format/write it - for example the first item is checked twice, once outside the loop and then again the loop, i'm sure this can be avoided but in fact it doesn't do any harm.

Michael

tell application "Adobe InDesign CS5"


set mySelection to selection
set myDoc to active document
tell myDoc
set thecount to count of mySelection

set firstitem to item 1 of mySelection
set {ytopleft, xtopleft, ybttmright, xbttmright} to geometric bounds of firstitem


repeat with myitem in mySelection
set {y1, x1, y2, x2} to geometric bounds of myitem
if y1 < ytopleft then set ytopleft to y1
if x1 < xtopleft then set xtopleft to x1
if y2 > ybttmright then set ybttmright to y2
if x2 > xbttmright then set xbttmright to x2
end repeat


set theheight to ybttmright - ytopleft
set thewidth to xbttmright - xtopleft


return {theheight, thewidth}

end tell
end tell



On 8 Feb 2012, at 13:10, email@hidden wrote:

Jan, 

Thank you for the code, it does work, but I was hoping to just get the values without changing the items. 
There will be surprises with grouping across layers, items may belong to other groups etc. 

Skipping the MOVE part and only group and calculate (y2-y1, x2-x1) would reduce risk a bit, but it is still a roundabout way of getting the values:

Since the values I am after are displayed in the Control Panel I was hoping to just pick them up from somewhere.
If someone knows how to access that info I would appreciate it.

Håvard




Den 7. feb. 2012 kl. 17.16 skrev email@hidden:

hi Havard,


You could do something like this, I moved the element for easy calculation, but you could cross reference with the bounds of the pages, in that case you could leave the element on its place. Anyway this is hopefully something useful.


tell application "Adobe InDesign CS5.5"
set mySelection to selection
set myDoc to active document
tell myDoc
if (count of mySelection) > 1 then
set myItem to make group with properties {group items:(mySelection)}
else
set myItem to item 1 of selection
end if
set {y1, x1, y2, x2} to geometric bounds of myItem
move myItem to {0, 0}
set {ny1, nx1, ny2, nx2} to geometric bounds of myItem
set theHeight to ny2
set theWidth to nx2
set geometric bounds of myItem to {y1, x1, y2, x2}
if (count of mySelection) > 1 then
ungroup myItem
end if
display dialog "the height is " & theHeight & ""
display dialog "the width is " & theWidth & ""
end tell
end tell


Best regards,
jan



InDesign CS5.I have a multiple objects selected. How can I get the width and height (as shown as H and W in the Control Panel).(Selection may be several objects within different groups on different layers.)
Håvard

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Prev by Date: Re: Indesign CS5 - getting width and height of selection?
  • Next by Date: Re: Indesign CS5 - getting width and height of selection?
  • Previous by thread: Re: Marquee selecting InDesign CS5
  • Next by thread: Apple Mail adding attachments hoses signature
  • Index(es):
    • Date
    • Thread