- 积分
- 19110
- 明经币
- 个
- 注册时间
- 2003-8-16
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
//加扩展词典独立程序
bool SetEntityDictFromRbChain(AcDbObjectId entId,ACHAR *strDictName,resbuf* pRbValue)
{
AcDbEntityPointer pObj(entId,AcDb::kForWrite);
if (pObj.openStatus()!=Acad::eOk ) return false;
AcDbObjectId extDictId = pObj->extensionDictionary();
if (extDictId == AcDbObjectId::kNull)
{
Acad::ErrorStatus es = pObj->createExtensionDictionary();
if (es != Acad::eOk)
return false;
if ((extDictId = pObj->extensionDictionary()) == AcDbObjectId::kNull)
return false;
}
AcDbDictionaryPointer pDict(extDictId,AcDb::kForRead);
if(pDict.openStatus() != Acad::eOk)
return false;
AcDbObjectId xRecId;
if(pDict->getAt(strDictName,xRecId) != Acad::eOk)
{
AcDbXrecord* pXrec = new AcDbXrecord();
//pXrec 可以使用scoped_ptr
pDict->upgradeOpen();
if(pDict->setAt(strDictName,pXrec,xRecId) != Acad::eOk)
{
delete pXrec;
return false;
}
pXrec->close();
}
AcDbObjectPointer<AcDbXrecord> pXrcord(xRecId,AcDb::kForWrite);
if(pXrcord.openStatus() != Acad::eOk) return false;
if(pXrcord->setFromRbChain(*pRbValue) != Acad::eOk) return false;
acutRelRb(pRbValue);
return true;
}
下面是调用增加扩展词典示例程序代码
ads_point p1;
ads_name Ename,WKEname;
AcDbObjectId ObjID,BMBKObjID;
if (acedEntSel(_T("\n选对象1:"),WKEname,p1)!=RTNORM)return;
acdbGetObjectId(BMBKObjID,WKEname);
if (acedEntSel(_T("\n选对象2:"),Ename,p1)==RTNORM)
{
acdbGetObjectId(ObjID,Ename);
acutRelRb(XreDa);
XreDa=acutBuildList(RTENAME,WKEname,0);
ACHAR Tempchar[MAX_PATH];
_tcscpy(Tempchar,_T("TestXre"));
SetEntityDictFromRbChain(ObjID,Tempchar,XreDa);
}
今天测试,这个加词典的涵数在VS2008 写的ARX2010至2012均能成功加上,然后我把代码放上VS2012写的ARX2015去测试经过调试发现程序运行到if(pXrcord->setFromRbChain(*pRbValue) != Acad::eOk) return false; 这句就不成功退出程序。百思不得其解,发上来请教一下大侠们如何解决ARX2015上面增加词典与的这段小程序。 |
|