I don't have control over either of these types so I can't say whether this
will be safe assumption forever but they are certainly bit by bit compatible
right now.
Same is true for Point3d and double[3], Point2d and double[2].
Albert
"Tony Tanzillo" wrote in message
news:4851364@discussion.autodesk.com...
Hi Albert.
Thanks for the great samples.
Can we presume that System.Drawing.Point and CPoint are
call-compatible types?
--
http://www.caddzone.com
AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com
"Albert Szilvasy" wrote in message
news:4851284@discussion.autodesk.com...
There's no first class .NET API to convert pixel to world coordinates and
back. You will need to P/Invoke 2 C++ APIs to accomplish this. Here's how to
do it:
public class ArxApi
{
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl,
EntryPoint="?acedCoordFromPixelToWorld@@YAHHVCPoint@@QAN@Z")]
extern static bool acedCoordFromPixelToWorld(int viewportNumber,
System.Drawing.Point pixel, out Autodesk.AutoCAD.Geometry.Point3d worldPt);
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl,
EntryPoint="?acedCoordFromWorldToPixel@@YAHHQBNAAVCPoint@@@Z")]
extern static bool acedCoordFromWorldToPixel(int viewportNumber, ref
Autodesk.AutoCAD.Geometry.Point3d worldPt, out System.Drawing.Point pixel);
[CommandMethod("testpix")]
public void Test()
{
Point3d pt = new Point3d(0,0,0);
System.Drawing.Point pix;
acedCoordFromWorldToPixel(0,ref pt,out pix);
Point3d res;
acedCoordFromPixelToWorld(0,pix,out res);
}
}
To convert between UCS and WCS you can use the transformation matrix
returned by Editor.CurrentUserCoordinateSystem
Albert
wrote in message news:4849962@discussion.autodesk.com...
We are in the process of customizing the DockingPalette C# sample found in
C:\ObjectARX 2006\samples\dotNet\DockingPalette.
We are attempting to insert an entity into the database at the X,Y drawing
coordinates where the user released the mouse button. We are able to
retrieve the X,Y pixel coordinates from System.Windows.Forms.DragEventArgs,
but have not found a way to translate those into X, Y coordinates useful for
inserting an entity at an accurate spot on the drawing. In addition, we
haven't found anyway to retrieve the current X, Y of the mouse position when
we receive our drop event.
Can anyone provide any guidance on either:
A) translating System.Windows.Forms.DragEventArgs X,Y coords into World
Coordinate or User Coordinate system X,Y values
B) retrieving World Coordinate or User Coordinate system X,Y values for the
current mouse position
BTW, we're I'd like to thank whoever got a .NET forum setup. We're looking
forward to a better repository of .NET knowledge for the ObjectARX api.