reecho 发表于 2009-4-21 13:35:00

[求助]可以拆离对象数据,但是执行命令后对象就被锁定了?

<table cellspacing="0" cellpadding="0"><tbody><tr><td class="t_msgfont" id="postmessage_383496"><p>我的编程环境是c#+autodesk map 3d2005中文版。现在实现地图-》对象数据-》拆离对象数据的命令。代码可以实现这个命令,但是运行后,再要对刚才拆离对象数据的实体操作就不可以了,显示“对象已打开进行读取”,这时候只有关闭当前文档,再打开才可以进行编辑。不知道是什么原因?代码如下,请各位多指点!<br/>AutocadMAP.Project p = map.Projects.Item(0);<br/><br/>ODRecords records = p.ODTables.GetODRecords();<br/>&nbsp;&nbsp;if (records.Init(selectEntity, true, false))<br/>&nbsp; &nbsp;&nbsp; &nbsp; //第二项一定要设为true才能删除,设为false删除不了record,即某个实体的对象数据。设为true的时候就是打开对象了,怎么关闭对象呢?<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;ODRecord removeRecord = records.Record();<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;records.Remove();<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;while (records.Next())<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; {<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; removeRecord = records.Record();<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;records.Remove();<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp;&nbsp;}<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; //文件打开后要关闭,貌似没什么作用。执行完这个命令后,再对该实体进行编辑,总是显示ewasforwrite的错误。非得把文件关闭重新打开才行。不知道程序中如何将打开的实体关闭?或者删除record还有别的方法?<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;records.Init(selectEntity, false, false);<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; records = null;//将索引器置空<br/>&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp; }</p></td></tr></tbody></table>

reecho 发表于 2009-5-4 13:17:00

又发现了不用关闭文件,只要执行完上面的代码后,点击格式-图层,弹出窗体后再关闭就一切恢复正常了。不知道是什么原因?是没有释放对象实体selectEntity的原因吗?怎么才能真正释放?
页: [1]
查看完整版本: [求助]可以拆离对象数据,但是执行命令后对象就被锁定了?