leidiang 发表于 2005-3-1 16:58:00

[求助]数据字典问题, 出异常!!请指点谢谢!!!

我得到数据字典类时,出现异常,不知道为什么,谢谢,下面是代码.
                       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();

中国虫 发表于 2005-3-2 08:48:00

getAt和getObject要判断返回值,尤其是第一个getAt直接影响下边的程序运行,除非你的:
AcDbDictionary *pDict;
改为
AcDbDictionary *pDict=NULL;
当然是最好直接判断返回值是否为Acad::eOk,仔细看看联机帮助吧

leidiang 发表于 2005-3-2 15:57:00

我把程序又改了一下,可还是有一些问题,版主再看一看给点意见!!谢谢
                       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();请版主帮助,谢谢,!!!!!!

leidiang 发表于 2005-3-4 15:03:00

跪求!!!

leidiang 发表于 2005-3-6 17:15:00

请高手指点!!

dipenghao 发表于 2005-3-6 19:12:00

你再检查检查其他地方 程序本身没有问题
页: [1]
查看完整版本: [求助]数据字典问题, 出异常!!请指点谢谢!!!