• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

IDCS6 [Mac] - script to draw a rectangle that is the size of the bleed box

Community Expert ,
May 10, 2013 May 10, 2013

Copy link to clipboard

Copied

Hello there. I'm sure this is very easy to do but what i'm not sure of is how to get the size of the rectangle to be the size of the bleed box (from the top left to the bottom right) given that this script would be run on dozens of files that are all different page sizes.

Is there also any way to get the script (as the last thing it does) to launch the place command?

colly

If the answer wasn't in my post, perhaps it might be on my blog at colecandoo!
TOPICS
Scripting

Views

1.6K

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

Mentor , May 11, 2013 May 11, 2013

Hi,

I made it in a "too much" short way, sorry.

myDocument.documentPreferences.documentBleedTopOffset;

above should works if "myDocument" is your doc. Similar with other properties...

Jarek

Votes

Translate

Translate
Mentor ,
May 11, 2013 May 11, 2013

Copy link to clipboard

Copied

Hi,

If we talk about a single page this rectangle geometricBounds are:

     page.bounds[0] - documentBleedTopOffset,

     page.bounds[1] - documentBleedInsideOrLeftOffset,

     page.bounds[2] + documentBleedBottomOffset,

     page.bounds[3] + documentBleedOutsideOrRightOffset.

But you have to decide how to calculate it in case of spread (facing pages)

It could switch ruler origin to RulerOrigin.SPREAD_ORIGIN and modify a code:

     spread.pages[0].bounds[0] - documentBleedTopOffset,

     spread.pages[0].bounds[1] - documentBleedInsideOrLeftOffset,

     spread.pages[-1].bounds[2] + documentBleedBottomOffset,

     spread.pages[-1].bounds[3] + documentBleedOutsideOrRightOffset.

Another decision to made is what to do if there are various sizes of pages inside one spread

to launch a place command use:

app.menuActions.itemByID(113409).invoke();

(ID taken from CS5 Windows version)

rgds

Jarek

Votes

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
Community Expert ,
May 11, 2013 May 11, 2013

Copy link to clipboard

Copied

Thanks for that. I was able to come up with this:

main();

function main(){

    mySnippet();

    myTeardown();

}

function mySnippet(){

var myDocument = app.activeDocument;

var myPages = myDocument.pages;

var myPage = myPages.item(0);

var myBounds = myPage.bounds;

var myY1 = myBounds[0] - 5;

var myX1 = myBounds[1] - 5;

var myY2 = myBounds[2] + 5;

var myX2 = myBounds[3] + 5;

    var myRectangle = myPage.rectangles.add({geometricBounds:[myY1, myX1, myY2, myX2]});

app.menuActions.itemByID(113409).invoke();

}

function myTeardown(){

}

It works well, with two exceptions:

  1. the bleed in this script will always be 5. depending on the units used, this could be points or millimetres...; and
  2. the rectangle that is made is always the same fill and stroke as the fill/stroke in the palette at the time of running the script. is there any way of making the fill/stroke become none (apart from setting the fill/stroke to none prior to running the script)?
If the answer wasn't in my post, perhaps it might be on my blog at colecandoo!

Votes

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
Mentor ,
May 11, 2013 May 11, 2013

Copy link to clipboard

Copied

Hi,

In case of 2nd exception:

var myRectangle = myPage.rectangles.add({

     geometricBounds:[myY1, myX1, myY2, myX2],

     fillColor: app.swatches.item("None"),

     strokeWeight: 0

     });

Jarek

Votes

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
Community Expert ,
May 11, 2013 May 11, 2013

Copy link to clipboard

Copied

Close...

I substituted line 20 of the script to:

var myRectangle = myPage.rectangles.add({geometricBounds:[myY1, myX1, myY2, myX2], fillColor:myDocument.swatches.item("None"), strokeWeight: 0});

fillColor: app.swatches.item("None")

kept erroring in cs6;

fillColor:myDocument.swatches.item("None)

did the trick though.

now how to solve riddle part 1... hmmm....

If the answer wasn't in my post, perhaps it might be on my blog at colecandoo!

Votes

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
Mentor ,
May 11, 2013 May 11, 2013

Copy link to clipboard

Copied

Hi,

In case of exception no 1:

Why dont you use documentBleed(....)Offset properties?

(see post 1)

Jarek

Votes

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
Community Expert ,
May 11, 2013 May 11, 2013

Copy link to clipboard

Copied

hello again.

because that line of code didn't work. might in cs5, but not cs6. instead this error occurs:

Screen shot 2013-05-12 at 1.15.10 AM.png

If the answer wasn't in my post, perhaps it might be on my blog at colecandoo!

Votes

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
Mentor ,
May 11, 2013 May 11, 2013

Copy link to clipboard

Copied

Hi,

I made it in a "too much" short way, sorry.

myDocument.documentPreferences.documentBleedTopOffset;

above should works if "myDocument" is your doc. Similar with other properties...

Jarek

Votes

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
Community Expert ,
May 11, 2013 May 11, 2013

Copy link to clipboard

Copied

wonderful! the script now does what it needs to do. thank you for your help!

If the answer wasn't in my post, perhaps it might be on my blog at colecandoo!

Votes

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
Community Expert ,
May 24, 2013 May 24, 2013

Copy link to clipboard

Copied

not to complicate this script any further, but the script I made is perfect if the file is one page long. However, if I have a 20 page file and I want to execute this script on one the current page, where would I need to change the script? I figure it's the myPages bit, but unsure.

colly

If the answer wasn't in my post, perhaps it might be on my blog at colecandoo!

Votes

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
Mentor ,
May 24, 2013 May 24, 2013

Copy link to clipboard

Copied

Hi,

I am not sure finally how your script looks like...,

but you could change this line:

myPage = app.layoutWindows[0].activePage;

to refer to the current displayed page.

Jarek

Votes

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
Community Expert ,
May 24, 2013 May 24, 2013

Copy link to clipboard

Copied

LATEST

that did the trick! thank you very much.

If the answer wasn't in my post, perhaps it might be on my blog at colecandoo!

Votes

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