예제 #1
0
        public static ICollection <RevitFile> AllowedFiles(CreateJournalSetting setting)
        {
            var allFiles = GetFoundFiles(setting);

            return(allFiles.Where(filePath => IsAllowedForJournal(filePath))
                   .Select(filePath => new RevitFile(filePath)).ToList());
        }
예제 #2
0
        public static IList <string> GetFoundFiles(CreateJournalSetting setting, string extension = "rfa")
        {
            var searchOption = SearchOption.TopDirectoryOnly;

            if (setting.RecursiveSearch)
            {
                searchOption = SearchOption.AllDirectories;
            }
            var filePaths = Directory.GetFiles(setting.SourceDir, $"*.{extension}", searchOption);

            return(filePaths);
        }
예제 #3
0
        public void CreateAddinFile(CreateJournalSetting setting)
        {
            var fullPath = Assembly.GetAssembly(GetType()).Location;

            if (Guid.TryParse(setting.AddinId, out var addinGuid) == false)
            {
                throw new ArgumentException("No valid AddinId - can NOT be parsed to GUID");
            }

            var addinId         = new AddInId(addinGuid);
            var currentManifest = GetCurrentManifest(fullPath, addinId);

            if (HasCommandId(currentManifest, setting.AddinId, out var command))
            {
                var newCommand  = CreateNew(fullPath, command);
                var newManifest = new RevitAddInManifest();
                newManifest.AddInCommands.Add(newCommand);
                var newManifestPath = Path.Combine(setting.DestinationDir, addinFileName);
                newManifest.SaveAs(newManifestPath);
            }
        }
예제 #4
0
        public void CreateBatch(CreateJournalSetting setting)
        {
            var batchContent = string.Empty;

            batchContent += $"@echo off{Environment.NewLine}";
            batchContent += $"echo  {setting.JobName}{Environment.NewLine}";
            batchContent += Environment.NewLine;
            batchContent += $"cd {setting.RevitDirectory}{Environment.NewLine}";
            batchContent += Environment.NewLine;
            var count     = 0;
            var fileCount = journalFiles.Count;

            foreach (var journalFile in journalFiles)
            {
                var fileName = Path.GetFileNameWithoutExtension(journalFile);
                batchContent += $"echo  {++count}/{fileCount} {fileName}{Environment.NewLine}";
                batchContent += $"start /W /HIGH Revit.exe {journalFile} /language {setting.Language} /nosplash{Environment.NewLine}";
                batchContent += Environment.NewLine;
            }
            batchContent += $"exit{Environment.NewLine}";
            FileHelper.WriteFile(setting.JobBatchFilePath, batchContent);
        }
예제 #5
0
        public void CreateJournal(CreateJournalSetting createSetting)
        {
            try
            {
                var journalData = JournalHelper.BuildJournalStart(createSetting.DebugModus);
                journalData += JournalHelper.BuildDocumentOpen(createSetting.CurrentFile.FilePath);

                journalData += JournalHelper.BuildAddinLaunch(createSetting.AddinId, createSetting.CmdFullName);
                journalData += JournalHelper.BuildAddinAddinCommandData(createSetting.JournalData);

                var journalFile = FileHelper.ChangeExtension(createSetting.CurrentFile.FilePath, "txt");
                journalFile = Path.GetFileName(journalFile);
                journalFile = $"{createSetting.FileCount}_{journalFile}";
                journalFile = Path.Combine(createSetting.DestinationDir, journalFile);
                FileHelper.WriteFile(journalFile, journalData);
                journalFiles.Add(journalFile);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }