Attaches data to an object.
int
ade_odaddrecord(
ads_name ename,
char* table);
Returns RTNORM or an error code.
| ename | An AutoCAD object name. |
| table | The table name, which can be up to 25 characters long. It must be unique, contain no spaces, and start with an alphanumeric character. |
Attaching data to an object is also called attaching a table to an object. This function attaches a new record in a specific table to a specific object. Typically, a record contains information about whatever it is that the object represents. For example, if a line in a drawing represents a section of pipe in a water system, an attached record could contain information about that section.
When a new record is attached, its fields contain default values that correspond to their field definitions. To get a field value, use ade_odgetfield; to change it, use ade_odsetfield. Field definitions are included in the table definition. See ade_oddefinetab for information about table definitions.
You can attach more than one record to the same object with additional calls to ade_odaddrecord. The additional records can be members of the same or different tables. If an object has only one record from a given table, the number of that record is 0. If you attach a second record from the same table, the number of that record is 1, and so on. Use ade_odrecordqty to find how many records of a given table are attached.
For example, if a section of water pipe is inspected at intervals, you could attach a number of records of the WATER INSPECTION table to the same line in the WATER drawing, and each record could contain the result of a different inspection.
The following sample creates a selection set of all entities in the current drawing using acedSSGet(). Each entity is then passed to ade_odaddrecord() with all required parameters. The result code returned by ade_odaddrecord() is displayed. Then it releases the resbuf, as required.
ads_name selectionSet;
ads_name ename;
char* pszOdTable = "table1";
acedSSGet("x", NULL, NULL, NULL, selectionSet);
long ssLength;
acedSSLength( selectionSet, &ssLength; );
for( int i = 0; i < ssLength; ++i )
{
if( acedSSName(selectionSet, i, ename) == RTNORM )
{
int nResultCode = ade_odaddrecord(ename, pszOdTable);
if (RTNORM == nResultCode) {
acutPrintf(
"\nThe specified record has been added.");
}
else {
acutPrintf(
"\nThe specified record has not been added.");
}
}
}


