Hi Gary, Here's the revised code. Basically, if anything is selected, it will just margin the artboard around the selected items. I hope that I understood your objective properly. Hope this helps! 🙂 -TT -------------------------------------------------- AdjustArtboardSize(10, true); function AdjustArtboardSize(abMargin, useLongSideMargin) { var aDoc = activeDocument; var vb = new Array(); vb = aDoc.visibleBounds; if (app.activeDocument.selection.length > 0) vb = GetSelectionBounds(aDoc); var width = (vb[2] - vb[0]); // left-right var height = -(vb[3] - vb[1]); // bottom-top if (useLongSideMargin == true) { var margin = Math.max(width, height) * (abMargin / 100) + 36; // 36pts = .5" vb[0] -= margin; // left vb[1] += margin; // top vb[2] += margin; // right vb[3] -= margin; // bottom } else { vb[0] -= (width * (1 + abMargin / 100) - width); // left vb[1] += (height * (1 + abMargin / 100) - height); // top vb[2] += (width * (1 + abMargin / 100) - width); // right vb[3] -= (height * (1 + abMargin / 100) - height); // bottom } aDoc.artboards[0].artboardRect = vb; } function GetSelectionBounds(aDoc) { for (i = 0; i < aDoc.selection.length; i++) { var vb, tvb = aDoc.selection.visibleBounds; if (i == 0) { vb = tvb; } else { vb[0] = Math.min(vb[0], tvb[0]); vb[1] = Math.max(vb[1], tvb[1]); vb[2] = Math.max(vb[2], tvb[2]); vb[3] = Math.min(vb[3], tvb[3]); } } return vb; }
... View more