下面是一个完整的函数,供参考。
void affixXdata(char *appName, char *xData, AcDbObject *pObj)
{
//向AcDbObject添加扩展数据Xdata
struct resbuf *pRb, *pTemp;
acdbRegApp(appName);
pRb = acutNewRb(AcDb::kDxfRegAppName);
pTemp = pRb;
pTemp->resval.rstring = new char[strlen(appName)+1];
strcpy(pTemp->resval.rstring, appName);
pTemp->rbnext = acutNewRb(AcDb::kDxfXdAsciiString);
pTemp = pTemp->rbnext;
pTemp->resval.rstring = new char[strlen(xData)+1];
strcpy(pTemp->resval.rstring, xData);
pObj->setXData(pRb);
acutRelRb(pRb);
} |