我试图在以编程方式插入块之前标记我的绘图,以便如果由于错误而仅部分完成,我可以以编程方式撤消该操作。现在插入方法看起来像这样
public void askForInsertionPoint
{
StateManagementExtensions.MarkPosition();
try
{
PromptPointResult pr = ed.GetPoint("\nSelect insertion point: ");
Point3d insPt = pr.Value;
}
catch(Exception e)
{
//TODO handle exception with undo
}
}
MarkPosition 定义为
public static void MarkPosition()
{
doc.SendStringToExecute("MARKPOS ", true, false, true);
}
最后,像我上面那样将 MARKPOS 发送到命令行调用此方法
[CommandMethod("MARKPOS")]
public void MarkPosition()
{
Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
ed.Command("UNDO", "M");
}
pointprompt 以某种方式击败了对 AutoCAD 命令行的 MARKPOS 调用,因此它尝试输入 MARKPOS 作为插入点,而不是暂停 C# 方法以等待 MARKPOS 作为命令执行。在提示插入点之前,如何向程序发出等待并执行 MARKPOS 命令的信号?我在 SendStringToExecute 调用之后尝试了 Thread.sleep() ,但没有成功。