public static string RunTask( CommandSettings.Data commandSettingsData, bool openLogFileWhenDone ) { commandSettingsData = ValidateCommandSettingsData(commandSettingsData); var batchRvtFolderPath = BatchRvt.GetBatchRvtFolderPath(); BatchRvt.ExecuteMonitorScript(batchRvtFolderPath, commandSettingsData); var logFilePath = commandSettingsData.GeneratedLogFilePath; logFilePath = PostProcessLogFile(logFilePath); if (openLogFileWhenDone) { if (!string.IsNullOrWhiteSpace(logFilePath)) { Process.Start(logFilePath); } } return(logFilePath); }
public static string RunTask( string taskScriptFilePath, object revitFileListInput, BatchRvt.RevitProcessingOption revitProcessingOption, UseRevitVersion useRevitVersion, BatchRvt.CentralFileOpenOption centralFileOpenOption, bool discardWorksetsOnDetach, bool deleteLocalAfter, bool openLogFileWhenDone, string logFolderPath, int fileProcessingTimeOutInMinutes, bool fallbackToMinimumAvailableRevitVersion, string taskData, string testModeFolderPath ) { var batchRvtRevitFileProcessingOption = ( useRevitVersion == UseRevitVersion.RevitFileVersion ? BatchRvt.RevitFileProcessingOption.UseFileRevitVersionIfAvailable : BatchRvt.RevitFileProcessingOption.UseSpecificRevitVersion ); // NOTE: can be any version if useRevitVersion is set to RevitFileVersion. var taskRevitVersion = ( useRevitVersion == UseRevitVersion.Revit2015 ? RevitVersion.SupportedRevitVersion.Revit2015 : useRevitVersion == UseRevitVersion.Revit2016 ? RevitVersion.SupportedRevitVersion.Revit2016 : useRevitVersion == UseRevitVersion.Revit2017 ? RevitVersion.SupportedRevitVersion.Revit2017 : useRevitVersion == UseRevitVersion.Revit2018 ? RevitVersion.SupportedRevitVersion.Revit2018 : RevitVersion.SupportedRevitVersion.Revit2019 ); var batchRvtSettings = BatchRvtSettings.Create( taskScriptFilePath, (revitFileListInput as string) ?? string.Empty, revitProcessingOption, centralFileOpenOption, deleteLocalAfter, discardWorksetsOnDetach, BatchRvt.RevitSessionOption.UseSeparateSessionPerFile, batchRvtRevitFileProcessingOption, taskRevitVersion, fileProcessingTimeOutInMinutes, fallbackToMinimumAvailableRevitVersion ); var commandSettingsData = new CommandSettings.Data(); commandSettingsData.RevitFileList = revitFileListInput as IEnumerable <string>; commandSettingsData.Settings = batchRvtSettings; commandSettingsData.LogFolderPath = logFolderPath; commandSettingsData.TaskData = taskData; commandSettingsData.TestModeFolderPath = testModeFolderPath; return(RunTask(commandSettingsData, openLogFileWhenDone)); }
private static CommandSettings.Data ValidateCommandSettingsData(CommandSettings.Data commandSettingsData) { if (string.IsNullOrWhiteSpace(commandSettingsData.SettingsFilePath)) { commandSettingsData.SettingsFilePath = null; } if (string.IsNullOrWhiteSpace(commandSettingsData.LogFolderPath)) { commandSettingsData.LogFolderPath = null; } if (string.IsNullOrWhiteSpace(commandSettingsData.SessionId)) { commandSettingsData.SessionId = null; } if (string.IsNullOrWhiteSpace(commandSettingsData.TaskData)) { commandSettingsData.TaskData = null; } if (string.IsNullOrWhiteSpace(commandSettingsData.TestModeFolderPath)) { commandSettingsData.TestModeFolderPath = null; } var batchRvtSettings = commandSettingsData.Settings; if (batchRvtSettings != null) { if (batchRvtSettings.RevitProcessingOption.GetValue() == BatchRvt.RevitProcessingOption.BatchRevitFileProcessing) { if ( string.IsNullOrWhiteSpace(batchRvtSettings.RevitFileListFilePath.GetValue()) && commandSettingsData.RevitFileList == null ) { throw new ArgumentNullException("No Revit file list was specified for Batch processing mode."); } } } commandSettingsData.GeneratedLogFilePath = null; return(commandSettingsData); }
public static string RunTaskFromSettingsFile( string settingsFilePath, string logFolderPath, bool openLogFileWhenDone, string taskData = null, string testModeFolderPath = null ) { var commandSettingsData = new CommandSettings.Data(); commandSettingsData.SettingsFilePath = settingsFilePath; commandSettingsData.LogFolderPath = logFolderPath; commandSettingsData.TaskData = taskData; commandSettingsData.TestModeFolderPath = testModeFolderPath; return(RunTask(commandSettingsData, openLogFileWhenDone)); }
public static void ExecuteMonitorScript( string batchRvtFolderPath, CommandSettings.Data commandSettingsData = null ) { var engine = ScriptUtil.CreatePythonEngine(); var mainModuleScope = ScriptUtil.CreateMainModule(engine); var scriptsFolderPath = Path.Combine(batchRvtFolderPath, SCRIPTS_FOLDER_NAME); var monitorScriptFilePath = Path.Combine( scriptsFolderPath, MONITOR_SCRIPT_FILE_NAME ); ScriptUtil.AddSearchPaths( engine, new[] { scriptsFolderPath, batchRvtFolderPath } ); ScriptUtil.AddBuiltinVariables( engine, new Dictionary <string, object> { { "__scope__", mainModuleScope }, { "__command_settings_data__", commandSettingsData } } ); ScriptUtil.AddPythonStandardLibrary(mainModuleScope); var scriptSource = ScriptUtil.CreateScriptSourceFromFile(engine, monitorScriptFilePath); scriptSource.Execute(mainModuleScope); return; }