Skip to main content
Inspiring
December 12, 2012
Answered

Use fitting options on all objects to a locked layer

  • December 12, 2012
  • 1 reply
  • 846 views

This will be a easy for some of you.  But I'm just a kid at this.

I have a layer locked called AD.

Not all the ads fit their boxes.  So I would love to run a script that would looked at the locked layer by the name of the layer and make all content fill frame proportionally.

I tried to piece together other code I found here, but I failed miserably.  I appeal to the gods!!

This topic has been closed for replies.
Correct answer Jump_Over

Hi,

try this:

myDoc = app.activeDocument;

myLayer = myDoc.layers.item("AD");

myLayer.locked = false;

for (k=0; k<myDoc.allPageItems.length; k++)

        if (myDoc.allPageItems.itemLayer == myLayer)

        {

        currPItem = myDoc.allPageItems;

        currPItem.fit(FitOptions.PROPORTIONALLY); // or another option you choose

        }

myLayer.locked = true;

enjoy

1 reply

Jump_Over
Jump_OverCorrect answer
Legend
December 12, 2012

Hi,

try this:

myDoc = app.activeDocument;

myLayer = myDoc.layers.item("AD");

myLayer.locked = false;

for (k=0; k<myDoc.allPageItems.length; k++)

        if (myDoc.allPageItems.itemLayer == myLayer)

        {

        currPItem = myDoc.allPageItems;

        currPItem.fit(FitOptions.PROPORTIONALLY); // or another option you choose

        }

myLayer.locked = true;

enjoy

MadMac55Author
Inspiring
December 12, 2012

Wow, so simple!  I wish I would have thought of that.  This is great, and I hope it's something everyone can use.