Copy link to clipboard
Copied
Hi
I have an indesign file consists of 2500 pages resulted from data merge process , that file has images in graphic oval frame
I want a script that move content ( images ) certain distance like .1 cm Not moving the oval frame
Thanks in anvance
This script will find all graphics within oval frames and move it a specified amount
The line bold is the move - if you want to move it sideways.
// Define variables
var doc = app.activeDocument;
var ovalFrames = doc.ovals;
var deltaX = 0.5;
// Loop through all oval frames
for (var i = 0; i < ovalFrames.length; i++) {
var ovalFrame = ovalFrames[i];
// Loop through all page items in oval frame
for (var j = 0; j < ovalFrame.allPageItems.length; j++) {
var pageItem = ovalFrame.allPageItems[j];
// Check
...Hi Eugene, you donāt have to select the image in order to make the moveāthis might be a bit faster with a long document:
var doc = app.activeDocument;
var deltaX = 0.5;
var deltaY = 0.5;
var ag = doc.allGraphics
for (var i = 0; i < ag.length; i++){
if (ag[i].constructor.name == "Image" && ag[i].parent.constructor.name == "Oval") {
ag[i].move(undefined, [deltaX, deltaY]);
}
};
Copy link to clipboard
Copied
This script will find all graphics within oval frames and move it a specified amount
The line bold is the move - if you want to move it sideways.
// Define variables
var doc = app.activeDocument;
var ovalFrames = doc.ovals;
var deltaX = 0.5;
// Loop through all oval frames
for (var i = 0; i < ovalFrames.length; i++) {
var ovalFrame = ovalFrames[i];
// Loop through all page items in oval frame
for (var j = 0; j < ovalFrame.allPageItems.length; j++) {
var pageItem = ovalFrame.allPageItems[j];
// Check if page item is an image
if (pageItem instanceof Image) {
// Select image and move it by deltaX
pageItem.select();
pageItem.move(undefined, [deltaX, 0]);
break; // Exit loop after selecting and moving first image
}
}
}
---------------
You could also add a prompt to insert the distance you want for x and y coords
// Define variables
var doc = app.activeDocument;
var ovalFrames = doc.ovals;
// Prompt user for X and Y distances
var deltaX = parseFloat(prompt("Enter X distance to move images by:", "0"));
var deltaY = parseFloat(prompt("Enter Y distance to move images by:", "0"));
// Loop through all oval frames
for (var i = 0; i < ovalFrames.length; i++) {
var ovalFrame = ovalFrames[i];
// Loop through all page items in oval frame
for (var j = 0; j < ovalFrame.allPageItems.length; j++) {
var pageItem = ovalFrame.allPageItems[j];
// Check if page item is an image
if (pageItem instanceof Image) {
// Select image and move it by deltaX and deltaY
pageItem.select();
pageItem.move(undefined, [deltaX, deltaY]);
break; // Exit loop after selecting and moving first image
}
}
}
Copy link to clipboard
Copied
Hi Eugene, you donāt have to select the image in order to make the moveāthis might be a bit faster with a long document:
var doc = app.activeDocument;
var deltaX = 0.5;
var deltaY = 0.5;
var ag = doc.allGraphics
for (var i = 0; i < ag.length; i++){
if (ag[i].constructor.name == "Image" && ag[i].parent.constructor.name == "Oval") {
ag[i].move(undefined, [deltaX, deltaY]);
}
};
Copy link to clipboard
Copied
Thanks for that - interesting!
Copy link to clipboard
Copied
Nery Great Thanks For your Help
It works as a charm
Thank you