要回答这个问题,您需要将add设置为false,以便在传输对象id时将对象转换为另一种类型的对象时从事务中删除该对象。例如,当您使用ConvertTo方法将轻型多段线转换为二维多段线时会发生这种情况:
- using (Polyline pline = (Polyline)t.GetObject(plineId, OpenMode.ForWrite))
- {
- t.AddNewlyCreatedDBObject(pline, false);
- Polyline2d poly2 = pline.ConvertTo(true);
- t.AddNewlyCreatedDBObject(poly2, true);
- t.Commit();
- }
通过事务打开LW多段线,因此事务知道它。但您将其替换为一个Polyline2d,它将接受id。因此,您需要通过调用AddNewlyCreatedBobObject将LWPolyline删除到事务中,第二个参数为false。如果不这样做,提交时将出现致命错误
事实上,当您需要从事务中删除对象时,事务中应该有一个RemoveObject来处理罕见的情况,而不是一个带有奇怪第二个参数的AddNewlyCreatedBoObject。这就像按下任务栏上的“开始”按钮来停止计算机。
http://adndevblog.typepad.com/autocad/2012/06/converting-polyline-to-polyline2d.html |