Hi @Bill Planey, I've written a script for this and I use it extensively on imposed jobs where half the job is upside down. Let me know if it works okay for you.
- Mark
/**
* @file UpsideDown.js
* Rotates view by 180°.
* @author m1b
*/
(function () {
var doc = app.activeDocument,
view = doc.activeView,
ab = doc.artboards[doc.artboards.getActiveArtboardIndex()],
intersection = intersectionOfBounds([view.bounds, ab.artboardRect]),
newViewCenter = [
intersection[0] + (intersection[2] - intersection[0]) / 2,
intersection[1] - (intersection[3] - intersection[1]) / 2
],
viewCenter = view.centerPoint,
dx = newViewCenter[0] - viewCenter[0];
view.centerPoint = [viewCenter[0] + dx * 2, viewCenter[1]];
if (view.rotateAngle == 0)
view.rotateAngle = 180;
else
view.rotateAngle = 0;
/**
* Returns the overlapping rectangle
* of two or more rectangles.
* NOTE: Returns undefined if ANY
* rectangles do not intersect.
* @author m1b
* @version 2022-07-24
* @param {Array} arrayOfBounds - an array of bounds arrays [l, t, r, b].
* @returns {Array} - bounds array [l, t, r, b] of overlap.
*/
function intersectionOfBounds(arrayOfBounds) {
// sort a copy of array
var bounds = arrayOfBounds
.slice()
.sort(function (a, b) { return b[0] - a[0] || a[1] - b[1] });
// start with first bounds
var intersection = bounds.shift(),
b;
// compare each bounds, getting smaller
while (b = bounds.shift()) {
// if doesn't intersect, bail out
if (!boundsDoIntersect(intersection, b))
return;
var l = Math.max(intersection[0], b[0]),
t = Math.min(intersection[1], b[1]),
r = Math.min(intersection[2], b[2]),
b = Math.max(intersection[3], b[3]);
intersection = [l, t, r, b];
}
return intersection;
};
/**
* Returns true if the two bounds intersect.
* @author m1b
* @version 2024-03-10
* @param {Array} bounds1 - bounds array.
* @param {Array} bounds2 - bounds array.
* @param {Boolean} [TLBR] - whether bounds arrays are interpreted as [t, l, b, r] or [l, t, r, b] (default: based on app).
* @returns {Boolean}
*/
function boundsDoIntersect(bounds1, bounds2, TLBR) {
if (undefined == TLBR)
TLBR = (/indesign/i.test(app.name));
return !(
TLBR
? (
// TLBR
bounds2[0] > bounds1[2]
|| bounds2[1] > bounds1[3]
|| bounds2[2] < bounds1[0]
|| bounds2[3] < bounds1[1]
)
: (
// LTRB
bounds2[0] > bounds1[2]
|| bounds2[1] < bounds1[3]
|| bounds2[2] < bounds1[0]
|| bounds2[3] > bounds1[1]
)
);
};
})();