Copy link to clipboard
Copied
Hey there,
I am a newbie and just made this script with the help of other topics:
it helps me to change the import options of all .ai's (pdfs) in my document
var d = app.activeDocument;
var g = d.allGraphics;
app.pdfPlacePreferences.pdfCrop = PDFCrop.CROP_TRIM;
for (i=0; i<d.allGraphics.length; i++) {
g = d.allGraphics;
g.absoluteHorizontalScale = 100; // Horizontal Scale
g.absoluteVerticalScale = 100; // Vertical Scale
g.place(g.itemLink.filePath);
}
now i have the problem that i only want to use this on one layer of my document, but he changes every ai.
How can i tell the script which layer he has to change or that the script doesnt change locked layers?
Sry for my bad english
Copy link to clipboard
Copied
Hi,
Use the below code,
var d = app.activeDocument;
var g = d.allGraphics;
for (i=0; i<d.allGraphics.length; i++) {
if(d.allGraphics.itemLayer.name == "RED")
{
g = d.allGraphics;
g.absoluteHorizontalScale = 100; // Horizontal Scale
g.absoluteVerticalScale = 100; // Vertical Scale
}
}
Regards
Siraj
Copy link to clipboard
Copied
Hi try this code
it can't change objects' properties on locked layer.
var d = app.activeDocument;
var l = d.layers.item("RED");
var ag = l.allGraphics;
app.pdfPlacePreferences.pdfCrop = PDFCrop.CROP_TRIM;
if (l.locked) {
alert('the layer is locked');
exit();
}
for (i=0; i< ag.length; i++) {
var g = ag;
g.absoluteHorizontalScale = 100; // Horizontal Scale
g.absoluteVerticalScale = 100; // Vertical Scale
g.place(g.itemLink.filePath);
}