Author Topic: ObjectARX C++/CLI  (Read 7811 times)

0 Members and 1 Guest are viewing this topic.

Odoshi

  • Guest
ObjectARX C++/CLI
« on: August 26, 2012, 07:43:46 PM »
Hi everyone,

I'm about to break new ground here. I've been coding AutoCAD using every API, but ObjectARX the least.

But now I have a need to go to C++/CLI in order to use some legacy C++ code.

So to keep it simple (yea right), I'm starting on AutoCAD 2013/VS 2010. Turns out VS 2010 has no intellisense for C++/CLI - big help there.

But before that, I'm using the ObjectARX 2013 wizard and on the last screen checking the ".NET mixed managed code support" option.

Once the project is created, I'm lost. I put in a snippet of code that compiles in a C++ ObjectARX project, but just get errors in my new project.

Syntax is different, expected types are different...

Are there any examples out there - maye something as simple as drawing a line so I can see what references I need and a kickstart on the syntax?

Thanks!

owenwengerd

  • Bull Frog
  • Posts: 441
Re: ObjectARX C++/CLI
« Reply #1 on: August 26, 2012, 09:45:24 PM »
But now I have a need to go to C++/CLI in order to use some legacy C++ code.

Why does legacy C++ code require C++/CLI? You should not use C++/CLI unless you absolutely have to use both legacy C++ code and legacy managed code in the same module. It is possible, but it's not for the faint of heart, and not well suited for a discussion forum.

Odoshi

  • Guest
Re: ObjectARX C++/CLI
« Reply #2 on: August 26, 2012, 10:04:44 PM »
So, the main point of using C++/CLI is to mix .NET references and C++? Is it of no benefit for calling ObjectARX code from a .NET GUI?

That was our other intent, to not use MFC, but to use .NET GUI in one DLL and call draw functions from ObjectARX C++/CLI dll. I know we could P/Invoke but thought it would be easier to reference a C++/CLI. Is that the case?

Thanks!

owenwengerd

  • Bull Frog
  • Posts: 441
Re: ObjectARX C++/CLI
« Reply #3 on: August 26, 2012, 10:40:44 PM »
In some cases the huge up-front investment is worthwhile, but it's definitely not easier to use C++/CLI over P/Invoke in the general case. The reason you don't see any C++/CLI ObjectARX samples is because it's so difficult to get right, especially when dealing with different versions of the Framework and different build platforms used in different versions of AutoCAD. If you can use P/Invoke, you should use it.

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 7032
  • AKA Daniel
Re: ObjectARX C++/CLI
« Reply #4 on: August 27, 2012, 12:17:02 AM »
I use C++/CLI regularly.  get yourself a copy of Visual Assist X for intellisence  :-)

Odoshi

  • Guest
Re: ObjectARX C++/CLI
« Reply #5 on: August 27, 2012, 08:39:43 AM »
Thanks for all the insight, everyone!

sdphg

  • Guest
Re: ObjectARX C++/CLI
« Reply #6 on: August 29, 2012, 05:32:24 AM »
mostly,you can take the C++/CLI project as a pure c++ project,unless you want wrapper something for .net module to invoke.so,my suggestion is:separate the CLI code from c++.To do that,you just write c++ code,when you want expose functions in c++ class to .net class,write a 'proxy class',this proxy class is a managed class(use __gc or gcnew keywords,etc) which wrapper the unmanaged function.
even thorough,I think owenwengerd is right,you use c++/CLI only you must to. Because you still to face many difficult,such as type convert from managed to unmanaged and vice versa,and so on.
good luck.
« Last Edit: August 29, 2012, 05:35:29 AM by sdphg »

LE3

  • Guest
Re: ObjectARX C++/CLI
« Reply #7 on: September 02, 2012, 09:17:44 PM »
Don't work on arx or c++ anymore - on my current job we use C#, but the part spent on arx was fun and I learned from the masters - one in particular Owen.

Below it is an image of one of the wrappers I did of one custom object for my old job - sorry no code is avail - and yes not easy at all.

Have fun!

Jeff H

  • Needs a day job
  • Posts: 6074
Re: ObjectARX C++/CLI
« Reply #8 on: September 04, 2012, 12:45:22 PM »
I use C++/CLI regularly.  get yourself a copy of Visual Assist X for intellisence  :)
Make you sure you plan on buying if you download.
It gets lonely when the trial runs out.

Odoshi

  • Guest
Re: ObjectARX C++/CLI
« Reply #9 on: September 18, 2012, 06:48:34 PM »
Just got the trial. Good stuff!