This is tricky!

938
5
06-10-2010 09:21 AM
YukunXing
New Contributor III
At least for me. And I certainly hope it is not for you guys so I can learn how to do it.

I have a mxd set up in layout view. If I mouse over a vertex of a feature, both the coordinates for the defined projection (meters), and coordinates of the vertex on the paper (inches) show up at the bottom of the ArcMap window, as shown in the attached image.

My question is, how do I get the "paper coordinates" (inch readings) via ArcObjects, without opening the mxd in ArcMap?

Thanks a lot!
0 Kudos
5 Replies
KirkKuykendall
Occasional Contributor III
when you say " without opening the mxd in ArcMap", do you mean you are using ArcEngine?

cast the pagelayout to IActiveView, then pass the mouse X/Y to IActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint

Even though the method says "ToMapPoint", the resulting point should be in page coordinates.
0 Kudos
YukunXing
New Contributor III
when you say " without opening the mxd in ArcMap", do you mean you are using ArcEngine?


I literally meant without opening the mxd in any application window. Here is what I'm trying to do:

I have a bunch of mxd, which all have a polygon as the top layer. The mxd is exported to PDF, then converted to either Tiff or PNG, which in turn need to be georeferenced (for some reason we are not supposed to go from mxd to Tiff or PNG directly). I'm attempting to automate the georefencing. So far I could get the point collections of the polygon, however the returned coordinates are in the projection system of the polygon feature. That's why I'm asking how to convert it to page/paper coordinates, to establish the "from" and "to" point pairs.

So there is no "mouse" involved in this, but I'll see if I can get what I need by playing with the displaytransformation method.

Thank you very much for your reply!
0 Kudos
YukunXing
New Contributor III
Can't seem to make it work. The x coordiantes of the point is 457613 (meter), however, neither the ToMapPoint nor the FromMapPoint function changed it, I always got the same number after the conversion, 457613.

I'm not sure if I did anything wrong, or this is not the method for what I need at all. Bounds and VisibleBounds properties are automatically set from the pagelayout object. DeviceFrame and resolution are not set. I'm not sure how to set DeviceFrame, and on the other hand, if the resolution property has anything to do with the outcome, I'm prbably looking at the wrong method.
0 Kudos
KirkKuykendall
Occasional Contributor III
I'd try IDisplayTransformation.TransformCoords for this.

Call it twice, first using the IActiveView of the map to get into device coords, then using the IActiveView of the pagelayout to go from device coords into page coords (even though page coords are treated as "map" coords when looking at the args).
0 Kudos
YukunXing
New Contributor III
Kirk,

I'd love to try it. However, the description of the TransformCoords is kinda confusing:
http://edndoc.esri.com/arcobjects/8.3/ComponentHelp/esriCore/IDisplayTransformation_TransformCoords....

At the bottom of the page it talks about TRANSFORM_TOMAP and TRANSFORM_TODEVICE flags, but I don't see it anywhere in the arguments list. Also when I tried to click on "WKSPoint" and "tagPONT" to get more information, I got a blank page.

Do you have any sample code, or other refernece I could use? Thank you!
0 Kudos