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

Script to reduce the size of artboard to the size of the artwork

Explorer ,
Mar 03, 2022 Mar 03, 2022

Copy link to clipboard

Copied

Hello All,

 

I need a script to reduce the size of the artboard to the size of the artwork. All the items in the artwork are grouped.

Whether it is possible to do with script. If possible, please some help me to figure out the script.

 

Example images:

VaithiyanathanJ_0-1646324276376.pngVaithiyanathanJ_1-1646324301241.png

Regards,

Vaithiyanathan J

TOPICS
Scripting

Views

281

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
Adobe
Participant ,
Mar 03, 2022 Mar 03, 2022

Copy link to clipboard

Copied

hey @Surya24 

check this!

 

var i, ii, doc, count, itemList, countArtboards, artboardIndex;
doc = app.activeDocument;
countArtboards = doc.artboards.length;

for (ii = countArtboards-1; ii >= 0; ii--) {
  artboardIndex = doc.artboards.setActiveArtboardIndex(ii);
  doc.selectObjectsOnActiveArtboard();
  app.executeMenuCommand ("Fit Artboard to selected Art");
  }
  app.executeMenuCommand ("fitall");
doc.selection = null;
app.redraw();

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
Explorer ,
Mar 03, 2022 Mar 03, 2022

Copy link to clipboard

Copied

Hello GerssonDelgado,

 

Thanks for the script, one small thing while artboard resizing, the aboard size was not exactly matching with size of artwork.

 

For Example:

Artwork size is width = 2.64" and height = 1.14". while am running the script the artboard size was increased to width = 2.65" and height = 1.15" not exactly matching the size. any option to match exact size.

 

Note: 0.01" additionally added to width and height of artboard size.

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 ,
Mar 03, 2022 Mar 03, 2022

Copy link to clipboard

Copied

Is by any chance Use Preview Bounds checked in your AI Preferences? If it is, try it without this being checked.

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 ,
Mar 03, 2022 Mar 03, 2022

Copy link to clipboard

Copied

You know there's a command for this in Illy right?

I have it set with a keyboard short cut, I use it many times a day...

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
Guide ,
Mar 03, 2022 Mar 03, 2022

Copy link to clipboard

Copied

An alternative approach (I don't know if it will prove any better):

 

// select items
app.executeMenuCommand("group");
var group = app.activeDocument.selection[0];
var AB = app.activeDocument.artboards[0]
AB.artboardRect = [
    group.left, group.top,
    group.left + group.width, group.top - group.height
];
app.executeMenuCommand("ungroup");

 

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 ,
Mar 03, 2022 Mar 03, 2022

Copy link to clipboard

Copied

LATEST

you can try using executeMenuCommand() with one of the following arguments:

"Fit Artboard to artwork bounds"

or

"Fit Artboard to selected Art"

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