Skip to main content
Participating Frequently
January 27, 2009
Question

Align to page

  • January 27, 2009
  • 12 replies
  • 929 views
Hi - new to using applescript
I've got a text box that I've made with Applescript. How can create my box, so that it is aligned to the bottom left of the page? I will be using this script on ID docs that are different sizes, but I will always need my text box at the bottom left.
This topic has been closed for replies.

12 replies

Inspiring
January 30, 2009
On 31/1/09 3:57 AM, "Kermy" <member@adobeforums.com> wrote:<br /><br />> I'm also thinking on making a version where I can drop multiple indd files<br />> on it from the Finder. What's the best format for that - Application (.app)?<br /><br />Yes, that has to be an app. There are two kinds -- bundle apps are Cocoa<br />native apps, and have some other advantages.<br /><br />> What/where is Script Debugger?<br /><br />It's a third-party script editor. You can download a copy from<br /><www.latenightsw.com/> for evaluation. I recommend it highly.<br /><br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au><br />AppleScript Pro Florida, April 2009 <a href=http://scriptingmatters.com/aspro>
_Kermy_Author
Participating Frequently
January 30, 2009
Thanks Eric - that code worked out fine for the formatting the font.

Shane, I'm guessing I will save this as Script (.scpt), when I'm done to use in the indd Script Panel, but I'm also thinking on making a version where I can drop multiple indd files on it from the Finder. What's the best format for that - Application (.app)?

This is my first time using Applescript and doing plenty of reading.

What/where is Script Debugger?
Inspiring
January 30, 2009
On 30/1/09 9:39 AM, "Olav Kvern" <member@adobeforums.com> wrote:<br /><br />> I guess I've just been burned too often by compiled scripts. My scripts often<br />> need to reside on non-Mac OS systems, and I've just had too many compiled<br />> files get corrupted as they go back and forth.<br /><br />That was certainly a problem with the old resource-fork format, but now that<br />everything is saved in the one fork (unless you want a bundle), there's much<br />less risk. And if you use Script Debugger, it adds in a copy of the source<br />text anyway, so it can be recovered that way.<br /><br />The other thing worth mentioning is that InDesign supports script bundles<br />(.scptd). These are very useful for things like attachment scripts, because<br />they give you a simple way to package (and find) external scripts called by<br />do script.<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au><br />AppleScript Pro Florida, April 2009 <a href=http://scriptingmatters.com/aspro>
Known Participant
January 29, 2009
Hi Shane,

I guess I've just been burned too often by compiled scripts. My scripts often need to reside on non-Mac OS systems, and I've just had too many compiled files get corrupted as they go back and forth.

re: Speed

Certainly I'd expect it to be slower, but I haven't noticed much of a speed difference with scripts that *don't* call other applications.

Thanks,

Ole
Inspiring
January 29, 2009
On 29/1/09 10:50 AM, "Olav Kvern" <member@adobeforums.com> wrote:<br /><br />> If you're running from the Scripts panel, I'm not aware of any advantage to<br />> saving as a compiled script over saving as a text file. What am I missing?<br /><br />Speed. If you save as text, the file has to be converted to AppleScript<br />tokens before it's run. How much time this takes can vary from next to<br />nothing to quite dramatic -- for example, if your script also addresses<br />another app, it means loading another dictionary.<br /><br />You also lose the ability to use persistent properties, you're more<br />susceptible to problems with terminology changes, and in some cases you risk<br />problems with different text encodings. You also avoid some potential<br />problems when moving between versions. Against that, I see few cons.<br /><br />The fact that you *can* run text files is a good thing, and in some cases<br />useful. But as a default, IMO, it doesn't make sense.<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au><br />AppleScript Pro Florida, April 2009 <a href=http://scriptingmatters.com/aspro>
January 29, 2009
Add a label so you can change them all afterwards. Something like this:

tell every page

set myTextBox to make new text frame with properties {geometric bounds:boxBounds, label:"myTextBox", contents:MyDocName}
end tell
set applied font of parent story of every text frame whose label = "myTextBox" to font ("Monaco" & tab & "Regular") as string
set point size of parent story of every text frame whose label = "myTextBox" to "8pt"

Better yet, create a text style and then just set them to that (which I will leave as an exercise to the reader). You can find all this in the scripting dictionary (cmd-shift-O, choose InDesign app). Look for story and you will see what properties you're allowed to set on it.
Known Participant
January 28, 2009
Shane wrote: "If you want to run it from InDesign's panel, save it as a Compiled Script (Data Fork). If you want to make it a standalone app, save it as either kind of application."

If you're running from the Scripts panel, I'm not aware of any advantage to saving as a compiled script over saving as a text file. What am I missing?

Thanks,

Ole
Inspiring
January 28, 2009
On 29/1/09 2:12 AM, "Kermy" <member@adobeforums.com> wrote:<br /><br />> How should I be saving this?<br /><br />If you want to run it from InDesign's panel, save it as a Compiled Script<br />(Data Fork). If you want to make it a standalone app, save it as either kind<br />of application.<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au><br />AppleScript Pro Florida, April 2009 <a href=http://scriptingmatters.com/aspro>
_Kermy_Author
Participating Frequently
January 28, 2009
Eric - That worked out swell. How can I get the font formatted, i.e. Arial, 4pt, Rt justified?
My Code:
tell application "Adobe InDesign CS3"
set myDocument to active document
set MyDocName to (name of document 1) as string
tell active document
--Standardize your coords
set zero point to {"0p", "0p"}
set horizontal measurement units of view preferences to points
set vertical measurement units of view preferences to points
set ruler origin of view preferences to page origin

--Define Doc & Box height/width
set thisDocHeight to page height of document preferences
set thisDocWidth to page width of document preferences
set boxHeight to 9
set boxWidth to 72

--Position in bottom right corner
-- using top,left,bottom,right coord system
set boxBounds to {thisDocHeight - boxHeight, 0, thisDocHeight, boxWidth}

--Place the boxes
tell every page

set myTextBox to make new text frame with properties {geometric bounds:boxBounds, contents:MyDocName}

end tell
end tell
end tell
_Kermy_Author
Participating Frequently
January 28, 2009
Well crap, somehow today my code is all screwed up. I guess I saved it in the wrong format and it changed(?). I have all of these funky brackets in my code now. Here's my screwed up code:

tell application "Adobe InDesign CS3"

set myDocument to make document
tell «class vwpp» of myDocument
set «class hunt» to «class zpoi»
set «class vunt» to «class zpoi»

set «class RCtp» to «constant MRcdRCPo»
end tell
set myPage to «class page» 1 of myDocument
set myString to "TEST" & return

tell myPage
set myTextFrame to make «class txtf» with properties {«class gbnd»:{0, 0, 15.738, 144}, contents:" " & myString}
tell myTextFrame
tell paragraph 1
set font to "Georgia"
set «class ptfs» to "Regular"
set size to 5
set «class szld» to 5
set «class paln» to «constant Baltleft»

end tell
end tell

tell «class strp» of myTextFrame
end tell
end tell
end tell

How should I be saving this? -