• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Select only one layer for my Script

Guest
Sep 17, 2014 Sep 17, 2014

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

TOPICS
Scripting

Views

261

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Sep 17, 2014 Sep 17, 2014

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Sep 17, 2014 Sep 17, 2014

Copy link to clipboard

Copied

LATEST

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);

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines