[ARX]为什么我的自定义实体类加入对象字典 出错
本帖最后由 作者 于 2005-7-3 14:18:43 编辑 <br /><br /> // This is command 'TEST'<BR>void cascoTest()<BR>{ <BR> acutPrintf("cascoCEntity was on the Drawing.\n");AcDbBlockTable *pBlkTbl;<BR> acdbHostApplicationServices()->workingDatabase()<BR> ->getBlockTable(pBlkTbl, AcDb::kForRead);<BR> AcDbBlockTableRecord *pTblRcd;<BR> pBlkTbl->getAt(ACDB_MODEL_SPACE, pTblRcd, AcDb::kForWrite);<BR> pBlkTbl->close();<BR> <BR> cascoCEntity *pMyEnt = new cascoCEntity();<FONT color=#ff0000>//自定义实体类cascoCEntity : public AcDbEntity</FONT><BR> pTblRcd->appendAcDbEntity(objectID, pMyEnt); <BR> objectID_a = objectID; <BR> const AcGePoint3d start(pMyEnt->Center());<BR> //pMyEnt->close();
cascoCEntity *pMySecondEnt = new cascoCEntity("Drawing0.dwg", "TWO_RECT"); <FONT color=#ff0000>//自定义实体类cascoCEntity : public AcDbEntity<BR></FONT> pTblRcd->appendAcDbEntity(objectID, pMySecondEnt); <BR> objectID_b = objectID;<BR> const AcGePoint3d end(pMySecondEnt->Center());<BR> //pMySecondEnt->close();
AcDbLine *pLine = new AcDbLine(start, end);<BR> pTblRcd->appendAcDbEntity(objectID, pLine); <BR> pLine->close();
AcDbDictionary *pNamedObj;<BR> AcDbDictionary *pNameList;<BR> acdbHostApplicationServices()->workingDatabase()<BR> ->getNamedObjectsDictionary(pNamedObj, AcDb::kForWrite);<BR> if (pNamedObj->getAt("ASDK_DICT", (AcDbObject*&)pNameList, AcDb::kForWrite)<BR> == Acad::eKeyNotFound)<BR> {<BR> pNameList = new AcDbDictionary;<BR> AcDbObjectId DictId;<BR> pNamedObj->setAt("ASDK_DICT", pNameList, DictId);<BR> }<BR> pNamedObj->close();
CascoObjectToNotify *pObj = new CascoObjectToNotify(); <FONT color=#ff0000>//自定义实体类CascoObjectToNotify : public AcDbObject<BR></FONT> pObj->eLinkage(objectID, true);
AcDbObjectId objId;<BR> if ((pNameList->getAt("object_to_notify_A", objId))<BR> == Acad::eKeyNotFound)<BR> {<BR> pNameList->setAt("object_to_notify_A", pObj, objId);<BR> pObj->close();<BR> } else {<BR> delete pObj;<BR> ads_printf("object_to_notify_A already exists\n");<BR> }
pMyEnt->addPersistentReactor(objectID_a); <FONT color=#f70909>//原来是objId,关键objId为空</FONT><BR> pMyEnt->close();
pObj = new CascoObjectToNotify();<BR> pObj->eLinkage(objectID, false);
if ((pNameList->getAt("object_to_notify_B", objId))<BR> == Acad::eKeyNotFound)<BR> {<BR> pNameList->setAt("object_to_notify_B", pObj, objId);<BR> pObj->close();<BR> } else {<BR> delete pObj;<BR> ads_printf("object_to_notify_B already exists\n");<BR> }
pMySecondEnt->addPersistentReactor(objectID_b); //原来是objId<BR> pMySecondEnt->close();<BR> pNameList->close();
pTblRcd->close();
}<BR>
页:
[1]