tpm_cleanalloc

Land Desktop Development ARX CPP SDK

Up a level
tpm_cleanalloc
 
 

Allocates the cleanup model.

ade_id

tpm_cleanalloc();

Returns the model ID (real) or ADE_NULLID.

To clean the objects before they become the elements of a topology, you must construct a model of these objects and their relationships. You can use this model to discover and repair drawing errors that would prevent topology creation.

The following example allocates a cleanup model, initializes the cleanup model, counts errors by group type and subtype, and frees the cleanup model.

ade_id var_id = ADE_NULLID;        // variable ID
ade_id cln_id = ADE_NULLID;        // clean ID
ads_name ss;                       // selection set
long qty = 0;                      // quantity
int type = 0;                      // clean error group type
int subtype = 0;                   // clean error group subtype
int done = 0;
int result = 0;
 
var_id = tpm_varalloc();
cln_id = tpm_cleanalloc();
 
if( ! var_id || ! cln_id ) {
ads_printf("\nMemory allocation failed.");
tpm_varfree(var_id);
tpm_cleanfree(cln_id);
 
return;
}
 
// initialize a set of objects, in selection set ss,
// to clean
tpm_cleaninit(cln_id, var_id, ss);
result = tpm_cleanstart(cln_id);
 
if( result != RTNORM ) {
      ads_printf("\nClean startup failed."); 
      tpm_varfree(var_id); 
      tpm_cleanfree(cln_id); 
      return; 
}
 
// Count errors by group type and subtype
while ( ! done) {
result = tpm_cleangroupnext(cln_id);
   if ( result == RTNORM ) { 
      result = tpm_cleancomplete(cln_id); 
      if ( result == RTNORM ) 
         done = 1; 
      else { 
         type = tpm_cleangrouptype(cln_id); 
         subtype = tpm_cleangroupsubtype(cln_id); 
         tpm_cleangroupqty(cln_id, &qty;); 
         ads_printf("Group type, subtype: %d,%d 
               Number of errors: %d", type, subtype, qty); 
      } // else 
   } // if 
} // while
 
tpm_cleanfree(cln_id);
tpm_varfree(var_id);