程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> C++和ObjectARX開發一例

C++和ObjectARX開發一例

編輯:C++入門知識

 

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

 

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的專欄

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved