// 判斷是否存在名稱為“LAY”的圖層
AcDbLayerTable *pLayerTbl;
//擷取目前圖形層表
acdbHostApplicationServices()->workingDatabase()->getLayerTable(pLayerTbl, AcDb::kForWrite);
if (pLayerTbl->has(_T("LAY")))
{
pLayerTbl->close();
return;
}
acutPrintf(_T("\n目前圖形中未包含\"LAY\"圖層!"));
AcDbLayerTableRecord *pLayerTblRcd = new AcDbLayerTableRecord();
pLayerTblRcd->setName(_T("LAY"));
AcDbObjectId layerTblRcdId;
pLayerTbl->add(layerTblRcdId, pLayerTblRcd);
AcCmColor color;//設定圖層顔色
color.setColorIndex();
pLayerTblRcd->setColor(color);
// 将建立的層表記錄添加到層表中
pLayerTblRcd->close();
pLayerTbl->close();
acdbHostApplicationServices()->workingDatabase()->setClayer(layerTblRcdId);//設為目前圖層