- 积分
- 1072
- 明经币
- 个
- 注册时间
- 2004-5-12
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
各位高手:假如我先运行getData函数,不运行setData函数,则一切正常,或者只运行setData函数也一切正常,但如果我先运行getData再运行 setData函数,AutoCAD就出错并关闭(出错的地方已标出),高手能告诉我为什么吗?程序如下: char* getData() { Acad::ErrorStatus es; AcDbDictionary *pNamedObj; acdbCurDwg()->getNamedObjectsDictionary (pNamedObj,AcDb::kForRead ); AcDbDictionary *pDict;
es=pNamedObj->getAt("SmartDict",(AcDbObject*&)pDict,AcDb::kForRead ); if (es==Acad::eOk ) { AcDbXrecord * pXrec1; es=pDict->getAt("XREC1",(AcDbObject*&)pXrec1,AcDb::kForRead ); if (es==Acad::eOk ) { struct resbuf *pHead; pXrec1->rbChain(&pHead); for(int i=0;i<index;i++,pHead=pHead->rbnext) { }
return pHead->resval.rstring; ads_relrb(pHead); }
//pXrec1=NULL; //delete pXrec1; /* pXrec1->close (); pDict->close (); pNamedObj->close ();*/ } else { //pDict->close (); //pNamedObj->close (); return NULL; }
}
/*---------------------------------------------------------------*/ void setData() { Acad::ErrorStatus es; AcDbDictionary *pNamedObj; AcDbDictionary *pDict=new AcDbDictionary; AcDbObjectId DictId;
acDocManager->lockDocument( acDocManager->curDocument(), AcAp::kWrite,NULL,NULL,true);
acdbCurDwg()->getNamedObjectsDictionary (pNamedObj,AcDb::kForWrite );
es=pNamedObj->setAt("SmartDict",pDict,DictId);//在这出错 acutPrintf(_T("\n无法执行:pNamedObj->setAt (%s)"),acadErrorStatusText(es)); if (es==Acad::eOk) { //。。。。。 }
//pNamedObj->close (); //pDict->close(); // pDict=NULL; //delete pDict; acDocManager->unlockDocument( acDocManager->curDocument()) ; } |
|