.NET

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

Managed C++ in .NET

368 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 (368 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
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.