.NET

Reply
Contributor
mlovitt
Posts: 12
Registered: ‎05-19-2005
Message 1 of 2 (352 Views)

Managed C++ in .NET

352 Views, 1 Replies
05-19-2005 11:26 AM
There is a function within ObjectARX, acedCoordFromPixelToWorld, that I want to use from my C#/.NET application. This method isn't exposed through the .NET wrappers or COM interface, so it seems like I need to call it natively from C++.

What's the best way to do this? One idea: create a managed C++ project, write a C++ wrapper for acedCoordFromPixelToWorld, and then set up my C# project to reference the managed C++ project.

Is this possible? If so, how do I go about setting up the managed C++ project? (What external libraries do I reference and so on? I couldn't find any documentation on this.)

Really we want a general purpose way of using the native ObjectARX functions when .NET wrappers are unavailable. Does this sound like the best way to accomplish that?

Thanks

Michael
*Albert Szilvasy
Message 2 of 2 (352 Views)

Re: Managed C++ in .NET

05-19-2005 05:23 PM in reply to: mlovitt
I'd call it directly from C# like this:
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);
}
}

wrote in message news:4850832@discussion.autodesk.com...
There is a function within ObjectARX, acedCoordFromPixelToWorld, that I want
to use from my C#/.NET application. This method isn't exposed through the
.NET wrappers or COM interface, so it seems like I need to call it natively
from C++.

What's the best way to do this? One idea: create a managed C++ project,
write a C++ wrapper for acedCoordFromPixelToWorld, and then set up my C#
project to reference the managed C++ project.

Is this possible? If so, how do I go about setting up the managed C++
project? (What external libraries do I reference and so on? I couldn't find
any documentation on this.)

Really we want a general purpose way of using the native ObjectARX functions
when .NET wrappers are unavailable. Does this sound like the best way to
accomplish that?

Thanks

Michael
Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.