|
同一个函数不能连续执行2次,第一次执行正常,第二次执行则在一个主要语句处出现致命性错误
就是连续执行下面这个函数2次:
public void 实体改色(string 层名, Autodesk..Colors.Color 颜色)
{
TypedValue[] 过滤项 = new TypedValue[] { new TypedValue((int)DxfCode.LayerName, 层名) };
SelectionFilter 过滤器 = new SelectionFilter(过滤项);
全选择结果 = ed.SelectAll(过滤器);
Entity ent = null;
using (tm)
{
foreach (ObjectId oid in 全选择结果.Value.GetObjectIds())
{
ent = tm.GetObject(oid, OpenMode.ForRead) as Entity;
ent.UpgradeOpen();
ent.Color = 颜色;
}
tm.Commit();
}
doc.Editor.Regen();
}
连续执行2次:
实体改色("abc", 颜色1);//执行第1次
实体改色("tkp", 颜色2);//执行第2次
当执行第2次时,在这一句:
ent = tm.GetObject(oid, OpenMode.ForRead) as Entity;
出现致命性错误。不知为什么? |
|