一、安装vs2005
二、安装AutoCAD2008
三、安装ObjectArx2008
四、建立第一个ObjectArx程序
1、首先用ObjectARX Commands添加一个命令
然后在acrxEntryPoint.cpp中生成如下代码:
ACED_ARXCOMMAND_ENTRY_AUTO(CArxProject1App, qxzyArxProject1, _MyCommand1, MyCommand1, ACRX_CMD_TRANSPARENT, NULL)
以及:
// - qxzyArxProject1._MyCommand1 command (do not rename) static void qxzyArxProject1_MyCommand1(void) { }2、然后补充代码如下:
static void qxzyArxProject1_MyCommand1(void) { // Add your code for command qxzyArxProject1._MyCommand1 here AcGePoint3d startPt(60.0, 60.0, 0.0); AcGePoint3d endPt(100.0, 200.0, 0.0); AcDbLine *pLine = new AcDbLine(startPt, endPt); AcDbBlockTable *pBlockTable; acdbHostApplicationServices()->workingDatabase() ->getSymbolTable(pBlockTable, AcDb::kForRead); AcDbBlockTableRecord *pBlockTableRecord; pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForWrite); pBlockTable->close(); AcDbObjectId lineId; pBlockTableRecord->appendAcDbEntity(lineId, pLine); pBlockTableRecord->close(); pLine->close(); }编译,最后会在项目文件的\Visual Studio 2005\Projects\ArxProject1\win32\debug中生成qxzyArxProject1.arx文件
3、打开AutoCAD2008选择“工具|加载应用程序”,选择上面生成的qxzyArxProject1.arx文件,然后在命令窗口输入MyCommand1,点击回车,效果如下: