Author
Topic: Geometric Bounds out of order (Read 750 times)

I'm getting the location (measurements) for guides on a page and I'm creating 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. Then the box is in the wrong spot and it's the wrong size. When I use actual numbers for the geometric bounds {"4 in", "5 in", "6 in", 7 in"} the bounds remain in the right order. Any ideas? Thanks!

--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

Ah, I see. InDesign calculates the geometric bounds differently than I thought. Here's the working code. I may be back. I have to figure out how to calculate the placement for the rest of the boxes and then I'm going to measure the square inches of the boxes and put that information in the box.

--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

set hItemListCount to count number of items in theGuideListHorizontal set vItemListCount to count number of items in theGuideListVertical

-----------------------------------------

--GETTING GEOMETRIC BOUNDS FOR LAST BOX

set lastFrameY1 to item 1 of theGuideListHorizontal as number set lastFrameX1 to item 1 of theGuideListVertical as number

set xFrame1 to make text frame at page 1 of spread 1 with properties {geometric bounds:{lastFrameY1, lastFrameX1, pageWidth, pageHeight}}