Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
I don't think you need to go to Ruby or satimage for this. Neat though it is to figure out the math of the matrix and implement this yourselves, Illustrator's scripting dictionary has the commands to make Illustrator translate an angle to a matrix value and vice versa:
see
concatenate rotation matrix
and
get rotation matrix
in the language dictionary.
There are the equivalent commands for scale and translation matrices too.
In the Illustrator CS6 Applescript Dictionary, I'm looking at Page 99.
Copy link to clipboard
Copied
Hey, nevermind. Looks like you can convert an angle to a matrix, and transform a matrix by adding an angle, but not get the angle from an existing matrix.
Nice work with the Ruby code.
- Tom.
Copy link to clipboard
Copied
Here is a method that avoids working with the transform matrix in case that's desired.
1. Define x1 and y1 from the geometricBounds.
2. Change the textFrame.textRange.baselineShift by any positive amount (small is fine).
3. Define x2 and y2 from the geometricBounds (which are now shifted).
4. Define the angle using the math below.
5. Revert the change to baselineShift.
0 - Math.atan( ( x1 - x2 ) / ( y1 - y2 ) ) * 180.0 / Math.PI
This will return a value of 0 to 359 degrees, where 0 degrees is unrotated text.
It might be affected by the origin quadrant preference (whether y goes up/down as you move up/down the page). I haven't tested that interaction.