Message 1 of 1
Close the layer where the selected graphic element is located
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Acad::ErrorStatus es = Acad::eOk;
ads_name ss;
const TCHAR* szTempPrompts[2] = { _T("\n请选择需要关闭图层的对象<退出>:"), _T("") };
if (acedSSGet(_T(":$:S"), szTempPrompts, NULL, NULL, ss) != RTNORM) { return; }
ads_name ent;
acedSSName(ss, 0, ent);
AcDbObjectId id = AcDbObjectId::kNull;
acdbGetObjectId(id, ent);
AcDbEntity *pEnt = NULL;
if (acdbOpenObject(pEnt, id, AcDb::kForRead) == Acad::eOk)
{
AcDbObjectId layerId = pEnt->layerId();
ACHAR* layerName = pEnt->layer();
AcDbLayerTable* pLayerTable;
es = acdbHostApplicationServices()->workingDatabase()->getLayerTable(pLayerTable, AcDb::kForRead);
if (es != Acad::eOk) {
acutPrintf(_T("\n无法打开图层表。"));
pEnt->close();
return;
}
AcDbLayerTableRecord* pLayer;
es = pLayerTable->getAt(layerName, pLayer, AcDb::kForWrite);
if (es != Acad::eOk) {
acutPrintf(_T("\n无法获取图层表记录。"));
pLayerTable->close();
pEnt->close();
return;
}
// 关闭图层
pLayer->setIsOff(Adesk::kFalse);
es = pLayer->close();
if (es != Acad::eOk) {
acutPrintf(_T("\n无法关闭图层。"));
pLayerTable->close();
pEnt->close();
return;
}
es = pLayerTable->close();
if (es != Acad::eOk) {
acutPrintf(_T("\n无法关闭图层表。"));
pEnt->close();
return;
}
pEnt->close();
}