Highlighted

Trying to expand my artboard and make a border in JavaScript

Participant ,
May 23, 2020

Copy link to clipboard

Copied

I feel like I can figure this out, but that it might also take days.  I have a script that's changing the size of the artboard which seems to work just fine.  But what I also want is a border of the old artboard size and also one for the new arboard size.


Here's a screenshot of my attempt, which is not working except for the artboard changing.  I might be missing a layer reference? I'm not sure.  I'm trying two different ways,... setEntirePath and Rectangle and neither seem to work.  I might be pretty far off on more than one front, unfortunately I started this a few years ago, and I'm now getting back into it.  Jumping back in instead of starting fresh might have been a mistake.

 

423.png

 

The bottom 3 lines are newer lines I've recently added that don't work, the top 5 lines do seem to work.

Most Valuable Participant
Correct answer by pixxxelschubser | Most Valuable Participant

Hi @Maple_Stirrup,

if I understand you right:

 

// draw a rectangle around the active artboard, enlarge this artboard, draw a second rectangle around the new artboard size
// regards pixxxelschubser

var aDoc = app.activeDocument;
var AB = aDoc.artboards;
var abIdx = AB.getActiveArtboardIndex ();
var oldAB = AB[abIdx].artboardRect;

var old_rect = aDoc.pathItems.rectangle (oldAB[1], oldAB[0], (oldAB[2]-oldAB[0]), (oldAB[1]-oldAB[3]));
old_rect.name = "old Artboard size";

AB[abIdx].artboardRect = [(oldAB[0]-72), (oldAB[1]+72), (oldAB[2]+72), (oldAB[3]-72)];
var newAB = AB[abIdx].artboardRect;
var new_rect = aDoc.pathItems.rectangle (newAB[1], newAB[0], (newAB[2]-newAB[0]), (newAB[1]-newAB[3]));
new_rect.name = "new Artboard size";

 

 

 

If that works for you

have fun

😉

TOPICS
Scripting

Views

774

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

Trying to expand my artboard and make a border in JavaScript

Participant ,
May 23, 2020

Copy link to clipboard

Copied

I feel like I can figure this out, but that it might also take days.  I have a script that's changing the size of the artboard which seems to work just fine.  But what I also want is a border of the old artboard size and also one for the new arboard size.


Here's a screenshot of my attempt, which is not working except for the artboard changing.  I might be missing a layer reference? I'm not sure.  I'm trying two different ways,... setEntirePath and Rectangle and neither seem to work.  I might be pretty far off on more than one front, unfortunately I started this a few years ago, and I'm now getting back into it.  Jumping back in instead of starting fresh might have been a mistake.

 

423.png

 

The bottom 3 lines are newer lines I've recently added that don't work, the top 5 lines do seem to work.

Most Valuable Participant
Correct answer by pixxxelschubser | Most Valuable Participant

Hi @Maple_Stirrup,

if I understand you right:

 

// draw a rectangle around the active artboard, enlarge this artboard, draw a second rectangle around the new artboard size
// regards pixxxelschubser

var aDoc = app.activeDocument;
var AB = aDoc.artboards;
var abIdx = AB.getActiveArtboardIndex ();
var oldAB = AB[abIdx].artboardRect;

var old_rect = aDoc.pathItems.rectangle (oldAB[1], oldAB[0], (oldAB[2]-oldAB[0]), (oldAB[1]-oldAB[3]));
old_rect.name = "old Artboard size";

AB[abIdx].artboardRect = [(oldAB[0]-72), (oldAB[1]+72), (oldAB[2]+72), (oldAB[3]-72)];
var newAB = AB[abIdx].artboardRect;
var new_rect = aDoc.pathItems.rectangle (newAB[1], newAB[0], (newAB[2]-newAB[0]), (newAB[1]-newAB[3]));
new_rect.name = "new Artboard size";

 

 

 

If that works for you

have fun

😉

TOPICS
Scripting

Views

775

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
May 23, 2020 0
Adobe Community Professional ,
May 23, 2020

Copy link to clipboard

Copied

If you paste your script text into the thread instead of a screen image others may be more apt to help since they can work with what you have.

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
Reply
Loading...
May 23, 2020 1
Participant ,
May 24, 2020

Copy link to clipboard

Copied

Thanks, I forget.. if you copy paste from ESTK, does it automatically format the text for you here to match how it looks there, or do you have copy it a special way to do that?

 

Also compltely unrelated to that, is it possible to turn off the ESTK chime when it runs into a compiling problem?

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
Reply
Loading...
May 24, 2020 0
Adobe Community Professional ,
May 23, 2020

Copy link to clipboard

Copied

you can't add pathItems to artboards, change that to document or layer

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
Reply
Loading...
May 23, 2020 1
Most Valuable Participant ,
May 23, 2020

Copy link to clipboard

Copied

Hi @Maple_Stirrup,

if I understand you right:

 

// draw a rectangle around the active artboard, enlarge this artboard, draw a second rectangle around the new artboard size
// regards pixxxelschubser

var aDoc = app.activeDocument;
var AB = aDoc.artboards;
var abIdx = AB.getActiveArtboardIndex ();
var oldAB = AB[abIdx].artboardRect;

var old_rect = aDoc.pathItems.rectangle (oldAB[1], oldAB[0], (oldAB[2]-oldAB[0]), (oldAB[1]-oldAB[3]));
old_rect.name = "old Artboard size";

AB[abIdx].artboardRect = [(oldAB[0]-72), (oldAB[1]+72), (oldAB[2]+72), (oldAB[3]-72)];
var newAB = AB[abIdx].artboardRect;
var new_rect = aDoc.pathItems.rectangle (newAB[1], newAB[0], (newAB[2]-newAB[0]), (newAB[1]-newAB[3]));
new_rect.name = "new Artboard size";

 

 

 

If that works for you

have fun

😉

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
Reply
Loading...
May 23, 2020 2
Participant ,
May 24, 2020

Copy link to clipboard

Copied

Thanks!

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
Reply
Loading...
May 24, 2020 0