Copy link to clipboard
Copied
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!
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 =
...
Copy link to clipboard
Copied
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');
Copy link to clipboard
Copied
Worked like a charm, thanks so much for your help!
Copy link to clipboard
Copied
Good to hear!
Copy link to clipboard
Copied
Do you want to "flip" or FLIP properly? 😉
And why do you want to flip your objects? And what kind of objects?