|
发表于 2004-7-9 17:01:00
|
显示全部楼层
可以参考一下这个例子: void addXdata()
{
struct resbuf* prbX;
char appname[] = {"SPACEH"};
char windotype[] = {"Rect"};
ads_name ename;
AcDbObjectId entId;
AcDbObject* pObj;
AcGePoint2d sp(getWindowStartPoint());
ads_point lwrleft;
lwrleft[X] = sp.x;
lwrleft[Y] = sp.y;
lwrleft[Z] = 0.0;
acdbRegApp("SPACEH");
prbX = acutBuildList(AcDb::kDxfRegAppName, appname,
AcDb::kDxfXdAsciiString, windotype,
AcDb::kDxfXdInteger32, getWindowRows(),
AcDb::kDxfXdInteger32, getWindowCols(),
AcDb::kDxfXdReal, getWindowLength(),
AcDb::kDxfXdReal, getWindowHeight(),
AcDb::kDxfXdWorldXCoord, lwrleft,
RTNONE);
// Get the last entity
acdbEntLast(ename);
// Get the entity object ID
acdbGetObjectId(entId, ename);
// Open the enity for a write operation
acdbOpenObject(pObj, entId, AcDb::kForWrite);
// Add the extended entity data to the entity
pObj->setXData(prbX);
pObj->close();
acutRelRb(prbX);
}
void printXdata()
{
struct resbuf* prbX;
struct resbuf* pTemp;
char appname[] = {"SPACEH"};
ads_name ename;
AcDbObjectId entId;
AcDbObject* pObj;
// Get the last entity
acdbEntLast(ename);
// Get the entity object ID
acdbGetObjectId(entId, ename);
// Open the enity for a write operation
acdbOpenObject(pObj, entId, AcDb::kForRead);
// Add the extended entity data to the entity
prbX = pObj->xData(appname);
pObj->close();
// Print out the extended entity data
// Here I know the order of the extended entity data
pTemp = prbX;
// Bypass the application name
pTemp = pTemp->rbnext;
acutPrintf("\nWindow Type = %s", pTemp->resval.rstring);
pTemp = pTemp->rbnext;
acutPrintf("\nRows = %d", pTemp->resval.rint);
pTemp = pTemp->rbnext;
acutPrintf("\nCols = %d", pTemp->resval.rint);
pTemp = pTemp->rbnext;
acutPrintf("\nLength = %.2lf", pTemp->resval.rreal);
pTemp = pTemp->rbnext;
acutPrintf("\nHeight = %.2lf", pTemp->resval.rreal);
pTemp = pTemp->rbnext;
acutPrintf("\nStart Point = (%.2lf, %.2lf)", pTemp->resval.rpoint[X], pTemp->resval.rpoint[Y]);
acutRelRb(prbX);
} |
|