Iterating over Tables

The code in the following example creates an iterator that walks through the symbol table records in the linetype table. It obtains each record, opens it for read, obtains the linetype name, closes the record, and then prints the linetype name. At the end, the program deletes the iterator.

void
iterateLinetypes()
{
    AcDbLinetypeTable *pLinetypeTbl;
    acdbHostApplicationServices()->workingDatabase()
        ->getSymbolTable(pLinetypeTbl, AcDb::kForRead);
    // Create a new iterator that starts at table
    // beginning and skips deleted.
    //
    AcDbLinetypeTableIterator *pLtIterator;
    pLinetypeTbl->newIterator(pLtIterator);
    // Walk the table, getting every table record and
    // printing the linetype name.
    //
    AcDbLinetypeTableRecord *pLtTableRcd;
    char *pLtName;
    for (; !pLtIterator->done(); pLtIterator->step()) {
        pLtIterator->getRecord(pLtTableRcd, AcDb::kForRead);
        pLtTableRcd->getName(pLtName);
        pLtTableRcd->close();
        acutPrintf("\nLinetype name is:  %s", pLtName);
        free(pLtName);
    }
    delete pLtIterator;
    pLinetypeTbl->close();
}