Copy link to clipboard
Copied
Hi there,
I'm having real trouble trying to get the below script to work on more than one selected object. At the moment it works perfect with one frame selected with an image in it. What it does is it scales it down to 10% and centres it in a frame. I've tried different script samples I've found online but I can't seem to get them to work with the below. Can anyone help show me what I'm failing to do.
Below is the working script (1 selected)
function fit10(){
var sel = app.selection[0];
sel.fit(FitOptions.centerContent);
var myImage = sel;
myImage.graphics[0].absoluteHorizontalScale = 10;
myImage.graphics[0].absoluteVerticalScale = 10;
}
____________________
Below is the script that is not working (more than 1 selected)
function fit10(){
var sel = app.selection;
sel.fit(FitOptions.centerContent);
for (var i = 0; sel > i; i++)
var myImage = sel;
myImage.graphics[0].absoluteHorizontalScale = 10;
myImage.graphics[0].absoluteVerticalScale = 10;
}
Thank you
Copy link to clipboard
Copied
Hi,
Let me induce you to study javascript since it will make your work easier and faster.
Copying and pasting unreadable codes from network can lead you to wrong or even danger places.
1. selection is composed from graphic' containers
and
2. these containers are not empty
makes a code more universal.
Exam this:
var
mTarget = app.selection,
cObject;
while (cObject = mTarget.pop())
fit10(cObject);
function fit10(anObject){
if (!anObject.hasOwnProperty ("graphics") ) return;
if (!anObject.graphics.length) return;
anObject.graphics[0].absoluteHorizontalScale = 10;
anObject.graphics[0].absoluteVerticalScale = 10;
anObject.fit(FitOptions.centerContent);
}
Jarek
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more