明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1868|回复: 0

[ARX]为什么我的自定义实体类加入对象字典 出错

[复制链接]
发表于 2005-7-3 12:15:00 | 显示全部楼层 |阅读模式
本帖最后由 作者 于 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(); }
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-26 06:54 , Processed in 0.157156 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表