Sets a field value.
int
ade_odsetfield(
ads_name ename,
char* table,
char* field,
int recnum,
struct resbuf* value);
Returns RTNORM or an error code.
ename | AutoCAD object name. |
table | Table name can be up to 25 characters long. Must be unique, contain no spaces, and start with an alphanumeric character. |
field | Field name can be up to 31 characters long. Must be unique, contain no spaces, and start with an alphanumeric character. |
recnum | Record number; the first record number is 0. |
value | New field value. |
To identify a unique record, you need to specify the table to which it belongs, the object to which it is attached, and its record number. The record number is necessary because more than one record from the same table can be attached to an object. For more information about records and record numbers, see ade_odaddrecord.
The following sample creates a resbuf containing the updated field value. A selection set of all entities in the current drawing is created using acedSSGet(). Each entity in the selection set is passed to ade_odsetfield() with all required parameters, the returned result code is checked for RTNORM and displayed. Then it releases the resbuf, as required.
char* pszOdTable = "table1"; ade_id recordId = ade_odnewrecord(pszOdTable); struct resbuf* pOdSetFieldValRb = acutBuildList(RTSTR, "Newvalue", 0); int recnum = 0; char* pszOdField = "field1"; ads_name selectionSet; ads_name ename; 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_odsetfield( ename, pszOdTable, pszOdField, recnum, pOdSetFieldValRb); if (RTNORM == nResultCode) { acutPrintf( "\nThe field value for the specified record has been modified."); } else { acutPrintf( "\nThe field value for the specified record has not been modified."); } } } acutRelRb(pOdSetFieldValRb);