【问题标题】:Forge error if using SendStringtoExecute (Command ^C^C)使用 SendStringtoExecute 时伪造错误(命令 ^C^C)
【发布时间】:2021-05-05 22:00:25
【问题描述】:

实际上,如果我只是从 lisp 脚本运行 (Command ^C^C),则不会出现错误。 情况是,我的应用程序是一个 .NET 应用程序,我调用了一些 SendStringToExecute 来使用一些 lisp 代码。 为了确保结束 lisp 例程,我在最后放了:

doc.SendStringToExecute("(Command ^C^C)", True, False, True)

Forge Design Automation 的结果是:failedinstruction

虽然我可以很容易地找到解决此问题的另一种方法,但我花了一天多的时间才弄清楚是(命令 ^C^C)导致了失败的指令,而其他一切工作正常。 希望这个错误将得到修复,并且类似的东西不会在其他地方再次出现。

我这样隔离案例:

  1. 制作一个 .NET 包,或者只是在调试模式下重用您现有的任何包
  2. 添加以下 lisp 定义函数(或者它可以是自定义命令,无论如何):
<LispFunction("l+SendStringToExecute")>
        Public Shared Function lsp_SendStringToExcute(args As ResultBuffer) As Object
            Dim script$ = Nothing
                For Each arg As TypedValue In args.AsArray
                    script = arg.Value
                    Exit For
                Next
                script = script.Trim()

                If script <> "" Then 
                   Document doc = 
                    AcadApplication.DocumentManager.MdiActiveDocument
                    doc.SendStringToExecute(script + vbCr, True, False, True)
                End If
                Return New TypedValue(LispDataType.T_atom)
        End Function
  1. 将包上传到 Forge,创建转储活动,然后只运行自定义 lisp:
(l+SendStringToExecute "(Command ^C^C)")
  1. 结果日志如下:
...
[02/01/2021 17:23:26] Command: (l+SendStringToExecute "(Command ^C^C)")
[02/01/2021 17:23:26] T
[02/01/2021 17:23:26] Command: (Command ^C^C)
[02/01/2021 17:23:26] *Cancel*
[02/01/2021 17:23:26] Command: nil
[02/01/2021 17:23:27] End AutoCAD Core Engine standard output dump.
[02/01/2021 17:23:27] Error: AutoCAD Core Console failed to finish the script - an unexpected input is encountered.
[02/01/2021 17:23:27] End script phase.
[02/01/2021 17:23:27] Error: An unexpected error happened during phase CoreEngineExecution of job.
[02/01/2021 17:23:27] Job finished with result FailedExecution
[02/01/2021 17:23:27] Job Status:
{
  "status": "failedInstructions", ...

【问题讨论】:

  • 你想通过 doc.SendStringToExecute("(Command ^C^C)", True, False, True) 来完成什么?您要退出脚本吗?
  • 谢谢。有很多方法可以解决它。但问题是它是一个隐藏的错误,我从不怀疑发送命令可能是原因。只是希望有人告诉 Autodesk 团队它在那里,并检查它是否可以在其他地方。如果我在本地 accoreconsole 中运行我的应用程序和上述测试,则​​没有错误。它只发生在 Forge 上。
  • @PhamVuHongLinh - 您能否提供重现该行为的确切步骤?
  • 我已经编辑了我的帖子以更好地展示这些步骤。我使用自定义定义 lisp,以便我可以使用其他 lisp 测试 SendStringToExecute 方法以查看是否有其他错误。最主要的是,如果使用纯 lisp,就可以了。但是使用 .NET SendStringToExecute 来发送 ^C^C,看起来像是发送了某种 Esc 键并取消 Forge 结束过程

标签: autodesk-forge autodesk-designautomation


【解决方案1】:

感谢您的报告,我不确定我们是否允许在 accoreconsole 中使用 command 表达式。 建议使用以下方式。

[CommandMethod("CANCELOUTSTANDING")]
public void TESTCANCEL()
{
var doc = Application.DocumentManager.MdiActiveDocument;
string cmd = string.Format("{0}", new string((char)03, 2));
doc.SendStringToExecute(cmd, true, false, true);
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-13
    • 1970-01-01
    • 2016-07-12
    • 2020-09-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多