- 积分
- 12459
- 明经币
- 个
- 注册时间
- 2003-5-28
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2004-9-22 11:51:00
|
显示全部楼层
点滴
本帖最后由 作者 于 2004-9-23 22:45:19 编辑
14. 如何加载一个菜单文件?
IAcadMenuGroups *mnuGrps = NULL; //... mnuGrps->Load(BSTR MenuFileName, VARIANT BaseMenu, IAcadMenuGroup **pMenuGroup);
// MenuFileName是自定义的菜单文件, BaseMenu是指什么呢?
方法: CString mac = "(COMMAND \"_MENULOAD\" \"acad_map.mnu\")"; if (acDocManager->curDocument()) { acedPostCommand( mac ); mac = "(menucmd \"P10=+ACAD_MAP.地形图缩编\")";
//如果P10不存在,则新载入的菜单加到当前菜单最后面 acedPostCommand( mac ); }
15. upgradeOpen()函数用法: //... acdbGetObjectId(plineId, ename); AcDbEntity *pEntity; acdbOpenAcDbEntity(pEntity, plineId, AcDb::kForRead); //... AcDbPolyline *pLWPline = (AcDbPolyline*)pEntity; // 现在pLWPline处于打开状态 //如果要修改pLWPline的属性,必须以写的方式打开 pLWPline->upgradeOpen(); pLWPline->setElevation(0.0); pLWPline->close();
注意,如果在使用upgradeOpen()之前,关闭了对象,将导致错误. 如 pEntity->close(); //或 pLWPline->close(); //... pLWPline->upgradeOpen(); pLWPline->setElevation(0.0); // INTERNAL ERROR: !dbobji.cpp@6159: eNotOpenForWrite pLWPline->close();
16. 如果一个对象已经删除,它的ID为objId,以下代码: AcDbEntity *pEntity; acdbOpenAcDbEntity(pEntity, objId, AcDb::kForRead); 结果pEntity为NULL. if (pEntity == NULL) acedAlert("NULL"); if (pEntity) acedAlert("Exist"); else acedAlert("None Exist"); if (pEntity->isErased() == Adesk::kTrue) // 执行将出错,其实的确也没有什么疑义,本来pEntity就不曾成功指向任何实体,当然也就没有是否被Erased的判断了; // 是不是如果pEntity曾经指向过实体对象,该对象被删除之后,就可以用这一句来判断了呢? // 而判断该实体是否已经被删除,下面的代码可以: If (objId.isErased() != true) acedAlert("Exist");
17. 如何得到一个块(AcDbBlockReference)的名字? 用参考块实体的blockTableRecord()方法返回一个该block reference引用的AcDbBlockTableRecord的object ID. 打开AcDbBlockTableRecord,用getName(const char* &pName)获得块名. //... AcDbBlockReference *pBlkRef = (AcDbBlockReference*)pEnt; AcDbObjectId pBlockTableRecordId; pBlockTableRecordId = pBlkRef->blockTableRecord(); AcDbBlockTableRecord *pBlockTableRecord; char* blkName; if (Acad::eOk == acdbOpenObject(pBlockTableRecord, pBlockTableRecordId, AcDb::kForRead)) { pBlockTableRecord->getName(blkName); pBlockTableRecord->close(); }
另一麻烦的方法: //... AcDbBlockReference *pBlkRef = (AcDbBlockReference*)pEnt; char* blkName; ads_name ssEntName; struct resbuf *rbSSEnt; struct resbuf *rbTrav; int rc; CString strBlkName = ""; acdbGetAdsName(ssEntName, pBlkRef->objectId()); rbSSEnt = acdbEntGet(ssEntName); rbTrav = rbSSEnt; while (rbTrav) { switch (rbTrav->restype) { case 2: strBlkName = rbTrav->resval.rstring; } rbTrav = rbTrav->rbnext; }//while |
|