Retrieving Extended Data

An application can obtain registered extended data by calling the acdbEntGetX() function, which is similar to acdbEntGet(). While acdbEntGet() returns only definition data, acdbEntGetX() returns both the definition data and the extended data for the applications it requests. It requires an additional argument, apps, that specifies the application names (this differs from AutoLISP, in which the (entget) function has been extended to accept an optional argument that specifies application names). The names passed to acdbEntGetX() must correspond to applications registered by a previous call to acdbRegApp(); they can also contain wild-card characters. If the apps argument is a NULL pointer, the call to acdbEntGetX() is identical to an acdbEntGet() call.

The following sample code fragment shows a typical sequence for retrieving extended data for two specified applications. Note that the apps argument passes application names in linked result buffers.

static struct resbuf    appname2 = {NULL, RTSTR}, 
                        appname1 = {&appname2, RTSTR}, 
                        *working_ent; 
strsave(appname1.rstring, "MY_APP_1"); 
strsave(appname2.rstring, "SOMETHING_ELSE"); 
. 
. 
. 
// Only extended data from "MY_APP_1" and 
// "SOMETHING_ELSE" are retrieved:  
working_ent = acdbEntGetX(&work_ent_addr, &appname1); 
if (working_ent == NULL) { 
    // Gracefully handle this failure.  
    . 
    . 
    . 
} 
// Update working entity groups.
status = acdbEntMod(working_ent); 
// Only extended data from registered applications still in the
// working_ent list are modified.  

As the sample code shows, extended data retrieved by the acdbEntGetX() function can be modified by a subsequent call to acdbEntMod(), just as acdbEntMod() is used to modify normal definition data. (Extended data can also be created by defining it in the entity list passed to acdbEntMake().)

Returning the extended data of only specifically requested applications protects one application from damaging the data of another application. It also controls the amount of memory that an application uses, and simplifies the extended data processing that an application performs.

Note: Because the strings passed with apps can include wild-card characters, an application name of “*” will cause acdbEntGetX() to return all extended data attached to an entity.