TheSwamp

Code Red => .NET => Topic started by: Draftek on May 08, 2007, 03:43:17 PM

Title: C++ managed project command
Post by: Draftek 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?
Title: Re: C++ managed project command
Post by: LE 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...
Title: Re: C++ managed project command
Post by: Paul Richardson 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()
  {

  }

};
Title: Re: C++ managed project command
Post by: Draftek 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.
Title: Re: C++ managed project command
Post by: LE on May 09, 2007, 12:22:39 PM
Dang... I see that my response was indeed out-of-scope...  :oops:  :oops:
Title: Re: C++ managed project command
Post by: Paul Richardson 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... :)