static void Test_x1(void)
{
// -- Get Layer's ObjectId for Freeze;
AcDbObjectId FrzLay = acdbHostApplicationServices()->workingDatabase()->clayer();
// -- Make to a array for freezeLayer use
AcDbObjectIdArray FrzArray;
FrzArray.removeAll();
FrzArray.append(FrzLay);
// -- get all the viewport's objectId, but not paperSpace.
AcDbObjectIdArray vps;
vps.removeAll(); // -- clear it;
Acad::ErrorStatus es = Acad::eInvalidInput;
es = acdbHostApplicationServices()->workingDatabase()->getViewportArray(vps, false);
if (es != Acad::eOk)
{
acutPrintf(_T("\nError(getViewportArray): %s"), acadErrorStatusText(es));
return;
}
if (vps.isEmpty())
{
acutPrintf(_T("\nError(Viewport's IdArray): none viewport in it."));
return;
}
for (int i = 0; i < vps.length(); i++)
{
AcDbViewport *pEnt = NULL;
es = acdbOpenObject((AcDbObject*&)pEnt, vps[i], AcDb::kForWrite);
if (es != Acad::eOk)
{
acutPrintf(_T("\nError(OpenLayout): %s."), acadErrorStatusText(es));
continue; // -- skip current layout.
}
// -- Freeze Layer in viewPort
es = pEnt->freezeLayersInViewport(FrzArray);
if (es != Acad::eOk)
{
acutPrintf(_T("\nError(FrzInVp): %s"), acadErrorStatusText(es));
pEnt->close();
continue;
}
/* UpdataDisplay? but it no work. this viewport have no change. */
pEnt->updateDisplay();
pEnt->close();
}
}
I have write this code to Freeze Current layer on all viewport. but no work as I think.
the viewport do't updata when the command complete.
but, if I copy a viewport , the layer( what I want to freezed) already Freeze on the copy....
look the Gif: