Skip to main content
Inspiring
December 18, 2014
Answered

Get the top left corner position?

  • December 18, 2014
  • 1 reply
  • 2805 views

Hey guys,

via geometricBounds[1] and geometricBounds[0] I can get the starting positions of my objects.

In my case I need the top left corner position. When you rotate an object, the geometricBounds still reflect a bounding box so that I can't get the desired coordinates.

How can I get the properties of the "starting points" (the top left corner of my Object)?

Thank you really much!

This topic has been closed for replies.
Correct answer TᴀW

You're entering the complex ground of coordinate spaces here.

Briefly, you can use resolve() to find any of the anchor points on an

object. But you've got to decide in what coordinate space to get the

results.

Your best bet is probably to use Spread coordinates. The 0,0 point

of that is the middle of the spread.

So, given a pageItem i, try:

i.resolve(AnchorPoint.TOP_LEFT_ANCHOR, CoordinateSpaces.SPREAD_COORDINATES);

If you want to delve into this subject, Marc Autret has a good PDF guide

about it.

Ariel

1 reply

TᴀW
TᴀWCorrect answer
Legend
December 18, 2014

You're entering the complex ground of coordinate spaces here.

Briefly, you can use resolve() to find any of the anchor points on an

object. But you've got to decide in what coordinate space to get the

results.

Your best bet is probably to use Spread coordinates. The 0,0 point

of that is the middle of the spread.

So, given a pageItem i, try:

i.resolve(AnchorPoint.TOP_LEFT_ANCHOR, CoordinateSpaces.SPREAD_COORDINATES);

If you want to delve into this subject, Marc Autret has a good PDF guide

about it.

Ariel

StammAuthor
Inspiring
December 23, 2014

Hey, that did it for me! Your answer in combination with the guide from indiscripts( can be found here: http://www.indiscripts.com/blog/public/data/coordinate-spaces-and-transformations-1/CoordinateSpacesTransfos01-02.pdf ).

I now used i.resolve(AnchorPoint.TOP_LEFT_ANCHOR, CoordinateSpaces..pageCoordinates);

Note: This will give you the coordinates of your object seen from the x = 0 , y = 0 coordinates of the page in POINTS. There are many sites in the web to convert this to other measurement units. I used this: Millimeters to Points (Computer) Conversion Calculator

Community Expert
December 23, 2014

@Stamm – and there is UnitValue for this purpose:

CS3 JS: UnitValue

Here an example:

//Input: 100 in points

var myMillimetersValue = UnitValue(100, MeasurementUnits.POINTS).as(MeasurementUnits.MILLIMETERS);

myMillimetersValue;

//Output: 35.2777777777778 in millimeters

Uwe