Copy link to clipboard
Copied
Hi all you big brains.
I know nothing about scripting but I've managed to amend a script an old work collegue did for me many moons ago. I need to be able to add the bleed amounts to the relevant parts of a slug made from a table:
I have text variables for the Ref (file name), Mod dates, Mod by and have a script for the width and height inputs:
If anyone could tell me what to add and where, I would be extremely grateful and send you a virtual donut.
Hi @Mayberry_Maybz,
Give this a try....
// WORKING ON CURRENT DOCUMENT
var myDocument = app.activeDocument;
// INITIAL SETTINGS
myDocument.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;
myDocument.zeroPoint=[0,0];
myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.MILLIMETERS;
myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.MILLIMETERS;
// WORKING WITH ACTIVE PAGE
var currentPage = myDocument.layoutWindows[0].activePage;
var width, height; //
...
Copy link to clipboard
Copied
Hello @Mayberry_Maybz
Can you post a InDesign document that only contains the slug made from the table for testing purposes?
I just want to make sure I'm getting the correlating bleed settings into the correct cells.
Regards,
MIke
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Hello @Mayberry_Maybz
Here you go...enjoy!!
// WORKING ON CURRENT DOCUMENT
var myDocument = app.activeDocument;
// INITIAL SETTINGS
myDocument.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;
myDocument.zeroPoint=[0,0];
myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.MILLIMETERS;
myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.MILLIMETERS;
// WORKING WITH ACTIVE PAGE
var currentPage = myDocument.layoutWindows[0].activePage;
var width, height; // SOME VARIABLES
// GETTING THE PAGE SIZES
width = currentPage.bounds[3] - currentPage.bounds[1];
height = currentPage.bounds[2] - currentPage.bounds[0];
// ROUND THE NUMBERS
var widthRounded = width.toFixed(2);
var heightRounded = height.toFixed(2);
var realHeight = heightRounded*10;
var realWidth = widthRounded*10;
var myLeftBleed = myDocument.documentPreferences.documentBleedInsideOrLeftOffset;
var myRightBleed = myDocument.documentPreferences.documentBleedOutsideOrRightOffset;
var myTopBleed = myDocument.documentPreferences.documentBleedTopOffset;
var myBottomBleed = myDocument.documentPreferences.documentBleedBottomOffset;
var ShowType;
// WORKING WITH TABLES ON THE ACTIVE PAGE
var myTables = app.layoutWindows[0].activePage.textFrames.everyItem().tables;
// show row and column of selected cell
//alert(app.selection[0].parentRow.index+"\n"+app.selection[0].parentColumn.index);
// CHECK IF THERE IS THE SLUG IN THE DOCUMENT
if(myTables.length>0)
{
ShowType = "ORG-GARTNER";
// PLACE THE SIZES IN THE SLUG
myTables[0].cells[12].contents = ("" + realWidth);
myTables[0].cells[13].contents = ("" + realHeight);
// PLACE THE BLEED SIZES IN THE SLUG
myTables[0].cells[15].contents = ("Left: " + myLeftBleed);
myTables[0].cells[16].contents = ("Right: " + myRightBleed);
myTables[0].cells[17].contents = ("Top: " + myTopBleed);
myTables[0].cells[18].contents = ("Bottom: " + myBottomBleed);
}
Oh yeah, I like chocolate glazed....
Regards,
Mike
Copy link to clipboard
Copied
Wow Mike, amazing work.
Now, I feel like i'm pushing it a bit but as the slug says, the document is at 10%. So when I use the script with your addition, it inputs the amount as is. I know there is part of the script for the page size that deals with this:
var realHeight = heightRounded*10;
var realWidth = widthRounded*10;
so is there a way to deal with this for the bleed? I've had a go, but with my limited knowledge, failed. The reason for this is exhibition graphics sometimes go waaaay past InDesigns page limit. I will use your answer for the other variations: 25% - 50% and 100%.
Much love
Maybz
Copy link to clipboard
Copied
Hello @Mayberry_Maybz,
Sorry, I don't think I've had enough coffee yet with my donut. I'm not really sure on what you're asking for...
Regards,
Mike
Copy link to clipboard
Copied
Sorry my man,
In the template, the page size of the document is set up as 400mm x 250mm, but the script makes the slug entry 4000 x 2500 because the code above that has *10 multiplies by 10.
The new part you added for bleed enters the numbers at s/s so instead of saying 100mm bleed, it will enter the number as 10. I wondered if there was a way of applying that *10 to the bleed output to make the correct size show.
Hope that makes sense
Many thanks
Maybz
Copy link to clipboard
Copied
Hi @Mayberry_Maybz,
Give this a try....
// WORKING ON CURRENT DOCUMENT
var myDocument = app.activeDocument;
// INITIAL SETTINGS
myDocument.viewPreferences.rulerOrigin = RulerOrigin.PAGE_ORIGIN;
myDocument.zeroPoint=[0,0];
myDocument.viewPreferences.horizontalMeasurementUnits = MeasurementUnits.MILLIMETERS;
myDocument.viewPreferences.verticalMeasurementUnits = MeasurementUnits.MILLIMETERS;
// WORKING WITH ACTIVE PAGE
var currentPage = myDocument.layoutWindows[0].activePage;
var width, height; // SOME VARIABLES
// GETTING THE PAGE SIZES
width = currentPage.bounds[3] - currentPage.bounds[1];
height = currentPage.bounds[2] - currentPage.bounds[0];
// ROUND THE NUMBERS
var widthRounded = width.toFixed(2);
var heightRounded = height.toFixed(2);
var realHeight = heightRounded*10;
var realWidth = widthRounded*10;
var myLeftBleed = myDocument.documentPreferences.documentBleedInsideOrLeftOffset*10;
var myRightBleed = myDocument.documentPreferences.documentBleedOutsideOrRightOffset*10;
var myTopBleed = myDocument.documentPreferences.documentBleedTopOffset*10;
var myBottomBleed = myDocument.documentPreferences.documentBleedBottomOffset*10;
var ShowType;
// WORKING WITH TABLES ON THE ACTIVE PAGE
var myTables = app.layoutWindows[0].activePage.textFrames.everyItem().tables;
// show row and column of selected cell
//alert(app.selection[0].parentRow.index+"\n"+app.selection[0].parentColumn.index);
// CHECK IF THERE IS THE SLUG IN THE DOCUMENT
if(myTables.length>0)
{
ShowType = "ORG-GARTNER";
// PLACE THE SIZES IN THE SLUG
myTables[0].cells[12].contents = ("" + realWidth);
myTables[0].cells[13].contents = ("" + realHeight);
// PLACE THE BLEED SIZES IN THE SLUG
myTables[0].cells[15].contents = ("Left: " + myLeftBleed);
myTables[0].cells[16].contents = ("Right: " + myRightBleed);
myTables[0].cells[17].contents = ("Top: " + myTopBleed);
myTables[0].cells[18].contents = ("Bottom: " + myBottomBleed);
}
Regards,
Mike
Copy link to clipboard
Copied
You absolute ledge Mike.
Seriously spot-on. You have made my life immensely more productive. Honestly can't thank you enough.
Give this man a raise!
Thanks again.
Maybz