Author Topic: Help me about Wrapper ARX to C#  (Read 3772 times)

0 Members and 1 Guest are viewing this topic.

ahlzl

  • Guest
Help me about Wrapper ARX to C#
« on: September 20, 2008, 09:52:29 PM »
1、 download Daniel's code(look the attachment)
2、 use ARX2009 Wizard, select ".NET mixed managed code support"
3、 Insret a Class, name is Utilities
4、 copy Daniel's code
Code: [Select]
// Utilities.h
#pragma managed
#pragma once
using namespace System;
using namespace System::Text;
using namespace Autodesk::AutoCAD::DatabaseServices;
using namespace Autodesk::AutoCAD::Geometry;
using namespace Autodesk::AutoCAD::Runtime;

namespace AcMgdWrprs
{
public ref class Utilities
{

public:
Utilities(void);
static double Distance(Point3d pt1, Point3d pt2);
};
}

// Utilities.cpp
#include "StdAfx.h"
#include "Utilities.h"

using namespace System;
using namespace System::Text;
using namespace System::Collections::Generic;
using namespace Autodesk::AutoCAD::DatabaseServices;
using namespace Autodesk::AutoCAD::Geometry;
using namespace Autodesk::AutoCAD::Runtime;
using namespace Autodesk::AutoCAD::EditorInput;
using namespace Autodesk::AutoCAD::ApplicationServices;

//
namespace AcMgdWrprs
{
Utilities::Utilities(void)
{

}

double Utilities::Distance(Point3d pt1, Point3d pt2)
{
ads_point adspt1;
ads_point adspt2;

adspt1[0] = pt1.X;
adspt1[1] = pt1.Y;
adspt1[2] = pt1.Z;

adspt1[0] = pt2.X;
adspt1[1] = pt2.Y;
adspt1[2] = pt2.Z;

return acutDistance(adspt1,adspt2);
}
}

5、 compile,but reeor……
Code: [Select]
Utilities.cpp
g:\arxcstest\Utilities.h(12) : error C2059: syntax error : 'public'
g:\arxcstest\Utilities.h(13) : error C2143: syntax error : missing ';' before '{'
g:\arxcstest\Utilities.h(13) : error C2447: '{' : missing function header (old-style formal list?)
.\Utilities.cpp(18) : error C3414: 'Autodesk::AutoCAD::Runtime::Utilities::Utilities' : imported member function can't be defined
.\Utilities.cpp(18) : error C2888: 'Autodesk::AutoCAD::Runtime::Utilities::Utilities(void)' : symbol cannot be defined within namespace 'AcMgdWrprs'
.\Utilities.cpp(22) : error C2039: 'Distance' : is not a member of 'Autodesk::AutoCAD::Runtime::Utilities'
        d:\program files\autocad 2009\acdbmgd.dll : see declaration of 'Autodesk::AutoCAD::Runtime::Utilities'


It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8661
  • AKA Daniel
Re: Help me about Wrapper ARX to C#
« Reply #1 on: September 20, 2008, 10:01:43 PM »
Sorry I can’t test this for you, I am on my laptop these days and I don’t have 09 installed. Can you post the solution?

ahlzl

  • Guest
Re: Help me about Wrapper ARX to C#
« Reply #2 on: September 20, 2008, 10:11:37 PM »
thanks for Daniel's help! very much.

I compile your project , OK!  but My project error.
has My project set error?

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8661
  • AKA Daniel
Re: Help me about Wrapper ARX to C#
« Reply #3 on: September 20, 2008, 10:17:54 PM »
Hard to say without seeing your solution. I know the default for the 07 wizard was to use /CLR:oldSyntax, you might want to make sure yours is set to just /CLR


ahlzl

  • Guest
Re: Help me about Wrapper ARX to C#
« Reply #4 on: September 20, 2008, 10:31:58 PM »
success! thanks again!! Daniel is God !!!