i finally completed what i would consider to be my first REAL script for InDesign CS2 – “real” meaning that it took me some time to figure out and it makes a positive impact on my working situation, reducing what would normally take an hour or so down to about 5 seconds. it’s written in Tiger, but hasn’t been fully tested in Panther.
the functions are:
- sets the bleed and slug area
- creates six layers with name and color properties
- creates a slug box on four specific layers
- creates slug line in the slug boxes with
a) the document name
b) automatic page number
c) layer name
d) proof version
e) sign-off areas for different departments
here’s a copy of the script:
(*
Can we build it?! YES WE CAN!!
January, 2006
Ray Massie: raymassie@onomonopia.com
Build document layers and slug in InDesign
With much help from: John Thorsen, Hanaan Rosenthal, Sal Soghoian, Olivier Berquin, and MacScripter.net
*)
tell application "Adobe InDesign CS2"
--!! change doc preferences !!---
--set bleed and slug
try
set properties of document preferences of active document to {document bleed bottom offset:0.125, document bleed inside or left offset:0.125, document bleed outside or right offset:0.125, document bleed top offset:0.125, document bleed uniform size:true, slug bottom offset:0.5, slug inside or left offset:0.0, slug right or outside offset:0.0, slug top offset:0.0, document slug uniform size:false}
end try
--set zero point
set zeroPoint to zero point of active document
set zero point of active document to {0, 0}
--set ruler origin
set rulerOrigin to ruler origin of view preferences of active document
set ruler origin of view preferences of active document to page origin
--some definitions
set myDoc to active document
set docName to name of myDoc as text
set boxWidth to page width of document preferences of myDoc
set boxHeight to page height of document preferences of myDoc
set currentDate to current date
set underscore to "_"
set autoPage to auto page number
set countPages to (count pages of myDoc)
---!! build the layers !!---
--change the first layer to "Default"
try
set name of layer 1 of myDoc to "Default"
end try
--make layers
tell myDoc
set coldread to make layer with properties {name:"Print/ColdRead", layer color:black, visible:false}
set mwgm to make layer with properties {name:"Midwest-MWGM", layer color:light blue}
set swgm to make layer with properties {name:"Southwest-SWGM", layer color:red, visible:false}
set wgm to make layer with properties {name:"West-WGM", layer color:green, visible:false}
set egm to make layer with properties {name:"East-EGM", layer color:blue, visible:false}
set sep to make layer with properties {name:"Separator", layer color:magenta, visible:false}
end tell
--! MWGM !--
--Set the active layer of the document.
set active layer of active window to layer "Midwest-MWGM" of myDoc
set layerName to "Midwest-MWGM"
--draw the slug
repeat with i from 1 to countPages
tell page (i) of myDoc
set mySlug to make text frame with properties {geometric bounds:{(boxHeight + 0.5), "0", (boxHeight - 0.0625), boxWidth}, contents:docName & underscore & autoPage & underscore & layerName & underscore & "Proof 1" & return & ¬
"DTP" & underscore & underscore & underscore & underscore & underscore & underscore & " " & ¬
"PR" & underscore & underscore & underscore & underscore & underscore & underscore & " " & ¬
"CE" & underscore & underscore & underscore & underscore & underscore & underscore & " " & ¬
"AD" & underscore & underscore & underscore & underscore & underscore & underscore & " " & ¬
"AM" & underscore & underscore & underscore & underscore & underscore & underscore}
tell mySlug
set vertical justification of text frame preferences to bottom align
set justification of paragraphs to center align
set applied font of paragraphs to "Helvetica Neue 55 Roman"
end tell
end tell
end repeat
--! SWGM !--
--Set the active layer of the document.
set active layer of active window to layer "Southwest-SWGM" of myDoc
set layerName to "Southwest-SWGM"
--draw the slug
repeat with i from 1 to countPages
tell page (i) of myDoc
set mySlug to make text frame with properties {geometric bounds:{(boxHeight + 0.5), "0", (boxHeight - 0.0625), boxWidth}, contents:docName & underscore & autoPage & underscore & layerName & underscore & "Proof 1" & return & ¬
"DTP" & underscore & underscore & underscore & underscore & underscore & underscore & " " & ¬
"PR" & underscore & underscore & underscore & underscore & underscore & underscore & " " & ¬
"CE" & underscore & underscore & underscore & underscore & underscore & underscore & " " & ¬
"AD" & underscore & underscore & underscore & underscore & underscore & underscore & " " & ¬
"AM" & underscore & underscore & underscore & underscore & underscore & underscore}
tell mySlug
set vertical justification of text frame preferences to bottom align
set justification of paragraphs to center align
set applied font of paragraphs to "Helvetica Neue 55 Roman"
end tell
end tell
end repeat
--! WGM !--
--Set the active layer of the document.
set active layer of active window to layer "West-WGM" of myDoc
set layerName to "West-WGM"
--draw the slug
repeat with i from 1 to countPages
tell page (i) of myDoc
set mySlug to make text frame with properties {geometric bounds:{(boxHeight + 0.5), "0", (boxHeight - 0.0625), boxWidth}, contents:docName & underscore & autoPage & underscore & layerName & underscore & "Proof 1" & return & ¬
"DTP" & underscore & underscore & underscore & underscore & underscore & underscore & " " & ¬
"PR" & underscore & underscore & underscore & underscore & underscore & underscore & " " & ¬
"CE" & underscore & underscore & underscore & underscore & underscore & underscore & " " & ¬
"AD" & underscore & underscore & underscore & underscore & underscore & underscore & " " & ¬
"AM" & underscore & underscore & underscore & underscore & underscore & underscore}
tell mySlug
set vertical justification of text frame preferences to bottom align
set justification of paragraphs to center align
set applied font of paragraphs to "Helvetica Neue 55 Roman"
end tell
end tell
end repeat
--! EGM !--
--Set the active layer of the document.
set active layer of active window to layer "East-EGM" of myDoc
set layerName to "East-EGM"
--draw the slug
repeat with i from 1 to countPages
tell page (i) of myDoc
set mySlug to make text frame with properties ¬
{geometric bounds:{(boxHeight + 0.5), "0", (boxHeight - 0.0625), boxWidth}, contents:docName & underscore & autoPage & underscore & layerName & underscore & "Proof 1" & return & ¬
"DTP" & underscore & underscore & underscore & underscore & underscore & underscore & " " & ¬
"PR" & underscore & underscore & underscore & underscore & underscore & underscore & " " & ¬
"CE" & underscore & underscore & underscore & underscore & underscore & underscore & " " & ¬
"AD" & underscore & underscore & underscore & underscore & underscore & underscore & " " & ¬
"AM" & underscore & underscore & underscore & underscore & underscore & underscore ¬
}
tell mySlug
set vertical justification of text frame preferences to bottom align
set justification of paragraphs to center align
set applied font of paragraphs to "Helvetica Neue 55 Roman"
end tell
end tell
end repeat
---!! house keeping !!---
--search/replace auto page number
tell myDoc
search for "auto page number" replacing with "^#" with case sensitive and whole word
end tell
--reset ruler origin
set ruler origin of view preferences of myDoc to rulerOrigin
--reset zero point
set zero point of myDoc to zeroPoint
--last end tell
end tell