🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #17741

Re: Centering selected objects on a page

#17741
From: Shane Stanley
Date: Tue, 20 May 2003 22:53
31 lines
2035 bytes
in article BAEC50A5.5A3D4%sstanley@myriad-com.com.au, Shane Stanley wrote:

> tell application "InDesign 2.0.2"
> set {a, b, c, d} to bounds of page 1 of document 1
> make group at document 1 with data (get selection)
> set {w, x, y, z} to geometric bounds of result
> undo document 1 -- undo the grouping
> move selection by {d / 2 - (x + z) / 2, c / 2 - (w + y) / 2}
> end tell

Which unfortunately fails at the make group command on other than page 1 --
presumably ID is seeing document 1 as meaning "page 1 of document 1" here.

So here's a version that fixes that and also handles the case of a single
item in the selection:

tell application "InDesign 2.0.2"
 set {A, b, c, D} to bounds of page 1 of document 1
 set theSel to selection
 if (count of theSel) > 1 then
  make group at parent of item 1 of theSel with data theSel
  set {w, x, y, z} to geometric bounds of result
  undo document 1 -- undo the grouping
 else
  set {w, x, y, z} to geometric bounds of item 1 of theSel
 end if
 move selection by {D / 2 - (x + z) / 2, c / 2 - (w + y) / 2}
end tell

-- 
Shane Stanley,  sstanley@myriad-com.com.au
Technical Details
Message-ID: <BAF0EF23.5ACBD%sstanley@myriad-com.com.au>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!proxad.net!newsfeed.tpinternet.pl!newsfeed01.sul.t-online.de!t-online.de!WebX
References: <BAEC366B.385D2%mscheurer@mac.com> <BAEC50A5.5A3D4%sstanley@myriad-com.com.au>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,b3b0a2530133ea38
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-05-20 16:07:53 PST
From: Shane Stanley <sstanley@myriad-com.com.au>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!proxad.net!newsfeed.tpinternet.pl!newsfeed01.sul.t-online.de!t-online.de!WebX
Newsgroups: adobe.scripting.indesign
Subject: Re: Centering selected objects on a page
Message-ID: <BAF0EF23.5ACBD%sstanley@myriad-com.com.au>
Date: Tue, 20 May 2003 15:53:56 -0700
References: <BAEC366B.385D2%mscheurer@mac.com> <BAEC50A5.5A3D4%sstanley@myriad-com.com.au>
Lines: 36
User-Agent: Microsoft-Outlook-Express-Macintosh-Edition/5.0.6
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit