AutoCAD 工作项的设计自动化在文件打开期间引发错误

问题描述 投票:0回答:1

使用设计自动化,我需要打开文件夹中的所有 *.dwg 文件并从模型空间打印 PDF。 当我在本地测试它时,它工作得很好,但在云中,当 DocumentManager 尝试打开任何提取的文件时,WorkItem 就会停止工作。 这是 WorkItem 中断的部分:

var files = Directory.EnumerateFiles(extractZipFolder, "*.*", SearchOption.AllDirectories).Where(s => s.EndsWith(".dwg"));
foreach (var file in files)
{
   var openedDocument = AcadApp.DocumentManager.Open(file, false);
   manager.MdiActiveDocument = openedDocument;
   var openedDatabase = openedDocument.Database;
   //Work with opened document...
   openedDocument.CloseAndDiscard();
}

工作项结果如下所示:

[07/01/2024 15:29:27] Folder "T:\Aces\Jobs\80b1dc931698465caca7dd33f3f1038d\acad_output" has been created.
[07/01/2024 15:29:27] Starting work item 80b1dc931698465caca7dd33f3f1038d
[07/01/2024 15:29:27] Start download phase.
[07/01/2024 15:29:27] Start downloading input: verb - 'Get', url - 'urn:adsk.objects:os.object:wip.dm.prod/a30ef8a9-f959-4e77-bd07-74febaf9e92c.dwg'
[07/01/2024 15:29:27] Start downloading input: verb - 'Get', url - 'urn:adsk.objects:os.object:xyicon_bucket/output.json'
[07/01/2024 15:29:27] Start downloading input: verb - 'Get', url - 'urn:adsk.objects:os.object:xyicon_bucket/revit_output_.zip'
[07/01/2024 15:29:28] End downloading file. Source=urn:adsk.objects:os.object:xyicon_bucket/output.json,LocalFile=T:\Aces\Jobs\80b1dc931698465caca7dd33f3f1038d\inputFile.json,BytesDownloaded=1570,Duration=334ms
[07/01/2024 15:29:28] End downloading file. Source=urn:adsk.objects:os.object:xyicon_bucket/revit_output_.zip,LocalFile=T:\Aces\Jobs\80b1dc931698465caca7dd33f3f1038d\acad_input.zip,BytesDownloaded=46107,Duration=330ms
[07/01/2024 15:29:28] End downloading file. Source=urn:adsk.objects:os.object:wip.dm.prod/a30ef8a9-f959-4e77-bd07-74febaf9e92c.dwg,LocalFile=T:\Aces\Jobs\80b1dc931698465caca7dd33f3f1038d\Input.dwg,BytesDownloaded=32467,Duration=373ms
[07/01/2024 15:29:28] End download phase successfully.
[07/01/2024 15:29:28] Start preparing script and command line parameters.
[07/01/2024 15:29:28] Command line: [ /i "T:\Aces\Jobs\80b1dc931698465caca7dd33f3f1038d\Input.dwg" "T:\Aces\Jobs\80b1dc931698465caca7dd33f3f1038d\inputFile.json" "T:\Aces\Jobs\80b1dc931698465caca7dd33f3f1038d\acad_input.zip" /al "T:\Aces\Applications\29782f183477c2a1b4b98b6a2426b474.XyiconApp.AutoCADPrintApp[1].package" /s "T:\Aces\Jobs\80b1dc931698465caca7dd33f3f1038d\setting_script.scr"]
[07/01/2024 15:29:28] End preparing script and command line parameters.
[07/01/2024 15:29:28] Start script phase.
[07/01/2024 15:29:28] Start AutoCAD Core Engine standard output dump.
[07/01/2024 15:29:28] Redirect stdout (file: T:\Aces\Jobs\80b1dc931698465caca7dd33f3f1038d\tmp\accc1762).
[07/01/2024 15:29:28] AcCoreConsole: StdOutConsoleMode: processed-output: disabled,auto
[07/01/2024 15:29:28] AutoCAD Core Engine Console - Copyright 2023 Autodesk, Inc.  All rights reserved. (U.61.Z.187)
[07/01/2024 15:29:28] Execution Path:
[07/01/2024 15:29:28] T:\Aces\AcesRoot\24.3\coreEngine\Exe\accoreconsole.exe
[07/01/2024 15:29:28] Current Directory: T:\Aces\Jobs\80b1dc931698465caca7dd33f3f1038d
[07/01/2024 15:29:28] Isolating to regkey=HKEY_CURRENT_USER\SOFTWARE\AppDataLow\Software\Autodesk\CoreUser\WorkItem_80b1dc931698465caca7dd33f3f1038d, userDataFolder=T:\Aces\Jobs\80b1dc931698465caca7dd33f3f1038d\userdata.
[07/01/2024 15:29:28] Version Number: U.61.Z.187 (UNICODE)
[07/01/2024 15:29:28] LogFilePath has been set to the working folder.
[07/01/2024 15:29:29] Regenerating model.
[07/01/2024 15:29:29] AutoCAD menu utilities loaded.
[07/01/2024 15:29:29] Command:
[07/01/2024 15:29:29] Command:
[07/01/2024 15:29:29] Command:
[07/01/2024 15:29:29] Command: (command "DWGTOPDF")
[07/01/2024 15:29:32] End AutoCAD Core Engine standard output dump.
[07/01/2024 15:29:32] Error: Application accoreconsole.exe exits with code 1 which indicates an error.
[07/01/2024 15:29:32] End script phase.
[07/01/2024 15:29:32] Error: An unexpected error happened during phase CoreEngineExecution of job.
[07/01/2024 15:29:32] Job finished with result FailedExecution
[07/01/2024 15:29:32] Job Status:
{
  "status": "failedInstructions",
  "activityId": "XyiconApp.AutoCADPrintAppActivity+dev",
  "stats": {
    "timeQueued": "2024-07-01T15:29:27.5198543Z",
    "timeDownloadStarted": "2024-07-01T15:29:27.6941103Z",
    "timeInstructionsStarted": "2024-07-01T15:29:28.129703Z",
    "timeInstructionsEnded": "2024-07-01T15:29:32.5634556Z",
    "bytesDownloaded": 80144
  },
  "id": "80b1dc931698465caca7dd33f3f1038d"
}

不幸的是,AutoCAD 没有任何类型的错误处理(总是显示“应用程序 accoreconsole.exe 退出,代码为 1,表明有错误。”),我不明白应用程序为何损坏,有没有办法找到最小错误描述?

autodesk-forge autodesk-bim360 autodesk-designautomation autocad-plugin
1个回答
0
投票

我不明白应用程序为何损坏,有没有办法找到最小的错误描述?

您可以使用 try/catch 包装代码并打印出更多详细信息。否则,异常传播会导致 accoreconsole.exe 崩溃。

顺便说一句,我不建议您像这样循环浏览绘图。我建议您为每个 dwg 创建一个工作项,以便它们可以并行执行。

© www.soinside.com 2019 - 2024. All rights reserved.