- 积分
- 909
- 明经币
- 个
- 注册时间
- 2005-4-1
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
本帖最后由 作者 于 2005-7-3 14:18:43 编辑
// This is command 'TEST' void cascoTest() { acutPrintf("cascoCEntity was on the Drawing.\n");
AcDbBlockTable *pBlkTbl; acdbHostApplicationServices()->workingDatabase() ->getBlockTable(pBlkTbl, AcDb::kForRead); AcDbBlockTableRecord *pTblRcd; pBlkTbl->getAt(ACDB_MODEL_SPACE, pTblRcd, AcDb::kForWrite); pBlkTbl->close(); cascoCEntity *pMyEnt = new cascoCEntity();//自定义实体类cascoCEntity : public AcDbEntity pTblRcd->appendAcDbEntity(objectID, pMyEnt); objectID_a = objectID; const AcGePoint3d start(pMyEnt->Center()); //pMyEnt->close();
cascoCEntity *pMySecondEnt = new cascoCEntity("Drawing0.dwg", "TWO_RECT"); //自定义实体类cascoCEntity : public AcDbEntity pTblRcd->appendAcDbEntity(objectID, pMySecondEnt); objectID_b = objectID; const AcGePoint3d end(pMySecondEnt->Center()); //pMySecondEnt->close();
AcDbLine *pLine = new AcDbLine(start, end); pTblRcd->appendAcDbEntity(objectID, pLine); pLine->close();
AcDbDictionary *pNamedObj; AcDbDictionary *pNameList; acdbHostApplicationServices()->workingDatabase() ->getNamedObjectsDictionary(pNamedObj, AcDb::kForWrite); if (pNamedObj->getAt("ASDK_DICT", (AcDbObject*&)pNameList, AcDb::kForWrite) == Acad::eKeyNotFound) { pNameList = new AcDbDictionary; AcDbObjectId DictId; pNamedObj->setAt("ASDK_DICT", pNameList, DictId); } pNamedObj->close();
CascoObjectToNotify *pObj = new CascoObjectToNotify(); //自定义实体类CascoObjectToNotify : public AcDbObject pObj->eLinkage(objectID, true);
AcDbObjectId objId; if ((pNameList->getAt("object_to_notify_A", objId)) == Acad::eKeyNotFound) { pNameList->setAt("object_to_notify_A", pObj, objId); pObj->close(); } else { delete pObj; ads_printf("object_to_notify_A already exists\n"); }
pMyEnt->addPersistentReactor(objectID_a); //原来是objId,关键objId为空 pMyEnt->close();
pObj = new CascoObjectToNotify(); pObj->eLinkage(objectID, false);
if ((pNameList->getAt("object_to_notify_B", objId)) == Acad::eKeyNotFound) { pNameList->setAt("object_to_notify_B", pObj, objId); pObj->close(); } else { delete pObj; ads_printf("object_to_notify_B already exists\n"); }
pMySecondEnt->addPersistentReactor(objectID_b); //原来是objId pMySecondEnt->close(); pNameList->close();
pTblRcd->close();
}
|
|