Copy link to clipboard
Copied
I am looking for some help on trying to make an object the exact size of the artboard. This is something I do on a daily basis for several different reasons and it would be very helpful if this can happen automatically for whatever size the artboard may be. As I understand it the only way is with a script but I have no experience with making illustrator scripts, im definately no programmer. I have set up quickkeys in the past to copy from the artboard inputs when you are on the artboard tool but these round to the nearest .01 and this is not accurate enough for what I am working with. Also if I do this with multiple pages open illustrator is very slow to respond to the artboard tool. If anyone has any idea where to start or has seen other such scripts I would greatly appreciate it. Thank you.
Below is a script that I saw on here that I believe may contain what I need but now knowing programming I have no idea where to start on editing. All I need is the part where an object is placed on the artboard that is the exact same size as the artboard. If anyone can advise on editing I would greatly apprecaite it.
#target illustrator function main() { if (app.documents.length == 0) { alert('Open a document before running this script'); return; // Stop script here no doc open… } else { var docRef = app.activeDocument; with (docRef) { if (selection.length == 0) { alert('No items are selected…'); return; // Stop script here with no selection… } if (selection.length > 1) { alert('Too many items are selected…'); return; // Stop script here with selection Array… } else { var selVB = selection[0].visibleBounds; var rectTop = selVB[1] + 36; var rectLeft = selVB[0] - 36; var rectWidth = (selVB[2] - selVB[0]) + 72; var rectHeight = (selVB[1] - selVB[3]) + 72; selection[0].parent.name = 'CC'; selection[0].filled = false; selection[0].stroked = true; var ccColor = cmykColor(0, 100, 0, 0); var ccCol = spots.add() ccCol.name = 'CC'; ccCol.color = ccColor; ccCol.tint = 100; ccCol.colorType = ColorModel.SPOT; var cc = new SpotColor(); cc.spot = ccCol; selection[0].strokeColor = cc; selection[0].strokeWidth = 1; var tcLayer = layers.add(); tcLayer.name = 'TC'; var padBox = pathItems.rectangle(rectTop, rectLeft, rectWidth, rectHeight, false); padBox.stroked = false; padBox.filled = true; var tcColor = cmykColor(0, 100, 90, 0); var tcCol = spots.add() tcCol.name = 'TC'; tcCol.color = tcColor; tcCol.tint = 100; tcCol.colorType = ColorModel.SPOT; var tc = new SpotColor(); tc.spot = tcCol; padBox.fillColor = tc; padBox.move(docRef, ElementPlacement.PLACEATEND); artboards[0].artboardRect = (padBox.visibleBounds); redraw(); rectWidth = (rectWidth-72)/72; rectWidth = roundToDP(rectWidth,1); rectHeight = (rectHeight-72)/72; rectHeight = roundToDP(rectHeight,1); var textString = rectWidth + ' x ' + rectHeight; prompt('Copy Me', textString); } } }} main(); function roundToDP(nbr, dP) { dpNbr = Math.round(nbr*Math.pow(10,dP))/Math.pow(10,dP); return dpNbr;} function cmykColor(c, m, y, k) { var newCMYK = new CMYKColor(); newCMYK.cyan = c; newCMYK.magenta = m; newCMYK.yellow = y; newCMYK.black = k; return newCMYK;}
1 Correct answer
here you go, select one object before running, if your art has more than one object, make a group first.
...#target Illustrator
// script.name = fitObjectToArtboardBounds.jsx;
// script.description = resizes selected object to fit exactly to Active Artboard Bounds;
// script.required = select ONE object before running; CS4 & CS5 Only.
// script.parent = carlos canto // 01/25/12;
// script.elegant = false;
var idoc = app.activeDocument;
selec = idoc.selection;
if (selec.length==1)
{
Explore related tutorials & articles
Copy link to clipboard
Copied
This stuff doesn't work for me. Maybe it's because I'm using CS2. I wish someting worked for me.
Copy link to clipboard
Copied
Object with clipping mask
This script will get an error
There is no correct equal to the size of the artboa


-
- 1
- 2