🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #18918

Re: AS: Can't move to spread

#18918
From: Shane Stanley
Date: Mon, 03 Feb 2003 10:31
76 lines
3812 bytes
Jan,

I think you're causing yourself unnecessary complication by using IDs
instead of object references. And because IDs are over-riding, they're
masking some things in your script. For example:

> repeat with myCounter from 1 to (count IDLinks)
> set LinkName to name of item myCounter of IDLinks as string
> -- Gets the object ID and then the Links ID and then its placement
> set thisLinkID to the id of item myCounter of IDLinks
> set ThisImageID to the id of parent of link id thisLinkID
> set ImgPos to geometric bounds of parent of parent of rectangle id thisLinkID

Now if you run this snippet, and add:

 class of rectangle id thisLinkID

You will get a result of:

 --> link

That's because thisLinkID is the ID of item myCounter of IDLinks -- that is,
a link -- and even if you call for "rectangle id thisLinkID" or even "spread
id thisLinkID", you are actually dealing with the item that has that ID,
regardless of its class. The error is covered over in your last line above
by the use of an extra "parent of". But these things tend to catch up with
you...

You hit the same problem later on when you refer to "spread id thisLinkID".

So the relevant section of your main script becomes:

  repeat with myCounter from 1 to (count IDLinks)
   set LinkName to name of item myCounter of IDLinks as string
   set thePic to parent of item myCounter of IDLinks
   set theFrame to parent of thePic
   set ImgPos to geometric bounds of theFrame

or more directly:

  repeat with myCounter from 1 to (count IDLinks)
   set LinkName to name of item myCounter of IDLinks as string
   set ImgPos to geometric bounds of parent of parent of item myCounter of
IDLinks

Now to the problem of which page or spread the pics belong to, and if you
are working by spread (probably the safest if pics might cross page
boundaries), you should also set your ruler origin to ruler origin spread
origin in view preferences.

But finding the spread is not just a matter of how many "parent of"s you
use, because the number depends on whether the image container is part of a
group, or an inline, or whatever. So you have to keep getting the parent and
testing, something like this:

  repeat with myCounter from 1 to (count IDLinks)
   set LinkName to name of item myCounter of IDLinks as string
   set thePic to parent of item myCounter of IDLinks
   set theFrame to parent of thePic
   set ImgPos to geometric bounds of theFrame
   repeat
    set theClass to class of parent of theFrame
    if theClass = spread then
     set theSpread to parent of theFrame
     exit repeat
    else
     set theFrame to parent of theFrame
    end if
   end repeat
 -- other code
   --Creates a textbox under the lowerright corner of the imagebox
   set ImgTxtFrame to make text frame at theSpread with properties
{geometric bounds:{myY2, myX2a, myY2a, myX2}}

-- 
Shane Stanley,  sstanley@myriad-com.com.au
Technical Details
Message-ID: <BA649035.4CB6E%sstanley@myriad-com.com.au>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newshosting.com!news-xfer1.atl.newshosting.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!nntp.infostrada.it!newsfeed01.sul.t-online.de!t-online.de!WebX
References: <1de7ab82.-1@WebX.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f939a,7ab2baaed378bb0f
X-Google-Attributes: gidf939a,public
X-Google-ArrivalTime: 2003-02-03 02:37:31 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-06!sn-xit-08!supernews.com!newshosting.com!news-xfer1.atl.newshosting.com!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!nntp.infostrada.it!newsfeed01.sul.t-online.de!t-online.de!WebX
Newsgroups: adobe.scripting.indesign
Subject: Re: AS: Can't move to spread
Message-ID: <BA649035.4CB6E%sstanley@myriad-com.com.au>
Date: Mon, 3 Feb 2003 02:31:34 -0800
References: <1de7ab82.-1@WebX.la2eafNXanI>
Lines: 90
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