找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 528|回复: 0

[求助]:一个关于反应器的copied()函数的问题

[复制链接]
发表于 2003-8-2 19:05:03 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
下面我是参照书本例子做的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();
}
}
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2024-11-14 13:41 , Processed in 0.222614 second(s), 31 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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