Skip to main content
Participant
June 8, 2011
Question

Coordinates

  • June 8, 2011
  • 1 reply
  • 2223 views

I open a photoshop document xx.psd in illustrator (15.1) and then add a textframe to the document, and specify the position of this text frame. I then place some contents in the text frame. For the purpose of my investigation, I make these contents the coordinates of the position I specified, eg "(100,100)". The text frame appears to be postioned using an ordinary cartesian right handed coordinate system, where x gets bigger to the right, and y gets bigger in the "up" direction (demonstrated by writing several text frames at different locations). When I inspect the rulers used in Illustrator, both the artboard and global rulers use coordinate systems where y increases in the "down" direction. Can anyone clarify what coordinate system scripting uses?

When I look at my bits of text, hovering over the handles shows (100,100) to be at (-106.76pt, 372.76pt) and it is below and to the left of the actual photoshop image when rulers is set to "artboard", and the ruler origin is the top left of the photoshop image.

When I look at my bits of text with the global rulers active, the handles of (100,100) are now at (100pt, -89.96pt) (implies a 10pt text size, as the handles are at the bottom of the text)

So the second part of my question is why is the global ruler origin where it is? The top left of my photoshop image appears at (206.76pt,-462.72pt) in the global ruler system. which is (0,0) in the artboard ruler system.

The only scripting manipulations I do before adding the text frame is to create a reference to the active document (I already have illustrator open with the photoshop doc (now xx.ai) as the active doc) . I then do a docref.textFrames.add to return a reference to a  text frame, and I set its position and contents, as described above.

Any suggestions welcome. Please excuse my ignorance - I am new to illustrator but not new to scripting.

This topic has been closed for replies.

1 reply

Muppet_Mark-QAl63s
Inspiring
June 8, 2011

In CS5 it has been my experience that origin is top/left and works positive down… This is a change from the previous versions where it was origin bottom/left and positive up… From what I have been able to gather so far using the app convert coordinate system is for use when dealing with multi-artboard positioning… Its been a very frustrating change and very little to no documented examples of how best to use the new methods…

Participant
June 9, 2011

Part of the problem seems to be my boldness in opening a psd in Illustrator. If I make a new illustrator doc, and then place an image in it, I can move the image up to the global zero zero, so that this origin is now at the top left of my image. Now, in my script, I must make my "y" values negative in order to get the text onto the image. So from scripting, y is -ve down and uses the global rulers origin.

Participant
June 10, 2011

Further to my ealrier remarks - this is an extract from the CS5 Scripting

Guide. A bit of RTFM sometimes helps:

For the artboard, the default coordinate origin, (0,0), is the top-left corner, reflected in the

ruler origin

property of the

artboard object. X coordinate values increase from left to right, and Y values increase

from top to bottom. This changed in the CS5 release; to maintain script compatability, a document created

by a script still uses the older system, with the origin at the bottom left of the artboard, and the Y value

increasing from bottom to top. The

page origin property of a document object defines the bottom-left

corner of the printable region of the document as a fixed point.

In fact, scripting uses that system even if the document is already there and you instantiate its object using application.activesheet.