ade_odpresetfield

Land Desktop Development ARX CPP SDK

Up a level
ade_odpresetfield
 
 

Assigns a value to a field in a new record.

int

ade_odpresetfield(

ade_id rec_id,

char* field,

struct resbuf* value);

Returns RTNORM or an error code.

rec_id Record ID returned by ade_odnewrecord.
field Field name.
value Field value.

Sets the value of a field in an Object Data record defined through ade_odnewrecord.

The following sample creates a new object data record for "table1" using ade_odnewrecord(). A resbuf is created which contains the new value to be applied to "field1" in the new object data record. Ade_odpresetfield() is called with all required parameters. A selection set containing all entities in the current drawing is created, then each entity has the new object data record attached using ade_odattachrecord(). Ade_odfreerec() is called to free the memory claimed in defining a new record and the resbuf is released as required.

char* pszOdTable = "table1";
ade_id recordId = ade_odnewrecord(pszOdTable);
struct resbuf* pOdFieldValRb = acutBuildList(RTSTR, "Newvalue",0);
char* pszOdField = "field1";
int returnCode = ade_odpresetfield(recordId, pszOdField, pOdFieldValRb);
ads_name selectionSet;
acedSSGet("_x", NULL, NULL, NULL, selectionSet);
ads_name ename;
long ssLength;
acedSSLength(selectionSet, &ssLength;);
for( int i = 0; i < ssLength; ++i )
{
    if( acedSSName(selectionSet, i, ename) == RTNORM )
    {
        int returnCode = ade_odattachrecord(ename, recordId);
    }
}
returnCode = ade_odfreerec(recordId);
acutRelRb(pOdFieldValRb);