Author Topic: C++ managed project command  (Read 3694 times)

0 Members and 1 Guest are viewing this topic.

Draftek

  • Guest
C++ managed project command
« on: May 08, 2007, 03:43:17 PM »
I'm playing around with managed c++ and cannot get a command to work:

I can't get the assembly:CommandClassAttribute method to compile and if I comment it out, the command "MyTest" does not register with AutoCAD.

Code: [Select]
// MgdCpp.h

#using <System.dll>
#using <..\..\..\Program Files\Autodesk\Acadm 2007\acdbmgd.dll>
#using <..\..\..\Program Files\Autodesk\Acadm 2007\acmgd.dll>

#pragma once

using namespace System;
using namespace Autodesk::AutoCAD::Runtime;

//[assembly: CommandClassAttribute(MgdCpp::Commands::typeid)]

namespace MgdCpp {

public ref class Commands
{
[CommandMethodAttribute("MyTest")]
static void MyTest()
{

}
};
}

see anything blaring wrong?

LE

  • Guest
Re: C++ managed project command
« Reply #1 on: May 08, 2007, 06:07:57 PM »
Mr. Matchmaker;

I don't have my books here... but I remember that Master Daniel uploaded a SLN project here.

Anyway, I have never have done any managed C++ code, but, it does not follow basically the same as in C++?

Like in your header file:

using namespace Autodesk::AutoCAD::Runtime;
using namespace Autodesk::AutoCAD::DatabaseServices;

namespace ClassLibrary
{
public class LESQClass   
{   
private:    
LESQClass() {};    
[Autodesk::AutoCAD::Runtime::CommandMethodAttribute("CMDTEST1")]   
static void cmdtest1();
};
}

void ClassLibrary::LESQClass::cmdtest1()
{

}

Don't know... 

if you use the arxwizard for your solution and click in the .NET checkbox... it will generate the basic skeleton...

edit: some grammatical that was super mickey mouse...
« Last Edit: May 08, 2007, 06:27:23 PM by LE »

Paul Richardson

  • Guest
Re: C++ managed project command
« Reply #2 on: May 08, 2007, 08:44:15 PM »
I'm playing around with managed c++ and cannot get a command to work:

I can't get the assembly:CommandClassAttribute method to compile and if I comment it out, the command "MyTest" does not register with AutoCAD.

Code: [Select]
// MgdCpp.h

#using <System.dll>
#using <..\..\..\Program Files\Autodesk\Acadm 2007\acdbmgd.dll>
#using <..\..\..\Program Files\Autodesk\Acadm 2007\acmgd.dll>

#pragma once

using namespace System;
using namespace Autodesk::AutoCAD::Runtime;

//[assembly: CommandClassAttribute(MgdCpp::Commands::typeid)]

namespace MgdCpp {

public ref class Commands
{
[CommandMethodAttribute("MyTest")]
static void MyTest()
{

}
};
}

see anything blaring wrong?

You need to make your CommandMethod Public:
Code: [Select]
public ref class Commands
{
public:
  [CommandMethodAttribute("MyTest")]
  static void MyTest()
  {

  }

};
« Last Edit: May 08, 2007, 08:47:03 PM by Paul Richardson »

Draftek

  • Guest
Re: C++ managed project command
« Reply #3 on: May 09, 2007, 08:08:22 AM »
Quote
You need to make your CommandMethod Public:

DOH! - I KNEW it was something simple.

Thanks guys!

Any clue why the CommandClassAttribute will not compile? I'm guessing I'd have the same problem with IExtensionApplication Attribute as well, which I use on occasion.

LE

  • Guest
Re: C++ managed project command
« Reply #4 on: May 09, 2007, 12:22:39 PM »
Dang... I see that my response was indeed out-of-scope...  :oops:  :oops:

Paul Richardson

  • Guest
Re: C++ managed project command
« Reply #5 on: May 10, 2007, 09:59:24 AM »
Dang... I see that my response was indeed out-of-scope...  :oops:  :oops:

I'll gladly trade my knowledge of C++/CLI for your knowledge of ARX... You'd
get the short end of that stick... :)