[求助]AcDbDictionary问题
本帖最后由 作者 于 2007-11-29 18:07:50 编辑我以前用lsp写的程序中,使用了命名辞典. lsp函数: vlax-ldata-put DictName Key Value.
这个命名词典:命令: (vlax-ldata-list "Dream.Fei")
(("vpscale" . 45) ("Printscale" . "45") ("pmlx" . "3") ("blkn" . "2006112810484498"))名称: Dream.Fei
包含的数据: (("vpscale" . 45) ("Printscale" . "45") ("pmlx" . "3") ("blkn" . "2006112810484498"))
我现在想取出 "PrintScale" 这个key 所对应的值来. 请问用C++应该怎么搞?
我现在写成这样出错:
AcDbDictionary *pNameObj = NULL;
if (acdbHostApplicationServices()->workingDatabase()->getNamedObjectsDictionary(pNameObj, AcDb::kForRead) != Acad::eOk)
return;
AcDbObjectId dictId = NULL;
if (pNameObj->getAt(_T("Dream.Fei"), dictId) != Acad::eOk)
{
pNameObj->close();
return;
}
pNameObj->close();
AcDbXrecord *pXrec = NULL;
if(acdbOpenObject((AcDbObject*&)pXrec, dictId, AcDb::kForRead) != Acad::eOk)
return;
struct resbuf *pRb = NULL;
pXrec->rbChain(&pRb);
pXrec->close();
if (pRb != NULL)
{
struct resbuf *tmp;
tmp = pRb;
while (tmp)
{
acutPrintf(_T("\n获取的字符串数据: %s"),tmp->resval.rstring );
tmp= pRb->rbnext;
}
acutRelRb(pRb);
}
如果您打算回答我去看帮助文档的话. 我看你还是不要回复了,省得浪费大家时间. 帮助我已经看过了,对不上号.
把函数改动了一下,但还是取不到值:static void PlanType_tst(void)
{
AcDbDictionary *pNameObj = NULL;
if (acdbHostApplicationServices()->workingDatabase()->getNamedObjectsDictionary(pNameObj, AcDb::kForRead) == Acad::eOk)
{
AcDbDictionary *pDict = NULL;
if(pNameObj->getAt(_T("Dream.Fei"), (AcDbObject*&)pDict, AcDb::kForRead) == Acad::eOk)
{
AcDbXrecord *pXrecd = NULL;
if (pDict->getAt(_T("PrintScale"), (AcDbObject*&)pXrecd, AcDb::kForRead) == Acad::eOk)
{
struct resbuf *pRb = NULL;
pXrecd->rbChain(&pRb);
if (pRb != NULL)
acutPrintf(_T("\n得到的结果: %s."), pRb->resval.rstring);
pXrecd->close();
acutRelRb(pRb);
}
pDict->close();
}
pNameObj->close();
}
}
页:
[1]