Keith511 发表于 2006-8-10 17:12:00

关于acdbDatabase::purge求教

<P>请问acdbDatabase::purge()</P>
<P>void PurgeBlock(AcDbDatabase *pDb)<BR>{<BR>&nbsp;AcDbBlockTable *pBlockTable;<BR>&nbsp;pDb-&gt;getSymbolTable(pBlockTable, AcDb::kForRead);<BR>&nbsp;AcDbBlockTableRecord *pBlockTableRecord;<BR><BR>&nbsp;&nbsp;pBlockTable-&gt;getAt(ACDB_MODEL_SPACE, pBlockTableRecord,<BR>&nbsp;AcDb::kForWrite);<BR>&nbsp;pBlockTable-&gt;close();<BR></P>
<P>&nbsp;AcDbBlockTableRecordIterator *pBlkRcdItr;&nbsp; //块表记录浏览器<BR>&nbsp;pBlockTableRecord-&gt;newIterator(pBlkRcdItr);<BR></P>
<P>&nbsp;AcDbObjectId id;<BR>&nbsp;AcDbObjectIdArray idArr;<BR>for(pBlkRcdItr-&gt;start();!pBlkRcdItr-&gt;done();pBlkRcdItr-&gt;step())<BR>&nbsp;{<BR>&nbsp;&nbsp;&nbsp; pBlkRcdItr-&gt;getEntityId(id);<BR>&nbsp;&nbsp;&nbsp; idArr.append(id);&nbsp; //向数组添加实体<BR>&nbsp;}<BR>&nbsp;&nbsp; pDb-&gt;purge(idArr);&nbsp;&nbsp;&nbsp; //清理垃圾<BR>&nbsp;&nbsp; pBlockTableRecord-&gt;close();<BR>&nbsp;&nbsp; delete pBlkRcdItr;<BR>} </P>
<P>比如我使用cad的purge命令,看到block下面有可以purge的一些对象,使用这个函数却无法purge掉他们,请问这是怎么回事?</P>

YANGGY 发表于 2006-8-10 18:53:00

<P>purge函数只能用在AcDbDatabase::purge(AcDbObjectIdArray &amp;idArray);中。</P>
<P>你可以用类似上述方法得到BLOCK的AcDbObjectIdArray,再用</P>
<P>AcDbDatabase extDatabase( Adesk::kFalse );&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; extDatabase.purge(idArray);</P>
<P>即可清除块</P>
<P>&nbsp;</P>
<P>&nbsp;</P>

YANGGY 发表于 2006-8-10 18:54:00

<P>purge函数只能用在AcDbDatabase::purge(AcDbObjectIdArray &amp;idArray);中。</P>
<P>你可以用类似上述方法得到BLOCK的AcDbObjectIdArray,再用</P>
<P>AcDbDatabase extDatabase( Adesk::kFalse );</P>
<P>&nbsp;extDatabase.purge(idArray);</P>
<P>即可清除块</P>

Keith511 发表于 2006-8-10 21:22:00

<P>不行,这样cad就会出现异常,而且调试是&nbsp;extDatabase.purge(idArray)执行是异常.</P>

shinjikun 发表于 2006-8-14 02:05:00

你为什么不先close?

shinjikun 发表于 2006-8-14 02:06:00

purge不进行删除,只是把不可以删掉的东西从array里面除掉罢了,删除要自己处理
页: [1]
查看完整版本: 关于acdbDatabase::purge求教