acedvPLayer不工作,崩溃
嗨,社区,我有两个布局和多层A & B视窗。我想只激活视口A上的图层A,只激活视口B上的图层B。
但是,由于这不起作用,视口A冻结所有图层,视口B只解冻图层B,这是正确的。为什么会有这种差异?
我发现它在退出autocad时会崩溃。
以下是我的代码:
void ActiveLayerOnly(const CString& strLayout, int nViewportIndex, const CString& strLayer)
{
AcDbViewport* pViewport = GetViewport(strLayout, nViewportIndex);
if (pViewport == nullptr)
{
ASSERT(pViewport != nullptr);
return;
}
int nRetActiveLayout = acedCommand(RTSTR, _T("layout"), RTSTR, _T(""), RTSTR, strLayout, 0);
ASSERT(nRetActiveLayout == RTNORM);
acedMspace();
Acad::ErrorStatus esSC = acedSetCurrentVPort(pViewport);
ASSERT(es == Acad::eOk);
AcDbLayerTable* pLayerTable = nullptr;
acdbHostApplicationServices()->workingDatabase()->getLayerTable(pLayerTable, kForWrite);
AcDbObjectIdArray vlayerIDFreeze;
AcDbObjectIdArray vlayerIDThaw;
AcDbLayerTableIterator* pItrLayer = nullptr;
if (pLayerTable->newIterator(pItrLayer) == Acad::eOk && pItrLayer)
{
for (pItrLayer->start(); !pItrLayer->done(); pItrLayer->step())
{
AcDbLayerTableRecord* pRcd = nullptr;
if (pItrLayer->getRecord(pRcd, AcDb::kForRead) == Acad::eOk && pRcd)
{
AcDbObjectId id = pRcd->objectId();
const ACHAR* pName = nullptr;
pRcd->getName(pName);
if (pName && CString(pName) != strLayer)
{
vlayerIDFreeze.append(id);
}
pRcd->close();
}
}
delete pItrLayer;
}
auto idid = pViewport->objectId();
pViewport->close();
auto esse = acedVPLayer(idid, vlayerIDFreeze, AcDb::kFreeze);
pLayerTable->close();
}
请帮忙,谢谢!
**** Hidden Message *****
我没有尝试你的代码...但是你可以尝试AcDbViewport::freezeLayersInViewport 如果我没记错的话,处理布局缓存可能会有问题。
有一些奇怪的功能有所帮助,我不记得了...acedVportTableRecords2Vports 或别的什么
https://forums.autodesk.com/t5/objectarx/acedvplayer-doesnt-t-work-and-crash/m-p/7391089#M36236
这个链接,我好家伙发现我的问题。
页:
[1]