明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1588|回复: 0

一个反应器的copied函数的问题

[复制链接]
发表于 2003-8-2 19:06:00 | 显示全部楼层 |阅读模式
下面我是参照书本例子做的copied()函数全部,问题在文字对象生成部分,代码中只生成一个
文字对象,可是运行时生成许多文字对象,不知何故?另一问题当删除一个对象时,要让其永久反应器同时删除,该怎样实现,请大家提供一个思路
AcDbHandle myhandle;
char IntidText[132];
double wallWd,myAngle;
AcDbObjectId objectId,objId;
AcGePoint3d leftPnt3d,rightPnt3d;
bool cs;
if (dbObj->isKindOf(AcDbEquiTriangle::desc())) //找到原对象的反应器的ID
{
  AcDbEquiTriangle *pTemp=AcDbEquiTriangle::cast(dbObj);
  pTemp->getAcDbHandle(myhandle);
  cs=myhandle.isNull();
if(!cs)
{
myhandle.getIntoAsciiBuffer(IntidText);
}
pTemp->close();
AcDbDictionary *pNamedObj;
AcDbDictionary *pNameList;
acdbHostApplicationServices()->workingDatabase()->getNamedObjectsDictionary(pNamedObj,AcDb::kForWrite);
if (pNamedObj->getAt("ASDK_DICT",(AcDbObject*&)pNameList, AcDb::kForRead)== Acad::eKeyNotFound)
{
return;
}
pNamedObj->close();
if ((pNameList->getAt(IntidText, objId))== Acad::eKeyNotFound)
{
return;
}
pNameList->close();
}
if(newObj->isKindOf(AcDbEquiTriangle::desc()))
{
AcDbEquiTriangle *pLine = AcDbEquiTriangle::cast(newObj);
pLine->removePersistentReactor(objId);//把新复制的对象的反应器除去
pLine->getLpoint(leftPnt3d);
pLine->getRpoint(rightPnt3d);
pLine->getAngle(myAngle);
pLine->getQiangKuan(wallWd);
pLine->getAcDbHandle(myhandle);
cs=myhandle.isNull();
if(!cs)
{
myhandle.getIntoAsciiBuffer(IntidText);
}
objectId=pLine->objectId();
AcGePoint3d textPnt;
char QiangText[132];
textPnt.set((leftPnt3d.x+rightPnt3d.x)/2-200*sin(myAngle),(leftPnt3d.y+rightPnt3d.y)/2+200*cos(myAngle),leftPnt3d.z);
AcDbBlockTable *pBlockTable;
acdbHostApplicationServices()->workingDatabase()->getSymbolTable(pBlockTable, AcDb::kForRead);
AcDbBlockTableRecord *pBlockTableRecord;
pBlockTable->getAt(ACDB_MODEL_SPACE, pBlockTableRecord, AcDb::kForWrite);
pBlockTable->close();
acdbRToS(wallWd,2,2,QiangText);
AcDbObjectId textId;
AcDbText *mytext=new AcDbText( textPnt,QiangText,AcDbObjectId::kNull,200,myAngle);//生成新的文字对象
pBlockTableRecord->appendAcDbEntity(textId, (AcDbText *)mytext);
pBlockTableRecord->close();
mytext->close();
AcDbDictionary *pNamedObjNew;//建立文字对象与新复制对象的联系的反应器
AcDbDictionary *pNameListNew;
acdbHostApplicationServices()->workingDatabase()->getNamedObjectsDictionary(pNamedObjNew,AcDb::kForWrite);
if (pNamedObjNew->getAt("ASDK_DICT",(AcDbObject*&)pNameListNew, AcDb::kForWrite)== Acad::eKeyNotFound)
{
pNameListNew = new AcDbDictionary;
AcDbObjectId DictId;
pNamedObjNew->setAt("ASDK_DICT", pNameListNew, DictId);
}
pNamedObjNew->close();
// Create the AsdkObjectToNotify for line A.
AsdkObjectToNotify *pObj = new AsdkObjectToNotify();
pObj->eLinkage(textId);
AcDbObjectId objIdNew;
if ((pNameListNew->getAt(IntidText, objIdNew))== Acad::eKeyNotFound)
{
pNameListNew->setAt(IntidText, pObj, objIdNew);
pObj->close();
} else {
delete pObj;
}
pNameListNew->close();
pLine->addPersistentReactor(objIdNew);
pLine->close();
}
}
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-11-29 09:38 , Processed in 0.165457 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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