[求助]删除图层问题
<p>DeleteAllLayer(void)<br/>{<br/> //删除所有图层上的所有实体<br/> DellayerALL();<br/> //把0层设为当前层<br/> SetCLayer(L"0",true);<br/> //获得0层id<br/> AcDbObjectId baselayerId;//layername图层的ID<br/> <br/> AcDbLayerTable *pLyrTable;<br/> AcDbLayerTableIterator *pLyrTblIterator;<br/> AcDbObjectId recId;<br/> ads_name entname;<br/> Acad::ErrorStatus es;<br/> AcDbDatabase *pCurDb = NULL;</p><p> pCurDb = acdbHostApplicationServices()->workingDatabase();</p><p><br/> es =pCurDb->getLayerTable(pLyrTable, AcDb::kForRead);//获取层表记录<br/> pLyrTable->getAt(L"0",baselayerId);<br/> es =pLyrTable->newIterator(pLyrTblIterator);<br/> <br/> for(pLyrTblIterator->start();!pLyrTblIterator->done();pLyrTblIterator->step())<br/> {<br/> int j=pLyrTblIterator->getRecordId(recId);<br/> if(baselayerId==recId)<br/> continue; //0层跳过<br/> es =acdbGetAdsName(entname,recId);<br/> <br/> acdbEntDel(entname);<br/> if (recId.isErased()==TRUE) <br/> {<br/> CString str;<br/> <br/> acutPrintf(L"%s\n对象给我们删除了\n",entname);<br/> }<br/> else{<br/> acutPrintf(L"\n%s对象存在\n",entname);<br/> }</p><p> <br/> }<br/> delete pLyrTblIterator;<br/> pLyrTable->close();<br/> return Acad::ErrorStatus();<br/>}</p><p><font color="#f73809">删除所有图层为什么删不掉啊?<img title="em10" src="http://www.mjtd.com/bbs/Skins/Default/emot/em10.gif" style="CURSOR: pointer;" alt=""/></font></p> <p>图层的删除需要注意如下几点:</p><p>1、0层不能被删除;<br/>2、当前层不能被删除;<br/>3、如果某个图层被某个块引用,那么那个层也不能被删除。</p>
页:
[1]