Exemple #1
0
        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));
        }
        public static BatchRvtSettings FromJsonString(string batchRvtSettingsJson)
        {
            BatchRvtSettings batchRvtSettings = null;

            try
            {
                var jobject = JsonUtil.DeserializeFromJson(batchRvtSettingsJson);
                batchRvtSettings = new BatchRvtSettings();
                batchRvtSettings.Load(jobject);
            }
            catch (Exception e)
            {
                batchRvtSettings = null;
            }

            return(batchRvtSettings);
        }
        public static BatchRvtSettings Create(
            string taskScriptFilePath,
            string revitFileListFilePath,
            BatchRvt.RevitProcessingOption revitProcessingOption,
            BatchRvt.CentralFileOpenOption centralFileOpenOption,
            bool deleteLocalAfter,
            bool discardWorksetsOnDetach,
            BatchRvt.RevitSessionOption revitSessionOption,
            BatchRvt.RevitFileProcessingOption revitFileVersionOption,
            RevitVersion.SupportedRevitVersion taskRevitVersion,
            int fileProcessingTimeOutInMinutes,
            bool fallbackToMinimumAvailableRevitVersion
            )
        {
            var batchRvtSettings = new BatchRvtSettings();

            // General Task Script settings
            batchRvtSettings.TaskScriptFilePath.SetValue(taskScriptFilePath);
            batchRvtSettings.ProcessingTimeOutInMinutes.SetValue(fileProcessingTimeOutInMinutes);

            // Revit Processing settings
            batchRvtSettings.RevitProcessingOption.SetValue(revitProcessingOption);

            // Revit File List settings
            batchRvtSettings.RevitFileListFilePath.SetValue(revitFileListFilePath);

            // Central File Processing settings
            batchRvtSettings.CentralFileOpenOption.SetValue(centralFileOpenOption);
            batchRvtSettings.DeleteLocalAfter.SetValue(deleteLocalAfter);
            batchRvtSettings.DiscardWorksetsOnDetach.SetValue(discardWorksetsOnDetach);

            // Revit Session settings
            batchRvtSettings.RevitSessionOption.SetValue(revitSessionOption);

            // Single Revit Task Processing settings
            batchRvtSettings.SingleRevitTaskRevitVersion.SetValue(taskRevitVersion);

            // Batch Revit File Processing settings
            batchRvtSettings.RevitFileProcessingOption.SetValue(revitFileVersionOption);
            batchRvtSettings.IfNotAvailableUseMinimumAvailableRevitVersion.SetValue(fallbackToMinimumAvailableRevitVersion);
            batchRvtSettings.BatchRevitTaskRevitVersion.SetValue(taskRevitVersion);
            batchRvtSettings.AuditOnOpening.SetValue(false); // TODO: implement this option for this function?

            return(batchRvtSettings);
        }