[求助]各位高手帮帮忙:(扩展字典问题)
本帖最后由 作者 于 2005-4-8 12:03:49 编辑 <br /><br /> 我想为各个层添加扩展字典,来记录层上的一些信息,下面是我的函数(我把层名作为字典的名字)<BR>CreateDictionary()<BR>{<BR> <BR> AcDbObjectId pCurLayerId;<BR> pCurLayerId=acdbHostApplicationServices()->workingDatabase()->clayer(); <BR> AcDbLayerTableRecord* pTRec;<BR> acdbOpenObject(pTRec,pCurLayerId,AcDb::kForWrite); <BR> pTRec->createExtensionDictionary();<BR> AcDbObjectId dictObjId,xrecObjId;<BR> AcDbXrecord *pXrec = new AcDbXrecord;<BR> AcDbDictionary* pDict;<BR> dictObjId=pTRec->extensionDictionary();<BR> pTRec->close();<BR> acdbOpenObject(pDict,dictObjId,AcDb::kForWrite);<BR> pDict->setAt(pCLname,pXrec,xrecObjId);<BR> pDict->close();<BR> <BR> resbuf* head;<BR> head=acutBuildList(AcDb::kDxfText,name,AcDb::kDxfReal,area,AcDb::kDxfReal,<BR> RLength,AcDb::kDxfReal,RWidth,AcDb::kDxfInt16,num,RTNONE);<BR> pXrec->setFromRbChain(*head);<BR> pXrec->close();<BR> acutRelRb(head);<BR>}//其中name、area、length、Width、num分别为CString double double double int型<BR>为了验证扩展字典的正确性,我编写了下面的函数进行验证<BR>ReadDictionary(CString name)<BR>{<BR> AcDbLayerTable *pLayer;<BR> AcDbLayerTableRecord *pRec;<BR> AcDbObjectId dictObjId;<BR> AcDbDictionary *pDict;<BR> AcDbXrecord *pXrec;acdbHostApplicationServices()->workingDatabase()<BR> ->getSymbolTable(pLayer,AcDb::kForRead);<BR> pLayer->getAt(name,pRec,AcDb::kForRead);<BR> pLayer->close();<BR> dictObjId=pRec->extensionDictionary();<BR> pRec->close();<BR> acdbOpenObject(pDict,dictObjId,AcDb::kForRead);<BR> pDict->getAt(name,(AcDbObject*&)pXrec,AcDb::kForRead);<BR> pDict->close();<BR> struct resbuf* pRbList;<BR> pXrec->rbChain(&pRbList);<BR> pXrec->close();<BR> <FONT style="BACKGROUND-COLOR: #d5d52b">pRbList->rbnext</FONT>;//从第二个数据开始输出
acedPrintf("area=%f\n",pRbList->resval.rreal);<BR> <FONT style="BACKGROUND-COLOR: #cccc33">pRbList->rbnext</FONT>;<BR> acedPrintf("length=%f\n",pRbList->resval.rreal);<BR><FONT style="BACKGROUND-COLOR: #d5d52b"> pRbList->rbnext;<BR></FONT> acedPrintf("width=%f\n",pRbList->resval.rreal);<BR> <FONT style="BACKGROUND-COLOR: #d5d52b">pRbList->rbnext;<BR></FONT> acedPrintf("num=%f\n",pRbList->resval.rint);<BR> acutRelRb(pRbList);<BR>}<BR>编译运行都没有问题,可就是得不到我输入的结果,请问各位高手,我的程序哪里有问题;还是不可以为层添加扩展词典<BR> 问题解决了,这是一个愚蠢而低级的错误出错的地方我已经做了标注,下面是改进后的代码,希望大家不要犯和我类似的错误
resbuf *pRbList;<BR> resbuf *pTemp;<BR> pXrec->rbChain(&pRbList);<BR> pTemp=pRbList;<BR> pXrec->close();<BR> pTemp=pTemp->rbnext;<BR> acedPrintf("area=%f\n",pRbList->resval.rreal);<BR> pTemp=pTemp->rbnext;<BR> acedPrintf("length=%f\n",pRbList->resval.rreal);<BR> pTemp=pTemp->rbnext;<BR> acedPrintf("width=%f\n",pRbList->resval.rreal);<BR> pTemp=pTemp->rbnext;<BR> acedPrintf("num=%f\n",pRbList->resval.rint);<BR> acutRelRb(pRbList);<BR>
页:
[1]