Welcome Dialog

Welcome to the Community!

We have a brand new look! Take a tour with us and explore the latest updates on Adobe Support Community.


Adjustment of a script that places dimensions on page

New Here ,
Jun 15, 2021 Jun 15, 2021

Copy link to clipboard

Copied

Hi All,

 

i was wondering if anyone could help me adapt a script I have that adds dimensions to an INDD document but I would like the dimensions and arrows to go below the page instead of above (as have the legend in this place and cannot be moved).

 

the script is below. was a free script from www.drscripto.com

 

property NumberGap : 25 --THIS IS THE GAP LEFT FOR THE NUMBER AND UNITS BETWEEN THE ARROWS (IN mm)

property ArrowOffset : 9

property LineThickness : 0.5

property FontSize : 12

property LineColour : "Black"

property SwatchNames : {}

property GlobalScale : 100

set TempSwatches to {}

set UnitsList to {"millimeters", "inches", "centimeters", "points", "pixels"}

set UnitsAbbreviations to {"mm", "\"", "cm", "pts", "px"}

set mmScaleList to {1, 0.0393701, 0.100000054, 2.83464, 2.83464}

 

tell application "Adobe InDesign 2020"

if (count of (every document)) is 0 then

display dialog "Please open a document and try this script again" buttons "OK" default button 1 giving up after 60

return

end if

--

set myRotateMatrix to make transformation matrix with properties {counterclockwise rotation angle:-90}

tell document 1

--GET NAMES OF SWATCHES

set SwatchNames to name of every swatch

repeat with i from 1 to (count SwatchNames)

set ThisSwatch to item i of SwatchNames

if ThisSwatch is not in {"None", "Paper"} then set the end of TempSwatches to ThisSwatch

end repeat

set SwatchNames to TempSwatches

--

set OrigRulerOrigin to ruler origin of view preferences

set ruler origin of view preferences to spread origin

set TypogPrefs to typographers quotes of text preferences

set typographers quotes of text preferences to false

 

--GET HORIZONTAL UNITS

set MyUnits to horizontal measurement units of view preferences

set MyUnits to MyUnits as string

set AbbrevPosition to my ListPosition(MyUnits, UnitsList)

if AbbrevPosition is not 0 then

set MyUnitsAbrev to item AbbrevPosition of UnitsAbbreviations

set mmScale to item AbbrevPosition of mmScaleList

else

set MyUnitsAbrev to ""

set mmScale to 0.3

end if

 

--ADVANCED DIALOG BOX

set MeasurementsChoice to my AdvancedIntroDialog(MyUnits)

if MeasurementsChoice is false then return

 

--MAKE NEW MEASUREMENTS LAYER

try

set MeasurementsLayer to layer "Measurements"

set locked of MeasurementsLayer to false

on error

set MeasurementsLayer to make layer with properties {name:"Measurements"}

end try

 

if the selection is {} then

set EveryPage to pages

set SelectedObjects to false

else

set EveryPage to the selection

set SelectedObjects to true

set ParentPage to parent page of item 1 of the selection

end if

 

repeat with i from 1 to (count of EveryPage)

set ThisPage to item i of EveryPage

try

set {PageY1, PageX1, PageY2, PageX2} to bounds of ThisPage

on error

set {PageY1, PageX1, PageY2, PageX2} to geometric bounds of ThisPage

end try

set PageWidth to PageX2 - PageX1

set PageHeight to PageY2 - PageY1

--

--Apply percentage to label only

set PageWidthString to PageWidth * 100 / GlobalScale

set PageHeightString to PageHeight * 100 / GlobalScale

set PageWidthString to (round (PageWidthString * 100)) / 100

set PageHeightString to (round (PageHeightString * 100)) / 100

if PageWidthString = PageWidthString as integer then set PageWidthString to PageWidthString as integer

if PageHeightString = PageHeightString as integer then set PageHeightString to PageHeightString as integer

--

set PageWidth to (round (PageWidth * 100)) / 100

set PageHeight to (round (PageHeight * 100)) / 100

if PageWidth = PageWidth as integer then set PageWidth to PageWidth as integer

if PageHeight = PageHeight as integer then set PageHeight to PageHeight as integer

--

set PageWidthString to (PageWidthString as string) & MyUnitsAbrev

set PageHeightString to (PageHeightString as string) & MyUnitsAbrev

--tell MeasurementsLayer

if MeasurementsChoice = 0 or MeasurementsChoice = 2 then --Top measurements or all measurements has been selected

if SelectedObjects then

--TOP MEASUREMENT OBJECTS

tell ParentPage

set MeasurementBox to make new text frame with properties {contents:PageWidthString, geometric bounds:{PageY1 - ((ArrowOffset + 4) * mmScale), PageX1, PageY1 - ((ArrowOffset - 4) * mmScale), PageX2}, layer:MeasurementsLayer}

set properties of (parent story of MeasurementBox) to {justification:center align, point size:FontSize, applied font:"Arial", fill color:LineColour}

set vertical justification of text frame preferences of MeasurementBox to center align

make new graphic line with properties {stroke color:LineColour, stroke weight:LineThickness, geometric bounds:{PageY1 - (ArrowOffset * mmScale), PageX1 + (1 * mmScale), PageY1 - (ArrowOffset * mmScale), (PageX1 + ((PageWidth - (NumberGap * mmScale)) / 2))}, left line end:triangle wide arrow head, layer:MeasurementsLayer}

make new graphic line with properties {stroke color:LineColour, stroke weight:LineThickness, geometric bounds:{PageY1 - (ArrowOffset * mmScale), (PageX1 + (NumberGap * mmScale) + ((PageWidth - (NumberGap * mmScale)) / 2)), PageY1 - (ArrowOffset * mmScale), PageX2 - (1 * mmScale)}, right line end:triangle wide arrow head, layer:MeasurementsLayer}

end tell

else

--TOP MEASUREMENT PAGES

tell ThisPage

set MeasurementBox to make new text frame with properties {contents:PageWidthString, geometric bounds:{PageY1 - ((ArrowOffset + 4) * mmScale), PageX1, PageY1 - ((ArrowOffset - 4) * mmScale), PageX2}, layer:MeasurementsLayer}

set properties of (parent story of MeasurementBox) to {justification:center align, point size:FontSize, applied font:"Arial", fill color:LineColour}

set vertical justification of text frame preferences of MeasurementBox to center align

make new graphic line with properties {stroke color:LineColour, stroke weight:LineThickness, geometric bounds:{PageY1 - (ArrowOffset * mmScale), PageX1 + (1 * mmScale), PageY1 - (ArrowOffset * mmScale), (PageX1 + ((PageWidth - (NumberGap * mmScale)) / 2))}, left line end:triangle wide arrow head, layer:MeasurementsLayer}

make new graphic line with properties {stroke color:LineColour, stroke weight:LineThickness, geometric bounds:{PageY1 - (ArrowOffset * mmScale), (PageX1 + (NumberGap * mmScale) + ((PageWidth - (NumberGap * mmScale)) / 2)), PageY1 - (ArrowOffset * mmScale), PageX2 - (1 * mmScale)}, right line end:triangle wide arrow head, layer:MeasurementsLayer}

end tell

end if

end if

if MeasurementsChoice = 1 or MeasurementsChoice = 2 then --Side measurements or all measurements has been selected

if SelectedObjects then

--SIDE MEASUREMENT ON OBJECTS

tell ParentPage

set MeasurementBox to make new text frame with properties {contents:PageHeightString, geometric bounds:{PageY1 - ((ArrowOffset + 4) * mmScale), PageX1, PageY1 - ((ArrowOffset - 4) * mmScale), PageX2}, layer:MeasurementsLayer}

set properties of (parent story of MeasurementBox) to {justification:center align, point size:FontSize, applied font:"Arial", fill color:LineColour}

set vertical justification of text frame preferences of MeasurementBox to center align

transform MeasurementBox in pasteboard coordinates from center anchor with matrix myRotateMatrix

set geometric bounds of MeasurementBox to {PageY1, (PageX2 + ((ArrowOffset - 4) * mmScale)), PageY2, (PageX2 + ((ArrowOffset + 4) * mmScale))}

make new graphic line with properties {stroke color:LineColour, stroke weight:LineThickness, geometric bounds:{(PageY1 + (1 * mmScale)), PageX2 + (ArrowOffset * mmScale), (PageY1 + (PageHeight / 2) - ((NumberGap * mmScale) / 2)), PageX2 + (ArrowOffset * mmScale)}, left line end:triangle wide arrow head, layer:MeasurementsLayer}

make new graphic line with properties {stroke color:LineColour, stroke weight:LineThickness, geometric bounds:{(PageY2 - (PageHeight / 2) + ((NumberGap * mmScale) / 2)), PageX2 + (ArrowOffset * mmScale), (PageY2 - (1 * mmScale)), PageX2 + (ArrowOffset * mmScale)}, right line end:triangle wide arrow head, layer:MeasurementsLayer}

end tell

else

--SIDE MEASUREMENT ON PAGES

tell ThisPage

set MeasurementBox to make new text frame with properties {contents:PageHeightString, geometric bounds:{PageY1 - ((ArrowOffset + 4) * mmScale), PageX1, PageY1 - ((ArrowOffset - 4) * mmScale), PageX2}, layer:MeasurementsLayer}

set properties of (parent story of MeasurementBox) to {justification:center align, point size:FontSize, applied font:"Arial", fill color:LineColour}

set vertical justification of text frame preferences of MeasurementBox to center align

transform MeasurementBox in pasteboard coordinates from center anchor with matrix myRotateMatrix

set geometric bounds of MeasurementBox to {0, (PageX1 + PageWidth + ((ArrowOffset - 4) * mmScale)), (PageHeight), (PageX1 + PageWidth + ((ArrowOffset + 4) * mmScale))}

make new graphic line with properties {stroke color:LineColour, stroke weight:LineThickness, geometric bounds:{(PageY1 + (1 * mmScale)), PageX1 + PageWidth + (ArrowOffset * mmScale), ((PageHeight / 2) - ((NumberGap * mmScale) / 2)), PageX1 + PageWidth + (ArrowOffset * mmScale)}, left line end:triangle wide arrow head, layer:MeasurementsLayer}

make new graphic line with properties {stroke color:LineColour, stroke weight:LineThickness, geometric bounds:{((PageHeight / 2) + ((NumberGap * mmScale) / 2)), PageX1 + PageWidth + (ArrowOffset * mmScale), (PageY2 - (1 * mmScale)), PageX1 + PageWidth + (ArrowOffset * mmScale)}, right line end:triangle wide arrow head, layer:MeasurementsLayer}

end tell

end if

end if

end repeat

set typographers quotes of text preferences to TypogPrefs

set ruler origin of view preferences to OrigRulerOrigin

end tell

end tell

 

--SUBROUTINES

 

on AdvancedIntroDialog(MyUnits)

tell application "Adobe InDesign 2020"

if MyUnits is "millimeters" then

set EditUnits to millimeters

else if MyUnits is "inches" then

set EditUnits to inches

else if MyUnits is "centimeters" then

set EditUnits to centimeters

else

set EditUnits to pixels

end if

--UNITS EXPECTED FOR MEASUREMENT BOXES ARE ALWAYS POINTS (PIXELS)

set ConvertedOffset to ArrowOffset * 2.83464

set ConvertedNumGap to NumberGap * 2.83464

--

activate

set MyDialog to make dialog with properties {name:"Add measurements", can cancel:true}

tell MyDialog

tell (make dialog column with properties {min width:290})

--BORDER PANEL 1

tell (make border panel)

tell (make dialog column)

tell (make dialog row) to make static text with properties {static label:"Add measurements value to width and/or height of each page.          ", min width:300}

tell (make dialog row)

set MeasurementsAnswer to make radiobutton group

tell MeasurementsAnswer

set OptionWidth to make radiobutton control with properties {static label:"Width (positioned at top of each page)"}

set OptionHeight to make radiobutton control with properties {static label:"Height (positioned on right hand side of each page"}

set OptionBoth to make radiobutton control with properties {static label:"Both width and height"}

set checked state of OptionWidth to true

end tell

end tell --End dialog row

end tell --End dialog column

end tell --End border panel

--BORDER PANEL 2

tell (make border panel)

tell (make dialog column)

make static text with properties {static label:"Arrow lines offset: "}

make static text with properties {static label:"Arrow lines thickness: "}

make static text with properties {static label:"Gap for number: "}

make static text with properties {static label:"Font size: "}

make static text with properties {static label:"Line colour: "}

make static text with properties {static label:"Artwork scaling:"}

end tell

tell (make dialog column)

set EditBoxOffset to make new measurement editbox with properties {edit value:ConvertedOffset, edit units:EditUnits, min width:106}

set EditBoxLineThick to make new measurement editbox with properties {edit value:LineThickness, edit units:points, min width:106}

set EditBoxNumGap to make new measurement editbox with properties {edit value:ConvertedNumGap, edit units:EditUnits, min width:106}

set EditTextSize to make new measurement editbox with properties {edit value:FontSize, edit units:points, min width:106}

set EditLineColour to make dropdown with properties {string list:SwatchNames, selected index:0, min width:106}

set EditGlobalScale to make new percent editbox with properties {edit value:GlobalScale}

end tell

tell (make dialog column)

make static text with properties {static label:"", min width:67}

end tell

end tell

end tell --End dialog column

end tell

 

--Show the dialog box

 

try

set MyResult to show MyDialog

set MeasurementsChoice to selected button of MeasurementsAnswer

 

-- OFFSET OF ARROW LINES

set NewOffset to edit value of EditBoxOffset

set NewOffset to NewOffset * 0.352778

if NewOffsetArrowOffset then set ArrowOffset to NewOffset

 

-- GAP FOR NUMBERS - VALUE RETURNED IN POINTS/PIXELS

set NewGap to edit value of EditBoxNumGap

set NewGap to NewGap * 0.352778

if NewGapNumberGap then set NumberGap to NewGap

 

-- THICKNESS OF ARROW LINES

set NewThick to edit value of EditBoxLineThick

--No conversion necessary for line thickness (points)

if NewThickLineThickness then --set LineThickness to NewThick

set LineThickness to NewThick

end if

 

--FONT SIZE

set NewFontWeight to edit value of EditTextSize

--No conversion necessary for line thickness (points)

if NewFontWeightFontSize then

set FontSize to NewFontWeight

end if

 

-- LINE COLOUR

set ChoiceLineColour to (selected index of EditLineColour) + 1

set LineColour to item ChoiceLineColour of SwatchNames

--

 

--PERCENTAGE

set GlobalScale to edit value of EditGlobalScale

--

on error ErrorMessage

display dialog ErrorMessage

destroy MyDialog

return false

end try

destroy MyDialog

--CHECK IF CANCELLED

if MyResult is false then

return false

else

return MeasurementsChoice

end if

end tell

end AdvancedIntroDialog

 

on ListPosition(this_item, this_list)

repeat with i from 1 to the count of this_list

if item i of this_list is this_item then return i

end repeat

return 0

end ListPosition

 

https://www.drscripto.com/index.php?eddfile=7546%3A1414%3A1%3A0&ttl=1627432134&file=1&token=34106894...


Thanks 

 

Alex

TOPICS
Scripting

Views

171

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , Jun 15, 2021 Jun 15, 2021
Hello, Below is a modified version of the script that puts the the dimensions and arrows at the bottom of the page. property NumberGap : 25 --THIS IS THE GAP LEFT FOR THE NUMBER AND UNITS BETWEEN THE ARROWS (IN mm)property WidthArrowOffset : -9property HeightArrowOffset : 9property LineThickness : 0.5property FontSize : 12property LineColour : "Black"property SwatchNames : {}property GlobalScale : 100set TempSwatches to {}set UnitsList to {"millimeters", "inches", "centimeters", "points", "pixel...

Likes

Translate

Translate
Advocate ,
Jun 15, 2021 Jun 15, 2021

Copy link to clipboard

Copied

Hello,

 

There's no need to make adjustments to the script, just enter\change the Arrow lines offset to a negative number that

goes along with page height......example 12" page enter -12.125.

 

Edit: Disregard this post and go to the next one for a modified version of the script you requested.

 

Regards,

Mike

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Jun 15, 2021 Jun 15, 2021

Copy link to clipboard

Copied

Hello,

 

Below is a modified version of the script that puts the the dimensions and arrows at the bottom of the page.

 

property NumberGap : 25 --THIS IS THE GAP LEFT FOR THE NUMBER AND UNITS BETWEEN THE ARROWS (IN mm)

property WidthArrowOffset : -9

property HeightArrowOffset : 9

property LineThickness : 0.5

property FontSize : 12

property LineColour : "Black"

property SwatchNames : {}

property GlobalScale : 100

set TempSwatches to {}

set UnitsList to {"millimeters", "inches", "centimeters", "points", "pixels"}

set UnitsAbbreviations to {"mm", "\"", "cm", "pts", "px"}

set mmScaleList to {1, 0.0393701, 0.100000054, 2.83464, 2.83464}

 

tell application "Adobe InDesign 2021"

if (count of (every document)) is 0 then

display dialog "Please open a document and try this script again" buttons "OK" default button 1 giving up after 60

return

end if

--

set myRotateMatrix to make transformation matrix with properties {counterclockwise rotation angle:-90}

tell document 1

--GET NAMES OF SWATCHES

set SwatchNames to name of every swatch

repeat with i from 1 to (count SwatchNames)

set ThisSwatch to item i of SwatchNames

if ThisSwatch is not in {"None", "Paper"} then set the end of TempSwatches to ThisSwatch

end repeat

set SwatchNames to TempSwatches

--

set OrigRulerOrigin to ruler origin of view preferences

set ruler origin of view preferences to spread origin

set TypogPrefs to typographers quotes of text preferences

set typographers quotes of text preferences to false



--GET HORIZONTAL UNITS

set MyUnits to horizontal measurement units of view preferences

set MyUnits to MyUnits as string

set AbbrevPosition to my ListPosition(MyUnits, UnitsList)

if AbbrevPosition is not 0 then

set MyUnitsAbrev to item AbbrevPosition of UnitsAbbreviations

set mmScale to item AbbrevPosition of mmScaleList

else

set MyUnitsAbrev to ""

set mmScale to 0.3

end if



--ADVANCED DIALOG BOX

set MeasurementsChoice to my AdvancedIntroDialog(MyUnits)

if MeasurementsChoice is false then return



--MAKE NEW MEASUREMENTS LAYER

try

set MeasurementsLayer to layer "Measurements"

set locked of MeasurementsLayer to false

on error

set MeasurementsLayer to make layer with properties {name:"Measurements"}

end try



if the selection is {} then

set EveryPage to pages

set SelectedObjects to false

else

set EveryPage to the selection

set SelectedObjects to true

set ParentPage to parent page of item 1 of the selection

end if



repeat with i from 1 to (count of EveryPage)

set ThisPage to item i of EveryPage

try

set {PageY1, PageX1, PageY2, PageX2} to bounds of ThisPage

on error

set {PageY1, PageX1, PageY2, PageX2} to geometric bounds of ThisPage

end try

set PageWidth to PageX2 - PageX1

set PageHeight to PageY2 - PageY1

--

--Apply percentage to label only

set PageWidthString to PageWidth * 100 / GlobalScale

set PageHeightString to PageHeight * 100 / GlobalScale

set PageWidthString to (round (PageWidthString * 100)) / 100

set PageHeightString to (round (PageHeightString * 100)) / 100

if PageWidthString = PageWidthString as integer then set PageWidthString to PageWidthString as integer

if PageHeightString = PageHeightString as integer then set PageHeightString to PageHeightString as integer

--

set PageWidth to (round (PageWidth * 100)) / 100

set PageHeight to (round (PageHeight * 100)) / 100

if PageWidth = PageWidth as integer then set PageWidth to PageWidth as integer

if PageHeight = PageHeight as integer then set PageHeight to PageHeight as integer

--

set PageWidthString to (PageWidthString as string) & MyUnitsAbrev

set PageHeightString to (PageHeightString as string) & MyUnitsAbrev

--tell MeasurementsLayer

if MeasurementsChoice = 0 or MeasurementsChoice = 2 then --Top measurements or all measurements has been selected

if SelectedObjects then

--TOP MEASUREMENT OBJECTS

tell ParentPage

set MeasurementBox to make new text frame with properties {contents:PageWidthString, geometric bounds:{PageY2 - ((4) * mmScale), PageX1, PageY2 - ((WidthArrowOffset - 4) * mmScale), PageX2}, layer:MeasurementsLayer}

set properties of (parent story of MeasurementBox) to {justification:center align, point size:FontSize, applied font:"Arial", fill color:LineColour}

set vertical justification of text frame preferences of MeasurementBox to center align

make new graphic line with properties {stroke color:LineColour, stroke weight:LineThickness, geometric bounds:{PageY2 - (WidthArrowOffset * mmScale), PageX1 + (1 * mmScale), PageY2 - (WidthArrowOffset * mmScale), (PageX1 + ((PageWidth - (NumberGap * mmScale)) / 2))}, left line end:triangle wide arrow head, layer:MeasurementsLayer}

make new graphic line with properties {stroke color:LineColour, stroke weight:LineThickness, geometric bounds:{PageY2 - (WidthArrowOffset * mmScale), (PageX1 + (NumberGap * mmScale) + ((PageWidth - (NumberGap * mmScale)) / 2)), PageY2 - (WidthArrowOffset * mmScale), PageX2 - (1 * mmScale)}, right line end:triangle wide arrow head, layer:MeasurementsLayer}

end tell

else

--TOP MEASUREMENT PAGES

tell ThisPage

set MeasurementBox to make new text frame with properties {contents:PageWidthString, geometric bounds:{PageY2 - ((WidthArrowOffset + 4) * mmScale), PageX1, PageY2 - ((WidthArrowOffset - 4) * mmScale), PageX2}, layer:MeasurementsLayer}

set properties of (parent story of MeasurementBox) to {justification:center align, point size:FontSize, applied font:"Arial", fill color:LineColour}

set vertical justification of text frame preferences of MeasurementBox to center align

make new graphic line with properties {stroke color:LineColour, stroke weight:LineThickness, geometric bounds:{PageY2 - (WidthArrowOffset * mmScale), PageX1 + (1 * mmScale), PageY2 - (WidthArrowOffset * mmScale), (PageX1 + ((PageWidth - (NumberGap * mmScale)) / 2))}, left line end:triangle wide arrow head, layer:MeasurementsLayer}

make new graphic line with properties {stroke color:LineColour, stroke weight:LineThickness, geometric bounds:{PageY2 - (WidthArrowOffset * mmScale), (PageX1 + (NumberGap * mmScale) + ((PageWidth - (NumberGap * mmScale)) / 2)), PageY2 - (WidthArrowOffset * mmScale), PageX2 - (1 * mmScale)}, right line end:triangle wide arrow head, layer:MeasurementsLayer}

end tell

end if

end if

if MeasurementsChoice = 1 or MeasurementsChoice = 2 then --Side measurements or all measurements has been selected

if SelectedObjects then

--SIDE MEASUREMENT ON OBJECTS

tell ParentPage

set MeasurementBox to make new text frame with properties {contents:PageHeightString, geometric bounds:{PageY1 - ((HeightArrowOffset + 4) * mmScale), PageX1, PageY1 - ((HeightArrowOffset - 4) * mmScale), PageX2}, layer:MeasurementsLayer}

set properties of (parent story of MeasurementBox) to {justification:center align, point size:FontSize, applied font:"Arial", fill color:LineColour}

set vertical justification of text frame preferences of MeasurementBox to center align

transform MeasurementBox in pasteboard coordinates from center anchor with matrix myRotateMatrix

set geometric bounds of MeasurementBox to {PageY1, (PageX2 + ((HeightArrowOffset - 4) * mmScale)), PageY2, (PageX2 + ((HeightArrowOffset + 4) * mmScale))}

make new graphic line with properties {stroke color:LineColour, stroke weight:LineThickness, geometric bounds:{(PageY1 + (1 * mmScale)), PageX2 + (HeightArrowOffset * mmScale), (PageY1 + (PageHeight / 2) - ((NumberGap * mmScale) / 2)), PageX2 + (HeightArrowOffset * mmScale)}, left line end:triangle wide arrow head, layer:MeasurementsLayer}

make new graphic line with properties {stroke color:LineColour, stroke weight:LineThickness, geometric bounds:{(PageY2 - (PageHeight / 2) + ((NumberGap * mmScale) / 2)), PageX2 + (HeightArrowOffset * mmScale), (PageY2 - (1 * mmScale)), PageX2 + (HeightArrowOffset * mmScale)}, right line end:triangle wide arrow head, layer:MeasurementsLayer}

end tell

else

--SIDE MEASUREMENT ON PAGES

tell ThisPage

set MeasurementBox to make new text frame with properties {contents:PageHeightString, geometric bounds:{PageY1 - ((HeightArrowOffset + 4) * mmScale), PageX1, PageY1 - ((HeightArrowOffset - 4) * mmScale), PageX2}, layer:MeasurementsLayer}

set properties of (parent story of MeasurementBox) to {justification:center align, point size:FontSize, applied font:"Arial", fill color:LineColour}

set vertical justification of text frame preferences of MeasurementBox to center align

transform MeasurementBox in pasteboard coordinates from center anchor with matrix myRotateMatrix

set geometric bounds of MeasurementBox to {0, (PageX1 + PageWidth + ((HeightArrowOffset - 4) * mmScale)), (PageHeight), (PageX1 + PageWidth + ((HeightArrowOffset + 4) * mmScale))}

make new graphic line with properties {stroke color:LineColour, stroke weight:LineThickness, geometric bounds:{(PageY1 + (1 * mmScale)), PageX1 + PageWidth + (HeightArrowOffset * mmScale), ((PageHeight / 2) - ((NumberGap * mmScale) / 2)), PageX1 + PageWidth + (HeightArrowOffset * mmScale)}, left line end:triangle wide arrow head, layer:MeasurementsLayer}

make new graphic line with properties {stroke color:LineColour, stroke weight:LineThickness, geometric bounds:{((PageHeight / 2) + ((NumberGap * mmScale) / 2)), PageX1 + PageWidth + (HeightArrowOffset * mmScale), (PageY2 - (1 * mmScale)), PageX1 + PageWidth + (HeightArrowOffset * mmScale)}, right line end:triangle wide arrow head, layer:MeasurementsLayer}

end tell

end if

end if

end repeat

set typographers quotes of text preferences to TypogPrefs

set ruler origin of view preferences to OrigRulerOrigin

end tell

end tell

 

--SUBROUTINES

 

on AdvancedIntroDialog(MyUnits)

tell application "Adobe InDesign 2021"

if MyUnits is "millimeters" then

set EditUnits to millimeters

else if MyUnits is "inches" then

set EditUnits to inches

else if MyUnits is "centimeters" then

set EditUnits to centimeters

else

set EditUnits to pixels

end if

--UNITS EXPECTED FOR MEASUREMENT BOXES ARE ALWAYS POINTS (PIXELS)

set ConvertedOffset to HeightArrowOffset * 2.83464

set ConvertedNumGap to NumberGap * 2.83464

--

activate

set MyDialog to make dialog with properties {name:"Add measurements", can cancel:true}

tell MyDialog

tell (make dialog column with properties {min width:290})

--BORDER PANEL 1

tell (make border panel)

tell (make dialog column)

tell (make dialog row) to make static text with properties {static label:"Add measurements value to width and/or height of each page. ", min width:300}

tell (make dialog row)

set MeasurementsAnswer to make radiobutton group

tell MeasurementsAnswer

set OptionWidth to make radiobutton control with properties {static label:"Width (positioned at bottom of each page)"}

set OptionHeight to make radiobutton control with properties {static label:"Height (positioned on right hand side of each page"}

set OptionBoth to make radiobutton control with properties {static label:"Both width and height"}

set checked state of OptionWidth to true

end tell

end tell --End dialog row

end tell --End dialog column

end tell --End border panel

--BORDER PANEL 2

tell (make border panel)

tell (make dialog column)

make static text with properties {static label:"Arrow lines offset: "}

make static text with properties {static label:"Arrow lines thickness: "}

make static text with properties {static label:"Gap for number: "}

make static text with properties {static label:"Font size: "}

make static text with properties {static label:"Line colour: "}

make static text with properties {static label:"Artwork scaling:"}

end tell

tell (make dialog column)

set EditBoxOffset to make new measurement editbox with properties {edit value:ConvertedOffset, edit units:EditUnits, min width:106}

set EditBoxLineThick to make new measurement editbox with properties {edit value:LineThickness, edit units:points, min width:106}

set EditBoxNumGap to make new measurement editbox with properties {edit value:ConvertedNumGap, edit units:EditUnits, min width:106}

set EditTextSize to make new measurement editbox with properties {edit value:FontSize, edit units:points, min width:106}

set EditLineColour to make dropdown with properties {string list:SwatchNames, selected index:0, min width:106}

set EditGlobalScale to make new percent editbox with properties {edit value:GlobalScale}

end tell

tell (make dialog column)

make static text with properties {static label:"", min width:67}

end tell

end tell

end tell --End dialog column

end tell



--Show the dialog box



try

set MyResult to show MyDialog

set MeasurementsChoice to selected button of MeasurementsAnswer



-- OFFSET OF ARROW LINES

set NewOffset to edit value of EditBoxOffset

set NewOffset to NewOffset * 0.352778

if NewOffset ≠ HeightArrowOffset then set HeightArrowOffset to NewOffset



-- GAP FOR NUMBERS - VALUE RETURNED IN POINTS/PIXELS

set NewGap to edit value of EditBoxNumGap

set NewGap to NewGap * 0.352778

if NewGap ≠ NumberGap then set NumberGap to NewGap



-- THICKNESS OF ARROW LINES

set NewThick to edit value of EditBoxLineThick

--No conversion necessary for line thickness (points)

if NewThick ≠ LineThickness then --set LineThickness to NewThick

set LineThickness to NewThick

end if



--FONT SIZE

set NewFontWeight to edit value of EditTextSize

--No conversion necessary for line thickness (points)

if NewFontWeight ≠ FontSize then

set FontSize to NewFontWeight

end if



-- LINE COLOUR

set ChoiceLineColour to (selected index of EditLineColour) + 1

set LineColour to item ChoiceLineColour of SwatchNames

--



--PERCENTAGE

set GlobalScale to edit value of EditGlobalScale

--

on error ErrorMessage

display dialog ErrorMessage

destroy MyDialog

return false

end try

destroy MyDialog

--CHECK IF CANCELLED

if MyResult is false then

return false

else

return MeasurementsChoice

end if

end tell

end AdvancedIntroDialog

 

on ListPosition(this_item, this_list)

repeat with i from 1 to the count of this_list

if item i of this_list is this_item then return i

end repeat

return 0

end ListPosition

 

 

 

Regards,

Mike

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 16, 2021 Jun 16, 2021

Copy link to clipboard

Copied

LATEST

This is amazing. thank you very much 🙂

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines