.NET
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Managed C++ in .NET
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
280 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
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
Re: Managed C++ in .NET
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
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@@YAHHVCPoin t@@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@@YAHHQBNAAV CPoint@@@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
public class ArxApi
{
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl,
EntryPoint="?acedCoordFromPixelToWorld@@YAHHVCPoin
extern static bool acedCoordFromPixelToWorld(int viewportNumber,
System.Drawing.Point pixel, out Autodesk.AutoCAD.Geometry.Point3d worldPt);
[DllImport("acad.exe", CallingConvention = CallingConvention.Cdecl,
EntryPoint="?acedCoordFromWorldToPixel@@YAHHQBNAAV
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);
}
}
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
