public void Apply() { var worksetLog = new TransactionLog(@"Workset Creation/Modifications"); if (WorksharingIsEnabled) { ModelSetupWizardUtilities.ApplyWorksetModifications(doc, Worksets.ToList(), ref worksetLog); } var projectInfoLog = new TransactionLog(@"Project Information Modifications"); ModelSetupWizardUtilities.ApplyProjectInfoModifications(doc, ProjectInformation.ToList(), ref projectInfoLog); var iniFile = IniIO.GetIniFile(doc); if (iniFile.Length > 0) { IniIO.WriteColours(iniFile, Colours.ToList()); } else { SCaddinsApp.WindowManager.ShowMessageBox(iniFile + " does not exist"); } string msg = "Summary" + System.Environment.NewLine + System.Environment.NewLine + worksetLog + System.Environment.NewLine + projectInfoLog; SCaddinsApp.WindowManager.ShowMessageBox("Model Setup Wizard - Summary", msg); TryClose(true); }
public ModelSetupWizardViewModel(Autodesk.Revit.UI.UIDocument uidoc) { doc = uidoc.Document; ProjectInformation = new BindableCollection <ProjectInformationParameter>(ElementCollectors.GetProjectInformationParameters(doc)); Worksets = new BindableCollection <WorksetParameter>(ElementCollectors.GetWorksetParameters(doc)); SelectedWorksets = new List <WorksetParameter>(); SelectedProjectInformations = new List <ProjectInformationParameter>(); optionsVm = new ModelSetupWizardOptionsViewModel(); NominatedArchitects = optionsVm.NominatedArchitects; ColourSchemes = optionsVm.ColourSchemes; NominatedArchitects.Insert(0, new NominatedArchitect("Architects Name", "0000")); selectedNominatedArchitect = NominatedArchitects[0]; selectedColourScheme = ColourSchemes[0]; FileName = doc.PathName; var iniFile = IniIO.GetIniFile(doc); if (iniFile.Length > 0) { var colors = IniIO.ReadColours(iniFile); Colours = new BindableCollection <System.Windows.Media.Color>(colors); } else { SCaddinsApp.WindowManager.ShowMessageBox(iniFile + " does not exist"); } var fileNameParam = ProjectInformation.Where(p => p.Name == ModelSetupWizardSettings.Default.FileNameParameterName); if (fileNameParam.Count() == 1) { if (string.IsNullOrEmpty(doc.PathName)) { SCaddinsApp.WindowManager.ShowMessageBox("Document not saved... filename cannot be assigned."); } var path = System.IO.Path.GetFileName(doc.PathName); fileNameParam.First().Value = path; } foreach (var pinf in optionsVm.ProjectInformationReplacements) { var match = ProjectInformation.Where(p => p.Name == pinf.ParamaterName); if (match.Count() == 1) { match.First().Format = pinf.ReplacementFormat; match.First().Value = pinf.ReplacementValue; } } foreach (var winf in optionsVm.Worksets) { if (Worksets.Select(w => w.Name.Trim()).Contains(winf.Name.Trim())) { continue; } if (!Worksets.Select(w => w.Name).Contains(winf.ExistingName.Trim())) { Worksets.Add(winf); } var match = Worksets.Where(w => w.Name.Trim() == winf.ExistingName.Trim()); if (match.Any()) { match.First().Name = winf.Name; } } }