Hi @Julio Ricardo, can you send me a test file with the artboard and black bars and layers and sample objects set up? You can post it here if it is saved as Illustrator PDF with "Preserve Illustrator Editing Capabilities". Otherwise it'll take too long to understand why "nothing happened". 🙂
- Mark
Hi @m1b
I got it ! ;-D
// Get the active document
var doc = app.activeDocument;
// Get the artboard object
var artboard = doc.artboards[doc.artboards.getActiveArtboardIndex()];
// Get the "Arte" layer
var layerArte = doc.layers.getByName("Arte");
// Create a rectangle with the same size as the artboard
var rect = doc.pathItems.rectangle(artboard.artboardRect[1], artboard.artboardRect[0], artboard.artboardRect[2]-artboard.artboardRect[0], artboard.artboardRect[1]-artboard.artboardRect[3]);
rect.move(layerArte, ElementPlacement.PLACEATBEGINNING);
//Bring to front the rectangle
rect.zOrder(ZOrderMethod.BRINGTOFRONT);
// Select all objects in the "Arte" layer
doc.activeLayer = layerArte;
var items = layerArte.pageItems;
for (var i = 0; i < items.length; i++) {
items[i].selected = true;
}
// Create a Clipping Mask
app.executeMenuCommand('makeMask');