再贴一个,希望对你有帮助 Adesk::Boolean SetIsOff (const char* lyrname, bool off) { AcDbLayerTable *pLyrTable; AcDbLayerTableRecord *pLyrTblRecord; AcDbDatabase *pCurDb = NULL; pCurDb = acdbHostApplicationServices()->workingDatabase(); // 获得当前图形的层表 pCurDb->getLayerTable(pLyrTable, AcDb::kForRead); AcDbObjectId lyrId; // 是否已经包含指定的层表记录 if (!pLyrTable->has(lyrname) && !(lyrname == "*")) { pLyrTable->close(); return Adesk::kFalse; } else { pLyrTable->getAt(lyrname, lyrId); } AcDbLayerTableIterator *pItr; pLyrTable->newIterator(pItr); if (lyrname == "*") { for (pItr->start(); !pItr->done(); pItr->step()) { // 遍历器记录 pItr->getRecord(pLyrTblRecord, AcDb::kForWrite); pLyrTblRecord->setIsOff(off); pLyrTblRecord->close(); } } else { for (pItr->start(); !pItr->done(); pItr->step()) { // 遍历器记录 if(pItr->seek(lyrId) == Acad::eOk) { pItr->getRecord(pLyrTblRecord, AcDb::kForWrite); pLyrTblRecord->setIsOff(off); pLyrTblRecord->close(); break; } } } delete pItr; pLyrTable->close(); return Adesk::kTrue; } |