求助:xdata
代码运行到出错,添加时候出错pObj->close();acutRelRb(pRb);
return TRUE;请教:源码如下: 代码:
bool AddXData(ads_name ename,ACHAR *appname,ACHAR *resString){
struct resbuf *pRb=NULL,*pTemp;
AcDbObjectId objId;
AcDbObject *pObj;
if(acdbGetObjectId(objId,ename)!=Acad::eOk)return 0;
acdbOpenObject(pObj,objId,AcDb::kForWrite);
pRb=pObj->xData(appname);
if (pRb==NULL) {
acdbRegApp(appname);
pRb=acutNewRb(AcDb::kDxfRegAppName);
pTemp=pRb;
pTemp->resval.rstring=(ACHAR*)malloc(_tcslen(appname)+1);
_tcscpy(pTemp->resval.rstring,appname);
}else{
for (pTemp=pRb;pTemp->rbnext!=NULL;pTemp=pTemp->rbnext) {;}
}
pTemp->rbnext=acutNewRb(AcDb::kDxfXdAsciiString);
pTemp=pTemp->rbnext;
pTemp->resval.rstring=(ACHAR*)malloc(_tcslen(resString)+1);
_tcscpy(pTemp->resval.rstring,resString);
//pObj->upgradeOpen();
pObj->setXData(pRb);
pObj->close();
acutRelRb(pRb);
return TRUE;
}
static void S001xdata_2_MyCommand1(void)
{ ads_name ename;
ads_point pt1;
if (acedEntSel(L"\n请选择对象:",ename,pt1)!=RTNORM)return;
ACHAR appname,resString;
_tcscpy(appname, L"abcd");
_tcscpy(resString,L"BDYCAD在学习ARX");
//if (acedGetString(NULL,"\n请输入扩展名:",appname)!=RTNORM)return;
//if (acedGetString(NULL,"\n请输入扩展数据的内容吧:",resString)!=RTNORM)return;
AddXData(ename,L"abcd",resString);
//return;
}
}
请大神出手,谢谢
页:
[1]