The script gets the location (measurements) for guides on an InDesign page and creates text boxes for the areas within the guides. I’m using variables to calculate the text box bounds based on the page size and guide location. For some reason when I do this, the bounds end up in the wrong order. (The number for the width gets changed to the number for the distance from the top margin, the distance from the left margin gets changed to the height, etc.) Then the box is in the wrong spot and it’s the wrong size. If I change the order to accommodate this, the computer just picks a different random order to put the bounds in and they are still not right. When I use actual numbers instead of variables for the geometric bounds {“4 in”, “5 in”, “6 in”, 7 in"} the geometric bounds remain in the right order. Any ideas? Thanks!
on open droppedfiles
repeat with afile in droppedfiles
tell application "Adobe InDesign CC 2014"
--SETTING MEASUREMENTS TO INCHES
tell view preferences
--Measurement unit choices are:
--picas, points, inches, inches decimal, millimeters, centimeters, or ciceros
--Set horizontal and vertical measurement units to points.
set horizontal measurement units to inches decimal
set vertical measurement units to inches decimal
end tell
open afile
tell document 1
-----------------------------------------
--SETTING RULER ORIGIN TO ZERO
set rulerOrigin to ruler origin of view preferences
if rulerOrigin is not page origin then set ruler origin of view preferences to page origin --(spread origin/page origin/spine origin)
set rulerZeroPoint to zero point
if rulerZeroPoint is not {0, 0} then set zero point to {0, 0}
--Do Stuff
--Reset zero point and ruler origin
set zero point to rulerZeroPoint
set ruler origin of view preferences to rulerOrigin
-----------------------------------------
--SETTING PAGE HEIGHT AND WIDTH
tell page 1
set pageHeight to item 4 of bounds
set pageWidth to item 3 of bounds
end tell
set theGuides to every guide of page 1
-----------------------------------------
--CREATING EMPTY LISTS TO ADD TO LATER ON
set theGuideListVertical to {}
set theGuideListHorizontal to {}
--GETTING THE ORIENTATION (HORIZONTAL OR VERTICAL) FOR EVERY GUIDE
repeat with aGuide in theGuides --Telling it to loop through every guide
set guideOrientation to orientation of aGuide as string --Getting the orientation of every guide
--STORING THE LOCATION (MEASUREMENTS) OF EVERY VERTICAL GUIDE IN ONE LIST
if guideOrientation contains "«constant ****vert»" then --Determining if guides are vertical
set guideLocationVertical to location of aGuide --Getting the location of every guide
set theGuideListVertical to theGuideListVertical & guideLocationVertical --Creating the list with every location (measurement) of all the vertical guides
--STORING THE LOCATION (MEASUREMENTS) OF EVERY HORIZONAL GUIDE IN ANOTHER LIST
else if guideOrientation contains "«constant ****horz»" then --Determining if guides are horizontal
set guideLocationHorizontal to location of aGuide --Getting the location of every guide
set theGuideListHorizontal to theGuideListHorizontal & guideLocationHorizontal --Creating the list with every location (measurement) of all the horizontal guides
end if
end repeat
-----------------------------------------
--GETTING GEOMETRIC BOUNDS FOR LAST BOX
set lastFrameVerticalOffset to item 1 of theGuideListHorizontal as number
set lastFrameHorizontalOffset to item 1 of theGuideListVertical as number
set lastFrameHeight to (pageHeight - lastFrameHorizontalOffset) as number
set lastFrameWidth to (pageWidth - lastFrameVerticalOffset) as number
display dialog lastFrameVerticalOffset & " " & lastFrameHorizontalOffset & " " & lastFrameHeight & " " & lastFrameWidth as string
set xFrame1 to make text frame at page 1 of spread 1 with properties {geometric bounds:{lastFrameVerticalOffset, lastFrameHorizontalOffset, lastFrameHeight, lastFrameWidth}}
display dialog geometric bounds of xFrame1 as string
end tell
end tell
end repeat
end open
AppleScript: AppleScript 2.2.1
Browser: Safari 537.78.2
Operating System: Mac OS X (10.7)