admin 发表于 2024-3-16 09:53:19

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





//-----------------------------------------
//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]
查看完整版本: C++和ObjectARX开发一例