lili0602 发表于 2009-10-27 15:08:00

求助 创建字典 异常

请教各位,我创建一个新字典(ASDK_DICT),将它添加到命名对象字典中,创建了一个类abc的对象,使用setAt函数将其添加到字典中。但在setAt函数中出现异常,代码如下:<br/><br/>&nbsp; &nbsp; &nbsp; &nbsp; AcDbDictionary *pNamedObj;<br/>&nbsp; &nbsp; &nbsp; &nbsp; AcDbDictionary *pNameList;<br/>&nbsp; &nbsp; &nbsp; &nbsp; <br/>&nbsp; &nbsp; &nbsp; &nbsp; <br/>&nbsp; &nbsp; &nbsp; &nbsp; acdbHostApplicationServices()-&gt;workingDatabase()<br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; -&gt;getNamedObjectsDictionary(pNamedObj,AcDb::kForWrite);<br/>&nbsp; &nbsp; &nbsp; &nbsp; <br/>&nbsp; &nbsp; &nbsp; &nbsp; if (pNamedObj-&gt;getAt("ASDK_DICT",<br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (AcDbObject*&amp;)pNameList, AcDb::kForWrite)<br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; == Acad::eKeyNotFound)<br/>&nbsp; &nbsp; &nbsp; &nbsp; {<br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pNameList = new AcDbDictionary;<br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AcDbObjectId DictId;<br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pNamedObj-&gt;setAt("ASDK_DICT", pNameList, DictId);<br/>&nbsp; &nbsp; &nbsp; &nbsp; }<br/>&nbsp; &nbsp; &nbsp; &nbsp; pNamedObj-&gt;close();<br/><br/>&nbsp; &nbsp; &nbsp; &nbsp; <br/>&nbsp; &nbsp; &nbsp; &nbsp; abc *p1=new abc(1);<br/>&nbsp; &nbsp; &nbsp; &nbsp; <br/>&nbsp; &nbsp; &nbsp; &nbsp; AcDbObjectId objId;<br/>&nbsp; &nbsp; &nbsp; &nbsp; if ((pNameList-&gt;getAt("dict1", objId))<br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; == Acad::eKeyNotFound)<br/>&nbsp; &nbsp; &nbsp; &nbsp; {<br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pNameList-&gt;setAt("dict1", p1, objId);&nbsp; &nbsp;&nbsp; &nbsp; //出现异常<br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; p1-&gt;close();<br/>&nbsp; &nbsp; &nbsp; &nbsp; } else {<br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; delete p1;<br/>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ads_printf("dict1 already exists\n");<br/>&nbsp; &nbsp; &nbsp; &nbsp; }<br/>&nbsp; &nbsp; &nbsp; &nbsp; <br/>&nbsp; &nbsp; &nbsp; &nbsp; acutPrintf("创建字典成功!\n");<br/><br/>请教各位这是什么原因呢?应该怎样改呢?谢谢!
页: [1]
查看完整版本: 求助 创建字典 异常