#target illustrator
if (app.documents.length !== 0) {
var doc = app.activeDocument;
if (doc.selection.length > 0) {
var obj = [];
for (var i = 0; i < doc.selection.length; i++) {obj[i] = doc.selection[i];};
doc.selection = false;
var tempLayer = doc.layers.add();
var tempGroup = doc.groupItems.add();
for (p=obj.length-1;p>=0;p--) {obj[p].duplicate(tempGroup);};
tempGroup.selected = true;
selectionStrokeWidth (0.000001);
var abIndex = doc.artboards.getActiveArtboardIndex();
var refgb = doc.artboards[abIndex].artboardRect;
doc.fitArtboardToSelectedArt(abIndex);
var gb = doc.artboards[abIndex].artboardRect;
doc.artboards[abIndex].artboardRect = refgb;
var newRect = doc.pathItems.rectangle (gb[1], gb[0], (gb[2]-gb[0]), (gb[1]-gb[3]));
try {
var newRectColor = doc.spots.getByName("OverallSizeColor").color;
} catch (e) {
var newColor = new CMYKColor();
newColor.cyan = 100;
newColor.magenta = 0;
newColor.yellow = 0;
newColor.black = 50;
var newSpot = doc.spots.add();
newSpot.name = "OverallSizeColor";
newSpot.colorType = ColorModel.SPOT;
newSpot.color = newColor;
var newRectColor = new SpotColor();
newRectColor.spot = newSpot;
};
var noColor = new NoColor();
newRect.strokeColor = newRectColor;
newRect.fillColor = noColor;
newRect.strokeWidth = 0.25;
try {
var layerOverallSize = doc.layers.getByName("OverallSize");
newRect.move(layerOverallSize, ElementPlacement.INSIDE);
tempLayer.remove();
} catch (e) { tempLayer.name = "OverallSize" }
tempGroup.remove();
} else {alert ("Нет выделенных объектов, миссия провалена :(")};
} else {alert('Нет открытых документов');};
function selectionStrokeWidth (w) {
//beginning Action Set==========================================
var ActionString = [ '/version 3',
'/name [ 9',
' 536372697074536574',
']',
'/isOpen 1',
'/actionCount 1',
'/action-1 {',
' /name [ 12',
' 536372697074416374696f6e',
' ]',
' /keyIndex 0',
' /colorIndex 0',
' /isOpen 1',
' /eventCount 1',
' /event-1 {',
' /useRulersIn1stQuadrant 0',
' /internalName (ai_plugin_setStroke)',
' /localizedName [ 10',
' 536574205374726f6b65',
' ]',
' /isOpen 0',
' /isOn 1',
' /hasDialog 0',
' /parameterCount 7',
' /parameter-1 {',
' /key 2003072104',
' /showInPalette -1',
' /type (unit real)',
' /value '+w,
' /unit 592476268',
' }',
' /parameter-2 {',
' /key 1667330094',
' /showInPalette -1',
' /type (enumerated)',
' /name [ 8',
' 4275747420436170',
' ]',
' /value 0',
' }',
' /parameter-3 {',
' /key 1836344690',
' /showInPalette -1',
' /type (real)',
' /value 10.0',
' }',
' /parameter-4 {',
' /key 1785686382',
' /showInPalette -1',
' /type (enumerated)',
' /name [ 10',
' 4d69746572204a6f696e',
' ]',
' /value 0',
' }',
' /parameter-5 {',
' /key 1684825454',
' /showInPalette -1',
' /type (integer)',
' /value 0',
' }',
' /parameter-6 {',
' /key 1684104298',
' /showInPalette -1',
' /type (boolean)',
' /value 0',
' }',
' /parameter-7 {',
' /key 1634494318',
' /showInPalette -1',
' /type (enumerated)',
' /name [ 6',
' 43656e746572',
' ]',
' /value 0',
' }',
' }',
'}'].join('\n');
//end Action Set================================================
var f = new File('~/ScriptSet.aia');
f.open('w');
f.write(ActionString);
f.close();
loadAction (f);
f.remove();
ActionString = null;
app.doScript("ScriptAction", "ScriptSet");
unloadAction("ScriptSet", "");
};