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');