[求助]数据字典问题, 出异常!!请指点谢谢!!!
我得到数据字典类时,出现异常,不知道为什么,谢谢,下面是代码.AcDbDictionary *pNamedobj;
acdbHostApplicationServices()->workingDatabase()
->getNamedObjectsDictionary(pNamedobj, AcDb::kForRead);
// Get a pointer to the ASDK_DICT dictionary.
//
AcDbDictionary *pDict;
pNamedobj->getAt("SCALE_DICT", (AcDbObject*&)pDict,
AcDb::kForRead);
pNamedobj->close();
// Get an iterator for the ASDK_DICT dictionary.
//
if (pDict == NULL) {//pDict不为空
ASSERT(0);
return;
}
AcDbDictionaryIterator* pDictIter= pDict->newIterator();//在这句后出现异常
BSCScaleClass *pMyCl;
for (; !pDictIter->done(); pDictIter->next()) {
// Get the current record, open it for read, and
// print its data.
//
pDictIter->getObject((AcDbObject*&)pMyCl,
AcDb::kForRead);
pMyCl->gethScale(hs);
pMyCl->getvScale(vs);
pMyCl->close();
acutPrintf("\nintval is: %d", hs);
}
delete pDictIter;
pDict->close(); getAt和getObject要判断返回值,尤其是第一个getAt直接影响下边的程序运行,除非你的:
AcDbDictionary *pDict;
改为
AcDbDictionary *pDict=NULL;
当然是最好直接判断返回值是否为Acad::eOk,仔细看看联机帮助吧
我把程序又改了一下,可还是有一些问题,版主再看一看给点意见!!谢谢
AcDbDictionary *pNamedobj;
acdbHostApplicationServices()->workingDatabase()
->getNamedObjectsDictionary(pNamedobj, AcDb::kForRead);
AcDbDictionary *pDict;
if (pNamedobj->getAt("SCALE_DICT", (AcDbObject*&) pDict,
AcDb::kForRead) == Acad::eOk)//程序运行通过,证明得到
{
AcDbDictionaryIterator* pDictIter= pDict->newIterator();
BSCScaleClass *pMyCl;
if (pDictIter!= NULL) {
for (; !pDictIter->done(); pDictIter->next()) {//程序在这一行不进入循环,但里面的我看了有数据,至少有一个
// Get the current record, open it for read, and
// print its data.
//
if (pDictIter->getObject((AcDbObject*&)pMyCl,
AcDb::kForRead)==Acad::eOk){
pMyCl->gethScale(hs);
pMyCl->getvScale(vs);
pMyCl->close();
acutPrintf("\nintval is: %d", hs);
}
}
}
/* pDictIter->next();
pDictIter->getObject((AcDbObject*&)pMyCl,
AcDb::kForRead);
pMyCl->gethScale(hs);
pMyCl->getvScale(vs);
pMyCl->close();
acutPrintf("\nintval is: %d", hs);*/
delete pDictIter;
}
pNamedobj->close();
pDict->close();请版主帮助,谢谢,!!!!!! 跪求!!! 请高手指点!! 你再检查检查其他地方 程序本身没有问题
页:
[1]