Skip to main content
Known Participant
February 14, 2023
Answered

anyone know of a script that will create interior crops?

  • February 14, 2023
  • 4 replies
  • 1755 views

anyone know of a script that will create interior crops like the attached? I have to create these many times a day manually, and a script would be a huge timesaver!

 

AI or INDD would work for me

This topic has been closed for replies.
Correct answer rob day

Hi @Kev28410820xkum , try this:

 

 

app.scriptPreferences.measurementUnit = MeasurementUnits.POINTS;
app.activeDocument.zeroPoint = [0, 0];
var ll = 12, //line length
    lt = 1, //line thickness
    p = app.activeWindow.activePage,
    pb = p.bounds,
    cl = makeLayer(app.activeDocument, "Crop Marks");

cl.move(LocationOptions.AT_BEGINNING);
app.activeDocument.activeLayer = cl;

//horizontal 
var myLine = makeLine(p,ll,lt,true)
myLine = makeLine(p,ll,lt,true);
myLine.move([pb[3]-ll,0]);
myLine = makeLine(p,ll,lt,true);
myLine.move([0,pb[2]-lt]);
myLine = makeLine(p,ll,lt,true);
myLine.move([pb[3]-ll,pb[2]-lt])

//vertical 
myLine = makeLine(p,ll,lt,false)
myLine = makeLine(p,ll,lt,false)
myLine.move([pb[3]-lt,0]);
myLine = makeLine(p,ll,lt,false);
myLine.move([0,pb[2]-ll]);
myLine = makeLine(p,ll,lt,false);
myLine.move([pb[3]-lt,pb[2]-ll])

app.scriptPreferences.measurementUnit = AutoEnum.AUTO_VALUE;

/**
* Make a graphic line 
* @ param page destination 
* @ param line length 
* @ param line thickness 
* @ param true horizontal or false vertical 
* @ return the line 
*
*/
function makeLine(p,l,t,h){
    var ln = p.graphicLines.add({strokeColor:"Black", strokeWeight:t});
    if (h) {
        ln.geometricBounds = [0,0,0,l];
        ln.strokeAlignment=StrokeAlignment.INSIDE_ALIGNMENT;
    } else {
        ln.geometricBounds = [0,0,l,0]
        ln.strokeAlignment=StrokeAlignment.OUTSIDE_ALIGNMENT;
    }
    return ln
}


/**
* Makes a new named Layer 
* @ param the document to add the layer 
* @ param layer name 
* @ return the new layer 
*/

function makeLayer(d, n){
    if (d.layers.itemByName(n).isValid) {
        return d.layers.itemByName(n);
    } else {
        return d.layers.add({name:n});
    }
}

 

4 replies

rob day
Community Expert
rob dayCommunity ExpertCorrect answer
Community Expert
February 16, 2023

Hi @Kev28410820xkum , try this:

 

 

app.scriptPreferences.measurementUnit = MeasurementUnits.POINTS;
app.activeDocument.zeroPoint = [0, 0];
var ll = 12, //line length
    lt = 1, //line thickness
    p = app.activeWindow.activePage,
    pb = p.bounds,
    cl = makeLayer(app.activeDocument, "Crop Marks");

cl.move(LocationOptions.AT_BEGINNING);
app.activeDocument.activeLayer = cl;

//horizontal 
var myLine = makeLine(p,ll,lt,true)
myLine = makeLine(p,ll,lt,true);
myLine.move([pb[3]-ll,0]);
myLine = makeLine(p,ll,lt,true);
myLine.move([0,pb[2]-lt]);
myLine = makeLine(p,ll,lt,true);
myLine.move([pb[3]-ll,pb[2]-lt])

//vertical 
myLine = makeLine(p,ll,lt,false)
myLine = makeLine(p,ll,lt,false)
myLine.move([pb[3]-lt,0]);
myLine = makeLine(p,ll,lt,false);
myLine.move([0,pb[2]-ll]);
myLine = makeLine(p,ll,lt,false);
myLine.move([pb[3]-lt,pb[2]-ll])

app.scriptPreferences.measurementUnit = AutoEnum.AUTO_VALUE;

/**
* Make a graphic line 
* @ param page destination 
* @ param line length 
* @ param line thickness 
* @ param true horizontal or false vertical 
* @ return the line 
*
*/
function makeLine(p,l,t,h){
    var ln = p.graphicLines.add({strokeColor:"Black", strokeWeight:t});
    if (h) {
        ln.geometricBounds = [0,0,0,l];
        ln.strokeAlignment=StrokeAlignment.INSIDE_ALIGNMENT;
    } else {
        ln.geometricBounds = [0,0,l,0]
        ln.strokeAlignment=StrokeAlignment.OUTSIDE_ALIGNMENT;
    }
    return ln
}


/**
* Makes a new named Layer 
* @ param the document to add the layer 
* @ param layer name 
* @ return the new layer 
*/

function makeLayer(d, n){
    if (d.layers.itemByName(n).isValid) {
        return d.layers.itemByName(n);
    } else {
        return d.layers.add({name:n});
    }
}

 

Known Participant
July 26, 2023

that was SO helpful! Thanks - unfortunately, none of my custom script seem to work now - I've no idea what happened. I'm using INDD 18.4 

rob day
Community Expert
Community Expert
July 26, 2023

Hi @Kev28410820xkum , Do you mean when you run the script from the scripts panel you get an error, or nothing happens? If it’s an error can you show the error alert?

rob day
Community Expert
Community Expert
February 15, 2023

Hi @Kev28410820xkum , Are the crop marks there as a guide for trimming? If they are, the crops you are showing in the capture would be visible after the page is trimmed—normally they would be offset from the page.

brian_p_dts
Community Expert
Community Expert
February 14, 2023

Just draw it on your parent page(s)

Brito Haroldo
Inspiring
February 14, 2023

Hi @Kev28410820xkum do you need this in 4 corners the page, is this?

Known Participant
February 14, 2023
Yep in all four corners
Loic.Aigon
Legend
February 14, 2023

What kind of projects do you work on? The fact that either ID or AI scripting is convenient for you is the source of my questions. Is it some kind of PDF imposition and marks for some cutter? I am asking because there may be more appropriate solutions for your true needs.