• Global community
    • Language:
      • Deutsch
      • English
      • EspaƱol
      • FranƧais
      • PortuguĆŖs
  • ę—„ęœ¬čŖžć‚³ćƒŸćƒ„ćƒ‹ćƒ†ć‚£
    Dedicated community for Japanese speakers
  • ķ•œźµ­ ģ»¤ė®¤ė‹ˆķ‹°
    Dedicated community for Korean speakers
Exit Search
0

script to move content certain distance

New Here ,
Feb 19, 2023 Feb 19, 2023

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

TOPICS
Scripting

Views

509

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

correct answers 2 Correct answers

Community Expert , Feb 19, 2023 Feb 19, 2023

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

...

Votes

Translate

Translate
Community Expert , Feb 19, 2023 Feb 19, 2023

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

Votes

Translate

Translate
Community Expert ,
Feb 19, 2023 Feb 19, 2023

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
}
}
}



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
Community Expert ,
Feb 19, 2023 Feb 19, 2023

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

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
Community Expert ,
Feb 19, 2023 Feb 19, 2023

Copy link to clipboard

Copied

Thanks for that - interesting!

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
New Here ,
Feb 19, 2023 Feb 19, 2023

Copy link to clipboard

Copied

LATEST

Nery Great Thanks For your Help

It works as a charm

Thank you

 

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