RevitServerTool wrapper
RevitServerToolClient (namespace RevitServerNet.Tools)
Static wrapper around RevitServerTool.exe createLocalRvt:
static string TryLocateToolPath(string versionHint = null): checks theREVITSERVER_TOOL_PATHenvironment variable first, thenAutodesk\Revit <versionHint>\RevitServerToolCommand\RevitServerTool.exe, then anyAutodesk\Revit *folder under the Program Files folders. Returnsnullif the tool is not found.static Task<RevitServerToolResult> CreateLocalModelAsync(string toolPath, string serverHost, string modelRelativePath, string destinationFile, bool overwrite = false, int timeoutMs = 600000): runs the tool and returns its result. It does not throw on a non-zero exit code, so checkSuccess. ThrowsArgumentExceptionifserverHost,modelRelativePathordestinationFileis empty, or if the full destination path has no file name (for example it ends with a separator);ArgumentOutOfRangeExceptioniftimeoutMsis less than -1;RevitServerToolExceptioniftoolPathdoes not exist; andSystem.ComponentModel.Win32Exceptionif the process cannot be started (for exampletoolPathis not an executable). Creating the destination directory can throwIOException,UnauthorizedAccessException,PathTooLongExceptionorNotSupportedException. The task faults withTimeoutExceptionaftertimeoutMs: the tool is killed and the wait for it to exit is limited to 5 seconds.static string ConvertPipePathToRelativeWindowsPath(string pipePath): converts|Projects|Demo|Model.rvttoProjects\Demo\Model.rvt.static string ParseVersionFromBaseUrl(string baseUrl): extracts the year fromRevitServerAdminRESTService<year>, or returnsnull.RevitServerToolResult:ExitCode,StandardOutput,StandardError,ErrorMessage(the first output line that starts withERROR:, or null),Success(ExitCode == 0and noERROR:line: RevitServerTool exits with 0 also when it fails, for example for a model that does not exist).- The server host, model path and destination are passed as separately quoted and escaped arguments; a destination without a directory is relative to the current directory.
RevitServerToolException: thrown for tool-level failures.