.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Managed C++ in .NET

1 REPLY 1
Reply
Message 1 of 2
mlovitt
958 Views, 1 Reply

Managed C++ in .NET

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
1 REPLY 1
Message 2 of 2
Anonymous
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

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost