乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 20|回复: 1

[求助]各位高手帮帮忙:(扩展字典问题)

[复制链接]

12

主题

54

帖子

1

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
102
发表于 2005-4-1 20:30:00 | 显示全部楼层 |阅读模式
我想为各个层添加扩展字典,来记录层上的一些信息,下面是我的函数(我把层名作为字典的名字)
CreateDictionary()
{
       
        AcDbObjectId pCurLayerId;
        pCurLayerId=acdbHostApplicationServices()->workingDatabase()->clayer();       
        AcDbLayerTableRecord* pTRec;
        acdbOpenObject(pTRec,pCurLayerId,AcDb::kForWrite);       
        pTRec->createExtensionDictionary();
        AcDbObjectId dictObjId,xrecObjId;
        AcDbXrecord *pXrec = new AcDbXrecord;
        AcDbDictionary* pDict;
        dictObjId=pTRec->extensionDictionary();
        pTRec->close();
        acdbOpenObject(pDict,dictObjId,AcDb::kForWrite);
        pDict->setAt(pCLname,pXrec,xrecObjId);
        pDict->close();
               
        resbuf* head;
        head=acutBuildList(AcDb::kDxfText,name,AcDb::kDxfReal,area,AcDb::kDxfReal,
                RLength,AcDb::kDxfReal,RWidth,AcDb::kDxfInt16,num,RTNONE);
        pXrec->setFromRbChain(*head);
        pXrec->close();
        acutRelRb(head);
}//其中name、area、length、Width、num分别为CString double double double int型
为了验证扩展字典的正确性,我编写了下面的函数进行验证
ReadDictionary(CString name)
{
        AcDbLayerTable *pLayer;
        AcDbLayerTableRecord *pRec;
        AcDbObjectId dictObjId;
        AcDbDictionary *pDict;
        AcDbXrecord *pXrec;         acdbHostApplicationServices()->workingDatabase()
                ->getSymbolTable(pLayer,AcDb::kForRead);
        pLayer->getAt(name,pRec,AcDb::kForRead);
        pLayer->close();
        dictObjId=pRec->extensionDictionary();
        pRec->close();
        acdbOpenObject(pDict,dictObjId,AcDb::kForRead);
        pDict->getAt(name,(AcDbObject*&)pXrec,AcDb::kForRead);
        pDict->close();
        struct resbuf* pRbList;
        pXrec->rbChain(&pRbList);
        pXrec->close();
        pRbList->rbnext;//从第二个数据开始输出
        acedPrintf("area=%f\n",pRbList->resval.rreal);
        pRbList->rbnext;
        acedPrintf("length=%f\n",pRbList->resval.rreal);
        pRbList->rbnext;
        acedPrintf("width=%f\n",pRbList->resval.rreal);
        pRbList->rbnext;
        acedPrintf("num=%f\n",pRbList->resval.rint);
        acutRelRb(pRbList);
}
编译运行都没有问题,可就是得不到我输入的结果,请问各位高手,我的程序哪里有问题;还是不可以为层添加扩展词典
回复

使用道具 举报

12

主题

54

帖子

1

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
102
发表于 2005-4-8 12:12:00 | 显示全部楼层
问题解决了,这是一个愚蠢而低级的错误出错的地方我已经做了标注,下面是改进后的代码,希望大家不要犯和我类似的错误
        resbuf *pRbList;
        resbuf *pTemp;
        pXrec->rbChain(&pRbList);
        pTemp=pRbList;
        pXrec->close();
        pTemp=pTemp->rbnext;
        acedPrintf("area=%f\n",pRbList->resval.rreal);
        pTemp=pTemp->rbnext;
        acedPrintf("length=%f\n",pRbList->resval.rreal);
        pTemp=pTemp->rbnext;
        acedPrintf("width=%f\n",pRbList->resval.rreal);
        pTemp=pTemp->rbnext;
        acedPrintf("num=%f\n",pRbList->resval.rint);
        acutRelRb(pRbList);
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-2-5 08:05 , Processed in 0.234385 second(s), 56 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表