Copy link to clipboard
Copied
I've tried to build a script that find all the items in a document with a specific object style and apply a percentage to their content (image).
But I've run into many problems… (i'm not a very good scripter, I've tried the help of ChatGPT and it's really not perfect(!!). It almost do what I want… but it's inelegant and doesn't really work.
The main problem seems to be creating a prompt at the beginning asking for :
1 - The percentage we want applied to images
2- The object style targeted (with a dropdown menu of the styles of the document)
3- The reference point by which the scale will be done (this could also be done using the current selected reference point in the control panel… but I dont find how)
I've join a document showing the intended result. The targeted images are in anchored groups and their frames has "Objects to scale" as object style. At the bottom of the page is the desired result, all the images are at the same percentage (10%) and transformed by the bottom center.
Anyone input on this would be greatly appreciated (and maybe a great tool for many others!) Thanks !
var myDoc = app.documents[0];
app.findObjectPreferences = app.changeObjectPreferences = null;
app.findObjectPreferences.appliedObjectStyles = "ABC";
var found = app.findObject();
for (var i = 0; i < found.length; i++)
{
found[i].graphics[0].horizontalScale = 60;
found[i].graphics[0].verticalScale = 60;
found[i].fit(FitOptions.FRAME_TO_CONTENT);
}
var flag=0;
findmyobject();
function findmyobject()
{
var w = new Window ("dialog", "Find Object Styles");
w.p1= w.add("panel", undefined, undefined, {borderStyle:"FONT"});
w.p1.add('statictext',undefined,"Select the find Object Styles");
w.p1.g = w.p1.add('group');
w.p1.g.orientation = 'column'
w.p1.g.alignChildren = "center";
var Find_Ostyles=app.documents[0].objectStyles.everyItem().name;
var preset_list = w.p1.g.add ("dropdownlist", undefined, Find_Ostyles
...
Copy link to clipboard
Copied
I found this thread - might be helpful
https://community.adobe.com/t5/indesign-discussions/scale-all-images-at-once-in-indesign/td-p/994814...
Copy link to clipboard
Copied
var myDoc = app.documents[0];
app.findObjectPreferences = app.changeObjectPreferences = null;
app.findObjectPreferences.appliedObjectStyles = "ABC";
var found = app.findObject();
for (var i = 0; i < found.length; i++)
{
found[i].graphics[0].horizontalScale = 60;
found[i].graphics[0].verticalScale = 60;
found[i].fit(FitOptions.FRAME_TO_CONTENT);
}
Copy link to clipboard
Copied
Yes it worked !
Thank you very much for your time.
Copy link to clipboard
Copied
var flag=0;
findmyobject();
function findmyobject()
{
var w = new Window ("dialog", "Find Object Styles");
w.p1= w.add("panel", undefined, undefined, {borderStyle:"FONT"});
w.p1.add('statictext',undefined,"Select the find Object Styles");
w.p1.g = w.p1.add('group');
w.p1.g.orientation = 'column'
w.p1.g.alignChildren = "center";
var Find_Ostyles=app.documents[0].objectStyles.everyItem().name;
var preset_list = w.p1.g.add ("dropdownlist", undefined, Find_Ostyles);
w.orientation = "column";
w.add ("button", undefined, "OK");
w.add ("button", undefined, "Cancel");
var myResult = w.show()
if(myResult == 1)
{
if((preset_list.selection==null)){return;}
mychanges();
}
else if (myResult== 2){
exit(0);
}
function mychanges(){
var myFind_OStyle=preset_list.selection.text;
var myDoc = app.documents[0];
app.findObjectPreferences = app.changeObjectPreferences = null;
app.findObjectPreferences.appliedObjectStyles = myFind_OStyle;
var found = app.findObject();
for (var i = 0; i < found.length; i++)
{
found[i].graphics[0].horizontalScale = 60;
found[i].graphics[0].verticalScale = 60;
found[i].fit(FitOptions.FRAME_TO_CONTENT);
flag=1;
}
}
}
alert("Process Completed")
Copy link to clipboard
Copied
var flag=0;
findmyobject();
function findmyobject()
{
var w = new Window ("dialog", "Find Object Styles");
w.p1= w.add("panel", undefined, undefined, {borderStyle:"FONT"});
w.p1.add('statictext',undefined,"Select the find Object Styles");
w.p1.g = w.p1.add('group');
w.p1.g.orientation = 'column'
w.p1.g.alignChildren = "center";
var Find_Ostyles=app.documents[0].objectStyles.everyItem().name;
var preset_list = w.p1.g.add ("dropdownlist", undefined, Find_Ostyles);
w.p1= w.add("panel", undefined, undefined, {borderStyle:"FONT"});
w.p1.add('statictext',undefined,"Select the Percentage");
w.p1.g = w.p1.add('group');
w.p1.g.orientation = 'column'
w.p1.g.alignChildren = "center";
var preset_percentage = w.p1.g.add ("dropdownlist", undefined, [10,20,30,40,50,60,70,80,90,100]);
w.orientation = "column";
w.add ("button", undefined, "OK");
w.add ("button", undefined, "Cancel");
var myResult = w.show()
if(myResult == 1)
{
if((preset_list.selection==null)){return;}
mychanges();
}
if(myResult == 2)
{
if((preset_percentage==null)){return;}
mychanges();
}
else if (myResult== 3){
exit(0);
}
function mychanges(){
var myFind_OStyle =preset_list.selection.text;
var mySelect_Percentage = Number(preset_percentage.selection.text);
var myDoc = app.documents[0];
app.findObjectPreferences = app.changeObjectPreferences = null;
app.findObjectPreferences.appliedObjectStyles = myFind_OStyle;
var found = app.findObject();
for (var i = 0; i < found.length; i++)
{
found[i].graphics[0].horizontalScale = mySelect_Percentage;
found[i].graphics[0].verticalScale = mySelect_Percentage;
found[i].fit(FitOptions.FRAME_TO_CONTENT);
flag=1;
}
}
}
alert("Process Completed")
Copy link to clipboard
Copied
Thanks, it works and looks good !