I am trying to use ‘pyrevit run’ to batch process models copied from Autodesk Desktop Connector to another local folder (downloading the files with APS api calls is not an option).
Sometimes (but not always) Desktop Connector silently packages Revit files as zip archives without changing the file extension (see Revit Journal records “COleException”, code=0x80004005: Unspecified error). When this happens, Revit fails to open the .rvt file, but the issue can be solved by changing the file extension of the copied file to .zip, extracting the archive, then opening the extracted .rvt file of the same name.
Since this doesn’t happen every time, I want to handle it with a try/catch block in PowerShell, but ‘pyrevit run’ does not raise an exception when failing to open the document, so it never triggers the try/catch block. See typical output below:
Debug: Attempting to read “BasicFileInfo” stream from structured storage file at “C:\Users\...\RVT\MyModel.rvt”
Error: File is not a structured storage file (System.NotSupportedException)
at pyRevitLabs.Common.CommonUtils.GetStructuredStorageStream(String filePath, String streamName)
at pyRevitLabs.TargetApps.Revit.RevitModelFile..ctor(String filePath)
at pyRevitCLI.PyRevitCLIRevitCmds.RunExtensionCommand(String commandName, String targetFile, String revitYear, PyRevitRunnerOptions runOptions, Boolean targetIsFileList)
at pyRevitCLI.PyRevitCLI.ProcessArguments()
at pyRevitCLI.PyRevitCLI.Main(String[] args)
Can you direct me to the relevant part of the source code, so I can try to feed that error message back to the host shell?