C++和ObjectARX开发一例

2014-11-24 12:41:20 · 作者: · 浏览: 0

C++和ObjectARX开发一例

//-----------------------------------------

//开发环境

//vs2008+ObjectArx2010+AutoCAD2010

//vs2008新建一个win32项目或者MFC DLL项目

//vs2008设置项目属性->配置属性->C/C++->常规->附加包含目录=E:\AutoCad开发\ObjectARX2010\inc

//vs2008设置项目属性->配置属性->连接器->常规->输出文件=$(OutDir)\$(ProjectName).arx

//vs2008设置项目属性->配置属性->连接器->常规->附加库目录="E:\AutoCad开发\ObjectARX2010\lib-win32"

//vs2008设置项目属性->配置属性->连接器->输入->附加依赖项=rxapi.lib acdb18.lib acge18.lib acad.lib acedapi.lib

//-----------------------------------------

//myArxFirst.def文件的内容

LIBRARY "MyArxFirst"

EXPORTS

acrxEntryPoint PRIVATE

acrxGetApiVersion PRIVATE

//-----------------------------------------

// MyArxFirst.cpp : 定义DLL 应用程序的导出函数。

//

#include "stdafx.h"

#include

#include vc.h>

//定义两个函数

void initApp();

void unloadApp();

//打印"Hello world!"在AutoCAD Command上

void helloWorld();

void initApp()

{

//register a command with the AutoCAD command mechanism

acedRegCmds->addCommand(ACRX_T("HELLOWORLD_COMMANDS"),

ACRX_T("Hello"),

ACRX_T("Bonjour"),

ACRX_CMD_TRANSPARENT,

helloWorld);

}

void unloadApp()

{

acedRegCmds->removeGroup(ACRX_T("HELLOWORLD_COMMANDS"));

}

void helloWorld()

{

acutPrintf(ACRX_T("\nHello World!"));

}

extern "C"

AcRx::AppRetCode

acrxEntryPoint(AcRx::AppMsgCode msg, void* pkt)

//void acrxEntryPoint(void* pkt)

{

switch (msg)

{

case AcRx::kInitAppMsg:

acrxDynamicLinker->unlockApplication(pkt);

acrxRegisterAppMDIAware(pkt);

initApp();

break;

case AcRx::kUnloadAppMsg:

unloadApp();

break;

default:

break;

}

return AcRx::kRetOK;

}

extern "C"

void acrxGetApiVersion(void) //

{

}

//ObjectARX offers the following input functions. Refer to the ObjectARX Online Help for a complete description of how to use these functions.

//acedGetInt used to get an integer value

//acedGetReal used to get a real value

//acedGetString used to get a string

//acedGetAngle used to get a angle value

//acedGetKword used to get a key word

//acedInitGet used to initialize acedGetXXXX functions

//acedGetFileD used to retrieve file selection from a file dialog

//acedGetPoint used to pick a point

//acedGetDist used to get the distance between two points

//acedGetCorner see Online Help for a complete description

//

//ObjectARX offers the following functions for selection of AutoCAD entities. (Again refer to the ObjectARX Online Help for a complete description of how to use these functions).

//

//acedEntSel used to select a single entity

//acedNEntSel used to select a single, nested entity

//acedNEntSelP used to select a single, nested entity

//acutSSGet used to select multiple entities

//---the end----

摘自 hsg77的专栏