cad新学生 发表于 2009-12-2 17:07:00

[求助]删除图层问题

<p>DeleteAllLayer(void)<br/>{<br/>&nbsp;//删除所有图层上的所有实体<br/>&nbsp;&nbsp;&nbsp; DellayerALL();<br/>&nbsp;//把0层设为当前层<br/>&nbsp;SetCLayer(L"0",true);<br/>&nbsp;//获得0层id<br/>&nbsp;AcDbObjectId baselayerId;//layername图层的ID<br/>&nbsp;<br/>&nbsp;AcDbLayerTable *pLyrTable;<br/>&nbsp;AcDbLayerTableIterator *pLyrTblIterator;<br/>&nbsp;AcDbObjectId recId;<br/>&nbsp;&nbsp;&nbsp; ads_name entname;<br/>&nbsp;Acad::ErrorStatus es;<br/>&nbsp;AcDbDatabase *pCurDb = NULL;</p><p>&nbsp;pCurDb = acdbHostApplicationServices()-&gt;workingDatabase();</p><p><br/>&nbsp;es =pCurDb-&gt;getLayerTable(pLyrTable, AcDb::kForRead);//获取层表记录<br/>&nbsp;pLyrTable-&gt;getAt(L"0",baselayerId);<br/>&nbsp;es =pLyrTable-&gt;newIterator(pLyrTblIterator);<br/>&nbsp;<br/>&nbsp;for(pLyrTblIterator-&gt;start();!pLyrTblIterator-&gt;done();pLyrTblIterator-&gt;step())<br/>&nbsp;{<br/>&nbsp;&nbsp;int j=pLyrTblIterator-&gt;getRecordId(recId);<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if(baselayerId==recId)<br/>&nbsp;&nbsp;&nbsp; continue; //0层跳过<br/>&nbsp;&nbsp;es =acdbGetAdsName(entname,recId);<br/>&nbsp;<br/>&nbsp;&nbsp;acdbEntDel(entname);<br/>&nbsp;&nbsp;if (recId.isErased()==TRUE) <br/>&nbsp;&nbsp;{<br/>&nbsp;&nbsp;&nbsp; CString str;<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp;acutPrintf(L"%s\n对象给我们删除了\n",entname);<br/>&nbsp;&nbsp;}<br/>&nbsp;&nbsp;else{<br/>&nbsp;&nbsp;&nbsp;acutPrintf(L"\n%s对象存在\n",entname);<br/>&nbsp;&nbsp;}</p><p>&nbsp;&nbsp;&nbsp;<br/>&nbsp;}<br/>&nbsp;delete pLyrTblIterator;<br/>&nbsp;pLyrTable-&gt;close();<br/>&nbsp;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>

luowy 发表于 2009-12-3 14:48:00

<p>图层的删除需要注意如下几点:</p><p>1、0层不能被删除;<br/>2、当前层不能被删除;<br/>3、如果某个图层被某个块引用,那么那个层也不能被删除。</p>
页: [1]
查看完整版本: [求助]删除图层问题