Highlighted

Arboards in navigator and rotation features

Community Beginner ,
Aug 01, 2018

Copy link to clipboard

Copied

When I work with multiple artboards that are large, it's annoying to see all of the artboards because then I can't focus on a few artboards or just one so that i can see how it looks like when it is small. It would be also cool to be able to rotate artboards as well. I know photoshop has the r hotkey to rotate, so a feature like that on Illustrator would be cool.

Topics

Scripting

Views

311

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

Arboards in navigator and rotation features

Community Beginner ,
Aug 01, 2018

Copy link to clipboard

Copied

When I work with multiple artboards that are large, it's annoying to see all of the artboards because then I can't focus on a few artboards or just one so that i can see how it looks like when it is small. It would be also cool to be able to rotate artboards as well. I know photoshop has the r hotkey to rotate, so a feature like that on Illustrator would be cool.

Topics

Scripting

Views

312

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
Participant ,
Aug 03, 2018

Copy link to clipboard

Copied

If I get you right, as for the rotation of the artboard, there is a solution:

// Artboards_Rotate_With_Objects.jsx for Adobe Illustrator

// Description: A script to rotate 90 degrees an active artboard with all the objects on it.

// Requirements: Adobe Illustrator CS6 and above

// Date: July, 2018

// Authors: Alexander Ladygin, email: i@ladygin.pro

// Sergey Osokin, email: hi@sergosokin.ru

// ============================================================================

// Installation:

// 1. Place script in:

// Win (32 bit): C:\Program Files (x86)\Adobe\Adobe Illustrator [vers.]\Presets\en_GB\Scripts\

// Win (64 bit): C:\Program Files\Adobe\Adobe Illustrator [vers.] (64 Bit)\Presets\en_GB\Scripts\

// Mac OS: <hard drive>/Applications/Adobe Illustrator [vers.]/Presets.localized/en_GB/Scripts

// 2. Restart Illustrator

// 3. Choose File > Scripts > Artboards_Rotate_With_Objects

// ============================================================================

// NOTICE:

// Tested with Adobe Illustrator CC 2017/2018 (Mac).

// This script is provided "as is" without warranty of any kind.

// Free to use, not for sale.

// ============================================================================

// Released under the MIT license.

// http://opensource.org/licenses/mit-license.php


#target illustrator

app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;


var scriptName = 'ARWO',

   scriptVersion = '0.2';


try {

   if (documents.length > 0) {

   var doc = app.activeDocument,

   currArt = doc.artboards[doc.artboards.getActiveArtboardIndex()],

   currArtNum = doc.artboards.getActiveArtboardIndex() + 1,

   lockedItems = new Array(),

   hiddenItems = new Array();


   // Create Main Window

   var dlg = new Window('dialog', scriptName + ' ver.' + scriptVersion, undefined);

   dlg.orientation = "column";

   dlg.alignChildren = ["fill", "fill"];


   // Target radiobutton

   var slctTarget = dlg.add("panel", undefined, "What to rotate?");

   slctTarget.orientation = "column";

   slctTarget.alignChildren = ["fill", "fill"];

   slctTarget.margins = 20;

   var currArtRadio = slctTarget.add('radiobutton', undefined, "Active Artboard: #" + currArtNum),

   allArtRadio = slctTarget.add('radiobutton', undefined, "All " + doc.artboards.length + " Artboards");

   currArtRadio.value = true;


   // Angle radiobutton

   var slctAngle = dlg.add("panel", undefined, "Rotation angle:");

   slctAngle.orientation = "row";

   slctAngle.alignChildren = ["fill", "fill"];

   slctAngle.margins = 20;

   var cwAngle = slctAngle.add('radiobutton', undefined, "90 CW"),

   ccwAngle = slctAngle.add('radiobutton', undefined, "90 CCW");

   cwAngle.value = true;


   // Buttons

   var btns = dlg.add('group');

   btns.alignChildren = 'center';

   btns.margins = [0, 10, 0, 0];

   var cancel = btns.add('button', undefined, "Cancel");

   cancel.helpTip = "Press Esc to Close";

   var ok = btns.add('button', undefined, "OK");

   ok.helpTip = "Press Enter to Run";

   ok.active = true;

   cancel.onClick = function () { dlg.close(); }

   ok.onClick = okClick;


   dlg.center();

   dlg.show();


   //Start

   function okClick() {

   // Saving information about locked & hidden pageItems

   saveItemsState();

   // Rotate active artboard or all artboards in document

   if (currArtRadio.value == true) {

   rotateArt(currArt);

   } else {

   for (var i = 0; i < doc.artboards.length; i++) {

   doc.artboards.setActiveArtboardIndex(i);

   rotateArt(doc.artboards);

   }

   }

   // Restoring locked & hidden pageItems

   restoreItemsState();

   dlg.close();

   }

   } else {

   throw new Error(scriptName + "\nPlease open a document before running this script.");

   }

} catch (e) {

   alert(e.message, 'Script Alert', true);

}


// Save information about locked & hidden pageItems

function saveItemsState() {

   for (var i = 0; i < doc.pageItems.length; i++) {

   var currItem = doc.pageItems;

   if (currItem.locked == true) {

   lockedItems.push(i);

   currItem.locked = false;

   }

   if (currItem.hidden == true) {

   hiddenItems.push(i);

   currItem.hidden = false;

   }

   }

}


// Restoring locked & hidden pageItems

function restoreItemsState() {

   for (var i = 0; i < lockedItems.length; i++) {

   var index = lockedItems;

   doc.pageItems[index].locked = true;

   }

   for (var j = 0; j < hiddenItems.length; j++) {

   var index = hiddenItems;

   doc.pageItems[index].hidden = true;

   }

}


// Main function for rotate artboard

function rotateArt(board) {

   var artRect = board.artboardRect,

   artWidth = artRect[2] - artRect[0],

   artHeight = -(artRect[3] - artRect[1]);

   deselect();

   doc.selectObjectsOnActiveArtboard();


   // Rotate artboard

   var newArtRect = [

   artRect[0] + artWidth / 2 - (artHeight / 2),

   artRect[1] - artHeight / 2 + (artWidth / 2),

   artRect[2] - artWidth / 2 + (artHeight / 2),

   artRect[3] + artHeight / 2 - (artWidth / 2)

   ];

   board.artboardRect = newArtRect;


   // Rotate objects

   for (var k = 0; k < selection.length; k++) {

   var bnds = selection.geometricBounds,

   top = bnds[1] - artRect[1],

   right = bnds[2] - artRect[2],

   left = bnds[0] - artRect[0],

   bottom = bnds[3] - artRect[3];

   // selection.rotate(90);

   if (cwAngle.value == true) {

   // rotate 90 CW

   selection.rotate(-90);

   selection.left = newArtRect[0] + bottom;

   selection.top = newArtRect[1] - left;

   } else {

   // rotate 90 CCW

   selection.rotate(90);

   selection.left = newArtRect[0] - top;

   selection.top = newArtRect[1] + right;

   }

   }

   deselect();

}


function deselect() {

   activeDocument.selection = null;

}

Likes

1 Like

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...
Resources
Add a group