autodesk-forgeautodesk-bim360autodesk-designautomationautocad-plugin

Design Automation for AutoCAD work item throws an error during file open


Using Design Automation I need to open all *.dwg files from folder and print PDF from Model space. When I test it locally it works perfect, but in a cloud WorkItem stops to work when DocumentManager tries to open any extracted file. This is part where WorkItem breaks:

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();
}

And Work Item result looks like this:

[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"
}

Unfortunately, there is no any kind of errors handling for AutoCAD (always show 'Application accoreconsole.exe exits with code 1 which indicates an error.'), I can't see why the application is broken, is there a way to find minimal error description?


Solution

  • I can't see why the application is broken, is there a way to find minimal error description?

    You could wrap your code with try/catch and print out more details. Otherwise, the exception propagates causes accoreconsole.exe to crash.

    BTW, I don't recommend that you loop through drawings like this. I would recommend that you create a workitem for each dwg so that they can be executed in parallel.