Author Topic: Text Frames for Page 2 to End Up on Page 1  (Read 479 times)

0 Members and 1 Guest are viewing this topic.

Offline mbornbach

  • Newbie
  • *
  • Posts: 34
  • Karma: 0
Text Frames for Page 2 to End Up on Page 1
« on: June 12, 2017, 05:28:44 PM »
I have a script that measures text frames and places those measurements as text inside the text frame. The only problem I'm having is that InDesign wants to put the measurements for page 2 of the spread on page 1. What do I need to change to convince InDesign to put the measurements for page 2 on page 2?

Code: [Select]

--------------------------------------------------------------------------------------------------------------
--CREATING SEPARATE NEW LAYER FOR THE MEASURMENTS AND TEXT BOXES IF IT DOESN'T EXIST
--------------------------------------------------------------------------------------------------------------

open afile


tell document 1 -->Beginning of tell document 1 block
try
set measuringLayer to make layer with properties {name:"Measure"}

--Telling script to use existing measure layer if it already exists
on error
set measuringLayer to layer "Measure"
end try



--------------------------------------------------------------------------------------------------------------
--GETTING MEASUREMENTS AND ADDING THEM AS TEXT TO THE MEASURED TEXT FRAME
--------------------------------------------------------------------------------------------------------------

--Displaying a message to the user if there are no text frames on the measure layer
if (count of every text frame of measuringLayer) is 0 then -->Beginning of if statement
set boxesDontExist to true -->Using this to display a dialog further down in the script, after the repeat loop ends.


--Getting the measurements of every text frame on the measure layer
else

set my_pages to every page
repeat with a_page in my_pages
set page_name to get the name of a_page


set boxesExist to true -->Using this to display a dialog further down in the script, after the repeat loop ends.
set measuringTextFrames to (every text frame of page page_name whose item layer is measuringLayer)
repeat with measuringTextFrame in measuringTextFrames -->Beginning of second repeat loop


--Geometric bounds are {top side, left side, bottom side, right side}, also referred to as {y1, x1, y2, x2}
set y2 to item 3 of geometric bounds of measuringTextFrame -->y2 is the bottom side of the frame
set y1 to item 1 of geometric bounds of measuringTextFrame -->y1 is the top side of the frame
set x1 to item 2 of geometric bounds of measuringTextFrame -->x1 is the left side of the frame
set x2 to item 4 of geometric bounds of measuringTextFrame -->x2 is the right side of the frame


--Doing some math with those measurements to figure out the square inches of each frame
set frameHeight to y2 - y1 -->bottom of frame - top of frame = height of the frame
set frameWidth to x2 - x1 -->right side of frame - left side of frame = width of the frame
set frameSquareInchesLong to frameHeight * frameWidth -->multiplying height time width to get square inches
set frameSquareInches to my roundThis(frameSquareInchesLong, 2) -->making the number round to only 2 decimal points instead of a gazillion
set inchMarks to {"''"} -->Adding the inch marks in between quotes
set measurementText to frameSquareInches & inchMarks as string -->Final result followed by the inch marks (example: 3.08")


--Creating the text frames that will hold the measurements
tell page page_name to set displayTextFrame to make text frame with properties {layer:measuringLayer, geometric bounds:{(y1 + "0.05"), (x1 + "0.075"), y2, x2}, stroke color:"None", stroke weight:0}


--Inserting the square inches figured into each frame as text
tell displayTextFrame

--Adding the drop shadow to the text
apply object style using dropShadowStyle

--Adding the calculated result for square inches in each text frame
set contents of insertion point -1 to measurementText

end tell

end repeat -->End of second repeat loop





end repeat --> End of repeat with page loop
end if -->End of if statement

Offline Jean-Marie Schwartz

  • Sr. Member
  • ****
  • Posts: 436
  • Karma: 6
  • Gender: Male
Re: Text Frames for Page 2 to End Up on Page 1
« Reply #1 on: June 14, 2017, 03:37:17 AM »
Hi there! I don't use ID hence I don't script ID, but can't address either spread or page? If so, you could target say the last page of spread 2, or page 2 of spread 17. Does this make sense? Another possible way (to me) would be to add the width of the page to the measures so that the new object to be created falls on the right hand page. Are you with me? Then you'd need to test the page number and detect wether you're on a odd or even page. HTH.
Jean-Marie Schwartz
May the Schwartz be with you :-)

= Mac Pro Quad-Core Intel 2.8 GHz 10 Go 1066 MHz DDR3 Mac OS 10.8.5 QuarkXPress 9.5.4.1 Adobe CS5 =