C++和ObjectARX开发一例

C++和ObjectARX开发一例
//-----------------------------------------
//开发环境  
//vs2008+vs2008sp1+ObjectArx2010+AutoCAD2010  
//vs2008新建一个win32项目或者MFC DLL项目  
//vs2008设置项目属性->配置->所有配置
//vs2008设置项目属性->配置属性->C/C++->代码生成->运行时库=多线程 DLL (/MD)
//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 
//AutoCAD2010调用命令方法 

//先加载应用程序MyArxFirst.arx
//命令: hello
//Hello World!


//-----------------------------------------
//myArxFirst.def文件的内容
LIBRARY	"MyArxFirst"
EXPORTS
acrxEntryPoint PRIVATE
acrxGetApiVersion PRIVATE



//-----------------------------------------
// MyArxFirst.cpp : 定义 DLL 应用程序的导出函数。
//
#include "stdafx.h"
#include <aced.h>
#include <rxregsvc.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;
}


//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----


  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值