Hi Again,
Please refer to the attachment. I need to know what the angel is in the top right hand corner and I need to know the true length of the line highlighted?
Can anyone help with this or tell me even if it’s possible?
Thanks Again
GH
Hi Again,
Please refer to the attachment. I need to know what the angel is in the top right hand corner and I need to know the true length of the line highlighted?
Can anyone help with this or tell me even if it’s possible?
Thanks Again
GH
We don’t have a Variable for Angle, so I don’t think it is possible.
The alternative is manual. Draw a second straight line. Use the Inspector/Property/Angle, and change the value, until the second line matches the target line. You have to mess with getting the source points matched up, etc. Brutal.
You can obtain a bug-ridden version by nominating the requirement in the OG7 WishList.
You can get at these measures by running some kind of script (from Script Editor, the OG script menu, or something like Keyboard Maestro / Fastscripts), but that’s obviously not ideal.
(function () {
'use strict';
// Angle to the x-axis, measured anti-clockwise
// polarAngle :: (x, y) -> (x1, y1) -> Radians
// polarAngle :: (Num, Num) -> (Num, Num) -> Num
function polarAngle(p1, p2) {
var dx = p2[0] - p1[0],
dy = p2[1] - p1[1],
dLocal = -Math.atan(dy / dx);
return 0 <= dx ? (
0 >= dy ? dLocal : 2 * Math.PI + dLocal
) : Math.PI + dLocal;
}
// degrees :: Radians -> Degrees
// degrees :: Num -> Num
function degrees(r) {
return r * (180 / Math.PI);
}
// Angle between two lines, measured anti-clockwise
// polarDifference :: ((x, y), (x1, y1)) - >
// ((x2, y2), (x3, y3)) -> Radians
// polarDifference :: ((Num, Num),(Num, Num)) ->
// ((Num, Num),(Num, Num)) -> Num
function polarDifference(line, line1) {
var theta = polarAngle.apply(null, line),
theta1 = polarAngle.apply(null, line1);
return theta1 > theta ? theta1 - theta : theta - theta1;
}
// lineLength :: (x, y) -> (x1, y1) -> Num
// lineLength :: (Num, Num) -> (Num, Num) -> Num
function lineLength(p1, p2) {
return Math.sqrt(
Math.pow(p2[0] - p1[0], 2) + // dx ^ 2
Math.pow(p2[1] - p1[1], 2) // + dy ^ 2
);
}
// Angle of single selected line to the horizontal, measured anti-clockwise
// OR (if more than one line selected)
// angle between first two selected lines.
// measured anti-clockwise from
// line with lower angle to line with higher angle
// (0 is parallel to the positive x axis)
var og = Application('OmniGraffle'),
ws = og.windows,
w = ws.length ? ws.at(0) : undefined;
if (w && w.id() !== -1) {
var lstSeln = w ? w.selection() : [],
lstLines = lstSeln
.reduce(function (a, x) {
if (a.length > 1) return a;
var lstPoints = x.pointList();
return lstPoints ? a.concat([lstPoints]) : a;
}, []);
var lngLines = lstLines.length,
firstLine = lngLines ? lstLines[0] : undefined,
secondLine = lngLines > 1 ? lstLines[1] : undefined;
var firstLineAngle = firstLine ? (
polarAngle.apply(null, firstLine)
) : undefined,
angleDifference = secondLine ? (
polarDifference(firstLine, secondLine)
) : undefined,
firstLengthPoints = firstLine ? (
lineLength.apply(null, firstLine)
) : undefined,
secondLengthPoints = secondLine ? (
lineLength.apply(null, secondLine)
) : undefined;
var dct = firstLine ? {
firstLineAngleRadians: firstLineAngle,
firstLineAngleDegrees: degrees(firstLineAngle),
firstLineLengthPoints: firstLengthPoints,
firstLineLengthIN: firstLengthPoints / 72,
firstLineLengthCM: firstLengthPoints * 2.54 / 72,
secondLineLengthPoints: secondLengthPoints,
secondLineLengthIN: secondLine ? (
secondLengthPoints / 72
) : undefined,
secondLineLengthCM: secondLine ? (
secondLengthPoints * 2.54 / 72
) : undefined,
polarDifferenceRadians: secondLine ? angleDifference : undefined,
polarDifferenceDegrees: secondLine ? degrees(
angleDifference
) : undefined,
} : undefined;
var strReport = dct ? Object.keys(dct)
.sort()
.reduce(function (a, k) {
var v = dct[k];
return v !== undefined ? (
a + k + '\t->\t' + v.toFixed(2) + '\n\n'
) : a;
}, '') : undefined;
if (strReport) {
var a = Application.currentApplication(),
sa = (a.includeStandardAdditions = true, a);
sa.activate();
sa.displayDialog(strReport, {
withTitle: "Measures of first 1 or 2 selected lines"
});
}
} else return undefined;
})();
Thanks for the replies guys. I worked out how to get around it. Thanks again!