Copy link to clipboard
Copied
Hi, I wondered if anybody has a script that can copy just what is contained inside the bounds of your current artboard to the Windows clipboard? Thanks
Copy link to clipboard
Copied
... to do what afterwards?
Please explain this in more detail.
At the moment I think:
select all in active artboard
and
copy
should be sufficient enough.
Or not?
Copy link to clipboard
Copied
Hi, thanks for the reply. I want it to be cropped at the bounds of the artboard. I also want it loaded to the clipboard as a jpeg. As for ... to do what afterwards? I want to use the clipboard in another program?
Copy link to clipboard
Copied
Salut!
Si j'ai bien compris...
// JavaScript Document for Illustrator
var doc = app.activeDocument;
with(doc) {
selectObjectsOnActiveArtboard();
fitArtboardToSelectedArt( artboards.getActiveArtboardIndex() );
}
app.copy();
Copy link to clipboard
Copied
Hi, thanks so much for trying. I do not want to move the artboard to encase the art. I want to use the Artboard as a crop for what Is shown. What you wrote moves the artboard to the art. If a piece of art is outside of the artboard I want it cropped (not included) in what is copied as a jpeg.
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Would this help you? It saves artboard 0 to a png file to your computer.
Save_PNG('local file path here/', 'test2.png');
function Save_PNG(SaveLocal, fileName) {
var aDoc = app.activeDocument;
var MyOpt = new ImageCaptureOptions;
var myBounds = aDoc.artboards[0];
myBounds.fillColor = aDoc.swatches[0].color;
MyOpt.antiAliasing = true;
MyOpt.matte = false;
MyOpt.resolution = 300; // screen PPI
MyOpt.transparency = false;
var Filename = new File(SaveLocal + fileName);
aDoc.imageCapture(Filename, myBounds.visibleBounds, MyOpt);
}
Copy link to clipboard
Copied
I already have a good script that does that. I find it too much trouble to go and retrieve the file every time. I want art that I shift around on a page to be quickly copied. I also want to be cropped by the artboard. Thank you for the additional script anyway, and thanks for the reply 🙂
Copy link to clipboard
Copied
Salut!
Peut-être maintenant ?
// JavaScript Document for Illustrator
// Masque copy.js
// Landry R Fri, 29 January 2021 14:29:26 GMT
var doc = app.activeDocument;
var idx = doc.artboards.getActiveArtboardIndex();
var ab = doc.artboards[idx];
var rect = ab.artboardRect;
var newGroup = doc.groupItems.add();
doc.selectObjectsOnActiveArtboard();
sel = selection;
doc.selection == null;
for (var k = 1; k < sel.length; k++) {
sel[k].move(newGroup,ElementPlacement.PLACEATEND);
}
var path0 = newGroup.pathItems.rectangle(rect[1],rect[0],rect[2]-rect[0],rect[1]-rect[3]);
newGroup.clipped = true;
newGroup.selected = true;
app.copy();
app.executeMenuCommand("undo");
Cordialement René
Copy link to clipboard
Copied
Thank you so much for your effort in helping me. I am enjoying seeing what the code can do. However, this is still not what I want. The last script you provide centers the art in a new rectangle. The new rectangle cuts the artwork into the center. I just want the artboard to crop out the artwork sometimes the artwork will be full and there will be no whitespace. But if there is whitespace I only need it to just like the Artboard. Thanks
Copy link to clipboard
Copied
Another thing is I do not need it to crop the artwork in the illustrator file. I want everything in the Illustrator file to stay the same. I just want the copied crop of the Artboard area. All overlapping art should stay the same. Thanks
Copy link to clipboard
Copied
Salut!
J'ai utilisé un masque d'écrêtage, mais on conserve ce qui est à l'extérieure du masque, ce qui explique le décalage.
Je ne vois pas par script comment faire le découpage exact, sauf par l'export.
Cependant, en faisant la manipulation suivante on évite l'enregistrement;
Enregistrer pour le web puis cliquer sur le bouton aperçu (web)
Faire un clic droit sur l'image et choisir copier
Puis Terminer
Coller dans l'autre application.
René
Copy link to clipboard
Copied
I understand totally, what you mean. However, I do not want it to work this way. I have already made some scripts that move the exported artboard into my clipboard, but it is still too many steps. I want to quickly position art inside an Artboard and copy it with the Artboard bounds clipping what is outside. I will keep looking. I will also try to advance my knowledge of Illustrator scripting. I know this can be done. Thanks for all the help