Creating a New Layer

The following code obtains the layer symbol table from the database, creates a new layer table record, and names it (ASDK_MYLAYER). The layer table record is then added to the layer table.

void
createNewLayer()
{
    AcDbLayerTable *pLayerTable;
    acdbHostApplicationServices()->workingDatabase()
        ->getSymbolTable(pLayerTable, AcDb::kForWrite);
    AcDbLayerTableRecord *pLayerTableRecord =
        new AcDbLayerTableRecord;
    pLayerTableRecord->setName("ASDK_MYLAYER");
    // Defaults are used for other properties of 
    // the layer if they are not otherwise specified.
    //
    pLayerTable->add(pLayerTableRecord);
    pLayerTable->close();
    pLayerTableRecord->close();
}