Sg2.9
Rotating TextFrames
Recent RSS
Rotating TextFrames
Date:  17. May 2007, 15:34

If I call

myArt.rotate(theta, x, y);

on an areaText it outputs the rotation as if myArt was rotated with the SelectionTool (the text gets shown at the top of the textFrame). How can I make it so, as if myArt was rotated with the RotateTool (position of text stays relative to the textFrame) or do I need to outline the text?

Re: Rotating TextFrames
From:  Jürg Lehni
Date:  18. May 2007, 06:53

That's a bug in Scriptographer. I just realized that the flag Art.TRANSFORM_DEEP is basically the same as Art.TRANSFORM_CHILDREN, but does not work correctly with text frames. It will be gone in future releases, and Art.TRANSFORM_CHILDREN will be used by default, together with Art.TRANSFORM_OBJECTS.
If you want to fix this in your script until the next release, you can do:

myArt.transform(matrix, Art.TRANSFORM_OBJECTS | Art.TRANSFORM_CHILDREN);
Re: Rotating TextFrames
Date:  20. May 2007, 10:53

Your solution is crashing my script. It just stops outputting and makes illustrator not show anything in the document (as if it was all deleted) and I have to close the document and start a new one. But Sg gives no error.

this is what I figured out:
the rotation (/matrix) seems to be called recursively on a textFrame. So firstly rotate is called on the text AND on the textFrame and then it is called on the textFrame itself. So when you wanted to rotate 45º, the text ends up 45º tilted in a textFrame at 90º from the original.

I've added an image to illustrate what's happening.

In my mind there were two possible solutions;
1. set the Theta to half and then try to rotate the text again seperately of the textFrame, or
2. let it be called twice so the text is still on the correct angle and then rotate the textFrame's Frame back by Theta.

I couldn't acces the text, since it's not a child of the textFrame. But the second method worked.. (although I'm not fond of using 'hacks' like this, I need it to work ;)

so calling the following after each other makes rotation work on textFrames:

myTextFrame.rotate(myTheta, myRotationPoint);
myTextFrame.getFirstChild().rotate((-1*myTheta), myRotationPoint);
Re: Rotating TextFrames
From:  Jürg Lehni
Date:  20. May 2007, 14:47

Your observation about the recursion is right. Setting Art.TRANSFORM_DEEP causes this, as when I implemented it I somehow managed to oversee the Art.TRANSFORM_CHILDREN parameter, which does the same thing natively, and in a correct way for any object, even text.

I wonder why it crashes on your computer. Do you mind sending the file along more information about your system, platform, etc? sg AT scriptographer DOT com. Thanks!

Re: Rotating TextFrames
Date:  20. May 2007, 18:10

Nevermind! The crash was my fault, I used setToRotation(theta, point); but it should be used as setToRotation(theta, x, y);
If you try the first it stops you from using Illustrator without giving an error.

Re: Rotating TextFrames
Date:  26. May 2007, 18:35

That was what I thought yes. But as I figured out it was down to something else in my script (faulty theta somewhere in a 200 line script) I deleted my post (but you seem very able to read it?)

I am still curious if it is possible to get to know what type of art something is.. for those who can't read my 'deleted' post.
I wondered if a function such as:

myArt.isInstanceOf(areaText); existed.

Re: Rotating TextFrames
From:  Jürg Lehni
Date:  26. May 2007, 18:56

I guess my RSS reader cached your post before you removed it ;)
I deleted my post now as well.

The feature you requested is already there, through standard JS:

myArt instanceof AreaText
Scripts
08.08.14, 15:24
15.05.14, 14:23
02.03.14, 19:16
18.11.13, 14:48
22.03.13, 03:05
22.02.13, 15:45
Posts
10.01.17, 16:37
19.02.16, 06:03
19.02.16, 06:00
17.01.16, 11:00
12.01.16, 13:10
25.11.15, 08:19
Script of the Moment
Stroke Translation 10.03.09