Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Script to rotate image inside frame Data merge

Engaged ,
May 28, 2023 May 28, 2023

Hi

I made an indesign file containes 1000 pages produced by data merge , each page contain one image

I want to  use a script to rotate Images Only with certain angle ( 45 , 90 ..... etc ) Not  rotating its graphic frame

Thanks

 

TOPICS
Scripting
1.0K
Translate
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 1 Correct answer

Community Expert , May 28, 2023 May 28, 2023

This script should do it.

function main() {

    // settings:
    var myAngle = prompt('Rotate all graphics by amount:', 90),
        absoluteRotation = true;

    if (myAngle == null)
        return;

    var doc = app.activeDocument,
        tm = app.transformationMatrices.add({ counterclockwiseRotationAngle: Number(myAngle) }),
        graphics = doc.allGraphics;

    for (var i = 0; i < graphics.length; i++)
        graphics[i].transform(CoordinateSpaces.PARENT_COORDINATES, AnchorPoint.CENTE
...
Translate
Engaged ,
May 28, 2023 May 28, 2023

Any help Here

Translate
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 ,
May 28, 2023 May 28, 2023

So, you want help to write the script? A script which rotates every placed graphic in the document by the same amount? Or does it need to target particular graphics? I suggest you post a sample .indd document (just a few pages) with a screen shot of the final result you want. - Mark

Translate
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
Engaged ,
May 28, 2023 May 28, 2023

Thanks For your Reply

I want script that rotates every placed graphic in the document by the same amount ( Not the graphic frame ) Except graphics in locked layers

Translate
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 ,
May 28, 2023 May 28, 2023

This script should do it.

function main() {

    // settings:
    var myAngle = prompt('Rotate all graphics by amount:', 90),
        absoluteRotation = true;

    if (myAngle == null)
        return;

    var doc = app.activeDocument,
        tm = app.transformationMatrices.add({ counterclockwiseRotationAngle: Number(myAngle) }),
        graphics = doc.allGraphics;

    for (var i = 0; i < graphics.length; i++)
        graphics[i].transform(CoordinateSpaces.PARENT_COORDINATES, AnchorPoint.CENTER_ANCHOR, tm, absoluteRotation ? MatrixContent.ROTATION_VALUE : undefined);

}

app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Rotate all graphics');

Note: this will set the rotate of every graphic *to* a particular angle, and running the script twice won't do anything. But if you change absolute rotation to false

absoluteRotation = false;

 then it will rotate *by* the amount each time you run the script.

- Mark

Translate
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
Engaged ,
May 28, 2023 May 28, 2023

Great thanks For you Mark

that's what I want 

It worked like a charm 

Thanks

Translate
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 ,
May 28, 2023 May 28, 2023
LATEST

Happy to help. 🙂

Translate
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