用ObjectARX开发AutoCAD2000应用程序配套源码老虎工作室.doc
《用ObjectARX开发AutoCAD2000应用程序配套源码老虎工作室.doc》由会员分享,可在线阅读,更多相关《用ObjectARX开发AutoCAD2000应用程序配套源码老虎工作室.doc(26页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、【精品文档】如有侵权,请联系网站删除,仅供学习与交流用ObjectARX开发AutoCAD2000应用程序配套源码老虎工作室.精品文档.老虎工作室实例exam03 画直线 获取用户输入点exam04a 打开已存在文件建立浏览器对象ID数组获取当前块表指针常事务处理普通快(改变部分实体属性)exam04b 交互选择实体 扩展数据加入 调用扩展数据exam05a 创建新块表记录 创建一带属性快 创建一属性实体 遍历块中实体exam06a 获取用户选择集 建立组,并向其中加入选择集实体 遍历并改变组实体exam06b 向字典对象中加入扩展集 调用扩展集数据exam07 建立基于MFC的对话框 拾取点
2、exam08 建一基于AcdbObject的派生类 应用类向字典加入数据并提取exam09 建一基于拖动的类 实现拖动创建椭圆exam10a 建一临时数据库反映器exam10b 建派生于AcdbObject的派生类 建一有名对象词典纪录 将反映器对象加入词典纪录中 用addPersistanReactor附着实体exam13 派生于AcdbEntity画一自定义网格exam14 判断实体类型交互选择实体转化为AcGe对象求实体交点exam032exam04a2exam04b4exam05a7exam06a11exam06b13exam0715exam0820exam0923exam10a25e
3、xam10b26exam1329exam1432exam03 #include #include #include #include #include #include #include Acad:ErrorStatus newLine();void addLineCommand()/BEGIN_LEVEL_ADVANCED if (newLine()=Acad:eOk) acutPrintf(Successn); else acutPrintf(Failedn);/END_LEVEL_ADVANCEDAcad:ErrorStatus postToDatabase(/*in*/AcDbEnti
4、ty* pEnt,/*out*/AcDbObjectId& idObj)Acad:ErrorStatus es;AcDbBlockTable*pBlockTable;AcDbBlockTableRecord* pSpaceRecord;/确定当前有正在工作的数据库 if (acdbHostApplicationServices()-workingDatabase()=NULL) return Acad:eNoDatabase; /获得当前图形的指针 /获得图形的块表,打开准备读取数据 if (es = acdbHostApplicationServices()-workingDatabase(
5、)-getBlockTable(pBlockTable, AcDb:kForRead)=Acad:eOk)/获得建模空间的记录,打开准备写数据 if (es = pBlockTable-getAt(ACDB_MODEL_SPACE, pSpaceRecord, AcDb:kForWrite)=Acad:eOk) /添加实体指针到建模空间后关闭指针和建模空间记录 if (es = pSpaceRecord-appendAcDbEntity(idObj, pEnt)=Acad:eOk) pEnt-close(); pSpaceRecord-close();/关闭块表 pBlockTable-clo
6、se();/返回状态信息return es;Acad:ErrorStatus newLine()ads_point pt1, pt2;/定义两个ads_point的点int retval;try /从用户处获得第一点if (retval = acedGetPoint(NULL, nSelect lower left: , pt1) != RTNORM) throw retval;/以第一点为基点, 从用户处获得第二点.if (retval = acedGetPoint(pt1, nSelect upper right: , pt2) != RTNORM)throw retval;catch (
7、int e)if (e = RTCAN) /判断输入错误程序中断return Acad:eUserBreak;if (e = RTERROR) /判断无效输入return Acad:eInvalidInput;/ 将ads_point类型的点转换为AcGePoint3d类型之后创建直线AcDbLine* pLine = new AcDbLine(asPnt3d(pt1), asPnt3d(pt2);/如果创建直线出错,返回错误信息if (!pLine)acedAlert(Not enough memory to create a Line!);return Acad:eOutOfMemory;
8、 AcDbObjectId id; /定义对象IDreturn postToDatabase(pLine, id);extern C AcRx:AppRetCode acrxEntryPoint(AcRx:AppMsgCode msg, void* pkt) switch (msg) case AcRx:kInitAppMsg: acrxDynamicLinker-unlockApplication(pkt); acrxDynamicLinker-registerAppMDIAware(pkt); /注册命令 acedRegCmds-addCommand(EXAM03,addline,addl
9、ine,ACRX_CMD_MODAL,addLineCommand); break; case AcRx:kUnloadAppMsg: /当应用程序卸载后,为防止AUOTCAD调用此命令,产生不必要的 /错误,移走命令组 acedRegCmds-removeGroup(EXAM03); break; return AcRx:kRetOK;exam04a#include #include #include #include #include #include #include #include #include #include voidrefEdit() AcDbObjectId transI
10、d; AcDbDatabase* pDb; char *fname; struct resbuf *rb; rb = acutNewRb(RTSTR); int stat = acedGetFileD(Pick a drawing, NULL, dwg, 0, rb); if (stat != RTNORM) | (rb = NULL) acutPrintf(nYou must pick a drawing file.); return; fname = (char*)acad_malloc(strlen(rb-resval.rstring) + 1); strcpy(fname, rb-re
11、sval.rstring); acutRelRb(rb); pDb = new AcDbDatabase(Adesk:kFalse); if (pDb-readDwgFile(fname) != Acad:eOk) acutPrintf(nSorry, that draing is probably already open.); return; AcDbBlockTable *pBlockTable; pDb-getSymbolTable(pBlockTable, AcDb:kForRead); AcDbBlockTableRecord *pOtherMsBtr; pBlockTable-g
12、etAt(ACDB_MODEL_SPACE, pOtherMsBtr, AcDb:kForRead); pBlockTable-close(); AcDbBlockTableRecordIterator *pIter; pOtherMsBtr-newIterator(pIter); AcDbObjectIdArray objIdArray; for (pIter-start(); !pIter-done(); pIter-step() AcDbEntity *pEntity; pIter-getEntity(pEntity, AcDb:kForRead); if (pEntity-isKind
13、Of(AcDbCircle:desc() objIdArray.append(pEntity-objectId(); pEntity-close(); delete pIter; pOtherMsBtr-close(); if (objIdArray.isEmpty() acad_free(fname); acutPrintf(nYou must pick a drawing file that contains circles.); return; AcDbBlockTable *pThisBlockTable; acdbHostApplicationServices()-workingDa
14、tabase() -getSymbolTable(pThisBlockTable, AcDb:kForRead); AcDbBlockTableRecord *pThisMsBtr; pThisBlockTable-getAt(ACDB_MODEL_SPACE, pThisMsBtr, AcDb:kForWrite); pThisBlockTable-close(); AcDbObjectId id = pThisMsBtr-objectId(); pThisMsBtr-close(); AcDbIdMapping errorMap; acapLongTransactionManagerPtr
15、()-checkOut(transId, objIdArray, id, errorMap); int colorIndex;double radius; acedGetInt(nEnter color number to circles center line: , &colorIndex);acedGetReal(nEnter circle radius: ,&radius);if (radiusnewWorkSetIterator(pWorkSetIter); for (pWorkSetIter-start(); !pWorkSetIter-done(); pWorkSetIter-st
16、ep() AcDbEntity *pEntity; acdbOpenAcDbEntity(pEntity, pWorkSetIter-objectId(), AcDb:kForWrite); pEntity-setColorIndex(colorIndex);(AcDbCircle*)pEntity)-setRadius(radius); pEntity-close(); delete pWorkSetIter; pObj-close(); char str132; acedGetString(0, nSee the new colors and radius. Press return to
17、 back, str); acapLongTransactionManagerPtr()-checkIn(transId, errorMap); pDb-saveAs(fname); delete pDb; pDb = NULL; acad_free(fname);voidinitApp() acedRegCmds-addCommand(EXAM04A, LONGTRANS, LONGTRANS, ACRX_CMD_MODAL, refEdit);void unloadApp() acedRegCmds-removeGroup(EXAM04A);extern C AcRx:AppRetCode
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- ObjectARX 开发 AutoCAD2000 应用程序 配套 源码 老虎 工作室
限制150内