Symbol Table Access

The acdbTblNext() function sequentially scans symbol table entries, and the acdbTblSearch() function retrieves specific entries. Table names are specified by strings. The valid names are “LAYER”, “LTYPE”, “VIEW”, “STYLE”, “BLOCK”, “UCS”, “VPORT”, and “APPID”. Both of these functions return entries as result-buffer lists with DXF group codes.

The first call to acdbTblNext() returns the first entry in the specified table. Subsequent calls that specify the same table return successive entries unless the second argument to acdbTblNext() (rewind) is nonzero, in which case acdbTblNext() returns the first entry again.

In the following example, the function getblock() retrieves the first block (if any) in the current drawing, and calls the printdxf() function to display that block's contents in a list format.

void getblock() 
{ 
    struct resbuf *bl, *rb; 
    bl = acdbTblNext("BLOCK", 1); // First entry  
    acutPrintf("\nResults from getblock():\n"); 
// Print items in the list as "assoc" items.
    for (rb = bl; rb != NULL; rb = rb->rbnext) 
        printdxf(rb); 
    // Release the acdbTblNext list.
    acutRelRb(bl); 
} 

Entries retrieved from the BLOCK table contain a -2 group that contains the name of the first entity in the block definition. In a drawing with a single block named BOX, a call to getblock() prints the following (the name value varies from session to session):

Results from getblock():

(0 . "BLOCK")

(2 . "BOX")

(70 . 0)

(10 9.0 2.0 0.0)

(-2 . <Entity name: 40000126>)

The first argument to acdbTblSearch() is a string that names a table, but the second argument is a string that names a particular symbol in the table. If the symbol is found, acdbTblSearch() returns its data. This function has a third argument, setnext, that can be used to coordinate operations with acdbTblNext(). If setnext is zero, the acdbTblSearch() call has no effect on acdbTblNext(), but if setnext is nonzero, the next call to acdbTblNext() returns the table entry that follows the entry found by acdbTblSearch().

The setnext option is especially useful when dealing with the VPORT symbol table, because all viewports in a particular viewport configuration have the same name (such as *ACTIVE).

Keep in mind that if the VPORT symbol table is accessed when TILEMODE is off, changes have no visible effect until TILEMODE is turned back on. (TILEMODE is set either by the SETVAR command or by entering its name directly.) Do not confuse the VPORT symbol table with viewport entities.

To find and process each viewport in the configuration named 4VIEW, you might use the following code:

struct resbuf *v, *rb; 
v = acdbTblSearch("VPORT", "4VIEW", 1); 
while (v != NULL} { 
    for (rb = v; rb != NULL; rb = rb->rbnext) 
        if (rb->restype == 2) 
            if (strcmp(rb->resval.rstring, "4VIEW") == 0) { 
                .// Process the VPORT entry  
                . 
                . 
                acutRelRb(v); 
 		// Get the next table entry.
                v = acdbTblNext("VPORT", 0); 
            } else { 
                acutRelRb(v); 
                v = NULL; // Break out of the while loop.
                break; // Break out of the for loop.
            } 
}