问题描述:
使用DBObject.HandOverTo()来创建对象替换对象Handle,发现经常出现eInvalidContext问题。
问题原因:
可以查看开发手册可知HandOverTo不能用于事务中打开。
示例程序:
[CommandMethod("TestHandOverTo")]
public void TestHandOverTo()
{
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
PromptEntityOptions peo =
new PromptEntityOptions("Please select a line:");
peo.SetRejectMessage("Please select a line");
peo.AddAllowedClass(typeof(Line), false);
PromptEntityResult per = ed.GetEntity(peo);
if (per.Status == PromptStatus.OK)
{
Line line = (Line)per.ObjectId.Open(OpenMode.ForWrite);
Polyline pline = new Polyline();
pline.AddVertexAt(
0,
new Point2d(line.StartPoint.X, line.StartPoint.Y),
0, 0, 0
);
pline.AddVertexAt(
1,
new Point2d(line.EndPoint.X, line.EndPoint.Y),
0, 0, 0
);
line.HandOverTo(pline, true, true);
// 提交 handOverTo 结果
pline.Close();
}
}
| 英文空间链接 |
|---|
★中望CAD NET开发中使用HandOverTo出现eInvalidContext如何解决?:https://confluence.zwcad.com/pages/viewpage.action?pageId=308805778
