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

Script to flip objects on all pages

New Here ,
Jan 11, 2025 Jan 11, 2025

Hi I'm looking for a script that will flip all objects on all pages of the document on the unlocked layers only. I have a script that I found here that will flip only the object selected but that is very tedious (and can also be done with the transform tool)  when I'm dealing with 250+ page documents. Thanks for any leads!

TOPICS
Scripting
492
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 , Jan 11, 2025 Jan 11, 2025

Hi @jacobs40370360, I'm sure there are further complexities, but here is a simple approach that does what you ask. See if it helps.

- Mark

 

/**
 * Flip Items Horizontally.js
 *
 * Flips every page item horizontally, unless its layer is locked or not visible.
 *
 * @author m1b
 * @discussion https://community.adobe.com/t5/indesign-discussions/script-to-flip-objects-on-all-pages/m-p/15084291
 */
function main() {

    var doc = app.activeDocument,
        items = doc.pageItems;

    for (var i = 
...
Translate
Community Expert ,
Jan 11, 2025 Jan 11, 2025

Hi @jacobs40370360, I'm sure there are further complexities, but here is a simple approach that does what you ask. See if it helps.

- Mark

 

/**
 * Flip Items Horizontally.js
 *
 * Flips every page item horizontally, unless its layer is locked or not visible.
 *
 * @author m1b
 * @discussion https://community.adobe.com/t5/indesign-discussions/script-to-flip-objects-on-all-pages/m-p/15084291
 */
function main() {

    var doc = app.activeDocument,
        items = doc.pageItems;

    for (var i = 0; i < items.length; i++) {

        var item = items[i];

        if (
            undefined == item
            || !item.hasOwnProperty('geometricBounds')
            || !item.itemLayer
            || item.itemLayer.locked
            || !item.itemLayer.visible
        )
            continue;

        item.transform(
            CoordinateSpaces.PARENT_COORDINATES,
            [[0, 0], BoundingBoxLimits.GEOMETRIC_PATH_BOUNDS, CoordinateSpaces.INNER_COORDINATES],
            app.transformationMatrices.add({
                horizontalTranslation: item.geometricBounds[3] - item.geometricBounds[1],
                horizontalScaleFactor: -1,
                verticalScaleFactor: 1,
            })
        );

    }

}
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Flip Items');

 

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
New Here ,
Jan 13, 2025 Jan 13, 2025

Worked like a charm, thanks so much for your 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
Community Expert ,
Jan 13, 2025 Jan 13, 2025
LATEST

Good to hear!

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
LEGEND ,
Jan 12, 2025 Jan 12, 2025

@jacobs40370360 

 

Do you want to "flip" or FLIP properly? 😉

 

 

And why do you want to flip your objects? And what kind of objects?

 

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