ObjectARX, AutoCAD. Среда программирования библиотеки C++


         

Notice that there is no


// Notice that there is no -3 group, as there is in

// LISP. This is ONLY the xdata, so

// the -3 xdata-start marker isn’t needed.

//

printList(pRb);

acutRelRb(pRb);

} else {

acutPrintf("\nNo xdata for this appname");

}

pObj->close();

}

void

addXdata()

{

AcDbObject* pObj = selectObject(AcDb::kForRead);

if (!pObj) {

acutPrintf("Error selecting object\n");

return;

}

// Get the application name and string to be added to

// xdata.

//

char appName[132], resString[200];

appName[0] = resString[0] = ’\0’;

acedGetString(NULL, "Enter application name: ",

appName);

acedGetString(NULL, "Enter string to be added: ",

resString);

struct resbuf *pRb, *pTemp;

pRb = pObj->xData(appName);

if (pRb != NULL) {

// If xdata is present, then walk to the

// end of the list.

//

for (pTemp = pRb; pTemp->rbnext != NULL; pTemp = pTemp->rbnext)

{ ; }

} else {

// If xdata is not present, register the application

// and add appName to the first resbuf in the list.

// Notice that there is no -3 group as there is in

// AutoLISP. This is ONLY the xdata so

// the -3 xdata-start marker isn’t needed.

//

acdbRegApp(appName);

pRb = acutNewRb(AcDb::kDxfRegAppName);

pTemp = pRb;

pTemp->resval.rstring

= (char*) malloc(strlen(appName) + 1);

strcpy(pTemp->resval.rstring, appName);

}

// Add user-specified string to the xdata.

//

pTemp->rbnext = acutNewRb(AcDb::kDxfXdAsciiString);

pTemp = pTemp->rbnext;

pTemp->resval.rstring

= (char*) malloc(strlen(resString) + 1);

strcpy(pTemp->resval.rstring, resString);

// The following code shows the use of upgradeOpen()

// to change the entity from read to write.

//

pObj->upgradeOpen();

pObj->setXData(pRb);

pObj->close();

acutRelRb(pRb);

}


Содержание  Назад  Вперед