private void BtnCreate_Click(object sender, EventArgs e) { // check if at least one item is selected if (LsvWorksets.CheckedItems.Count == 0) { UI.Info.Form_Info1.infoMsgMain = "Selection"; UI.Info.Form_Info1.infoMsgBody = "Select one or more worksets from the list."; using (UI.Info.Form_Info1 thisForm = new Info.Form_Info1()) { thisForm.ShowDialog(); } } else { // collect selected worksets List <string> selectedWorksets = new List <string>(); foreach (ListViewItem item in LsvWorksets.CheckedItems) { selectedWorksets.Add(item.Text); } // check if workset name is in use usedNames = GetUsedNames(m_doc, selectedWorksets); if (usedNames.Any()) { using (UI.Info.Form_Warning thisForm = new UI.Info.Form_Warning()) { thisForm.ShowDialog(); } } // proceed if workset names are unique else { using (TransactionGroup tg = new TransactionGroup(m_doc, "Transfer Worksets")) { tg.Start(); createdWorksets.Clear(); // clear results list for when running the command more than once. foreach (string WorksetName in selectedWorksets) { using (Transaction t = new Transaction(m_doc, "Single Transaction")) { t.Start(); Workset newWorkset = null; newWorkset = Workset.Create(m_doc, WorksetName); createdWorksets.Add(WorksetName); t.Commit(); } } tg.Assimilate(); } // show Results Form using (UI.Info.Form_Results thisForm = new Info.Form_Results()) { thisForm.ShowDialog(); } DialogResult = DialogResult.OK; } } }
private void BtnAddParameters_Click(object sender, EventArgs e) { #region get all checked parameters List <Definition> defList = new List <Definition>(); foreach (TreeNode n1 in TreeViewParameters.Nodes) { foreach (TreeNode n2 in n1.Nodes) { if (n2.Checked == true) { defList.Add(n2.Tag as Definition); } } } #endregion #region get all checked categories List <Category> catList = new List <Category>(); if (m_doc.IsFamilyDocument == true) { catList.Add(m_doc.OwnerFamily.FamilyCategory); } else { foreach (TreeNode c in TreeViewCategories.Nodes) { if (c.Checked == true) { catList.Add(c.Tag as Category); } } } #endregion // Check if selected: Shared Parameter FILE, Parameters and Categories if (m_app.OpenSharedParameterFile() == null | defList.Count == 0 | catList.Count == 0) { using (UI.Info.Form_Info1 thisForm = new UI.Info.Form_Info1()) { thisForm.ShowDialog(); } } // Load parameters else { // get parameter group KeyValuePair <BuiltInParameterGroup, string> groupKeyValuePair = (KeyValuePair <BuiltInParameterGroup, string>)CbxGroup.SelectedItem; BuiltInParameterGroup group = groupKeyValuePair.Key; // Bind the Definitions Data.Helpers.BindDefinitionsToCategories(m_doc, m_app, defList, catList, group, RbtInstance.Checked); // show Results Form using (UI.Info.Form_Results thisForm = new Info.Form_Results()) { thisForm.ShowDialog(); } // show form Do you want to load more parameters? using (UI.Info.Form_Info2 thisForm = new UI.Info.Form_Info2()) { thisForm.ShowDialog(); if (thisForm.DialogResult == DialogResult.No) { this.DialogResult = DialogResult.OK; } } // uncheck parameters foreach (TreeNode n in TreeViewParameters.Nodes) // parents { n.Checked = false; foreach (TreeNode c in n.Nodes) // children { c.Checked = false; } } // uncheck categories foreach (TreeNode n in TreeViewCategories.Nodes) { n.Checked = false; } } }
private void BtnDuplicate_Click(object sender, EventArgs e) { // reset viewport counter Ana_NoOfViewports = 0; // get number of copies int copies = Convert.ToInt32(NumOfCopies.Value); // set Dependent views Duplicate Option ViewDuplicateOption dependentOption = ViewDuplicateOption.AsDependent; if (CbxDependent.Checked != true) { dependentOption = ViewDuplicateOption.WithDetailing; } // is there at least one item selected? if (LsvSheets.CheckedItems.Count == 0) { UI.Info.Form_Info1.infoMsgMain = "Select"; UI.Info.Form_Info1.infoMsgBody = "Select one sheet to continue."; using (UI.Info.Form_Info1 thisForm = new UI.Info.Form_Info1()) { thisForm.ShowDialog(); } } // proceed with duplication else { executionTime.Start(); // start execution time counter // collect selected sheets, for multiple selection List <string> selSheetsTxt = new List <string>(); List <ViewSheet> allViewSheets = Data.Helpers.GetViewSheets(m_doc); foreach (ListViewItem lv in LsvSheets.CheckedItems) { selSheetsTxt.Add(lv.SubItems[0].Text); } List <ViewSheet> selViewSheets = Data.Helpers.GetSelectedSheets(allViewSheets, selSheetsTxt); // currently multiple selection is not allowed, so take just one item ViewSheet sourceSheet = selViewSheets.First(); Ana_SheetNumber = sourceSheet.SheetNumber; Ana_SheetName = sourceSheet.Name; Ana_NoOfCopies = copies; DuplicateSheets(m_doc, sourceSheet, copies, dependentOption); transactionMade = true; // to trigger stopwatch stop in other methods executionTime.Stop(); // stop execution time counter ExecTimeElapseS = executionTime.Elapsed.Seconds.ToString(); #region show Results Form resultHead = "Results"; resultMain = string.Format("You have made {0} copies of:{1}{1}'{2}'", copies, Environment.NewLine, sourceSheet.Name); resultBody = string.Format("NOTE: A suffix 'DupX' has been added to the view names.{0}" + "Please, rename the views appropriately.", Environment.NewLine); ; using (UI.Info.Form_Results thisForm = new Info.Form_Results()) { thisForm.ShowDialog(); if (thisForm.DialogResult == DialogResult.No) { useTime.Stop(); UseTimeElapseS = useTime.Elapsed.Seconds.ToString(); Utilities.GetAnalyticsCSV(m_doc, m_app); Data.Helpers.DuplicateSheetsAnalytics(m_doc, m_app, UseTimeElapseS, ExecTimeElapseS, Ana_NoOfCopies, Ana_NoOfViewports, Ana_SheetNumber, Ana_SheetName); DialogResult = DialogResult.OK; } if (thisForm.DialogResult == DialogResult.Yes) { LoadSheets(); // get analytics data useTime.Stop(); UseTimeElapseS = useTime.Elapsed.Seconds.ToString(); Utilities.GetAnalyticsCSV(m_doc, m_app); Data.Helpers.DuplicateSheetsAnalytics(m_doc, m_app, UseTimeElapseS, ExecTimeElapseS, Ana_NoOfCopies, Ana_NoOfViewports, Ana_SheetNumber, Ana_SheetName); useTime.Restart(); // reset use time and start time counter again } } #endregion } }
private void BtnTransfer_Click(object sender, EventArgs e) { List <string> infoFiltersTransferred = new List <string>(); List <string> infoFiltersGraphicOverriden = new List <string>(); #region items selected? if (LsvFilters.CheckedItems.Count == 0) { UI.Info.Form_Info1.infoMsgMain = "Select"; UI.Info.Form_Info1.infoMsgBody = "Select one or more View Filters from the list to continue."; using (UI.Info.Form_Info1 thisForm = new Info.Form_Info1()) { thisForm.ShowDialog(); } return; } if (LsvTemplates.CheckedItems.Count == 0) { UI.Info.Form_Info1.infoMsgMain = "Select"; UI.Info.Form_Info1.infoMsgBody = "Select one or more View Templates from the list to continue."; using (UI.Info.Form_Info1 thisForm = new Info.Form_Info1()) { thisForm.ShowDialog(); } return; } #endregion #region CHECK IF FILTER IS ALREADY APPLIED List <string> infoIsFilterApplied = new List <string>(); bool triggerIsFilterApplied = false; foreach (ListViewItem tItem in LsvTemplates.CheckedItems) // LOOP THROUGH TEMPLATES { ElementId templateId = new ElementId(tItem.ImageIndex); Autodesk.Revit.DB.View template = m_doc.GetElement(templateId) as Autodesk.Revit.DB.View; foreach (ListViewItem vItem in LsvFilters.CheckedItems) // LOOP THROUGH FILTERS { ElementId filterId = new ElementId(vItem.ImageIndex); if (template.IsFilterApplied(filterId)) { infoIsFilterApplied.Add(string.Format("{0} -> {1}", vItem.Text, template.Name)); triggerIsFilterApplied = true; } } } if (triggerIsFilterApplied) { // show warning form UI.Info.Form_Warning.warningHead = "You should know..."; UI.Info.Form_Warning.warningMain = "The following Filters are already applied to one or more selected View Templates:"; UI.Info.Form_Warning.warningFoot = "Graphic settings will be overriden."; UI.Info.Form_Warning.warningList = infoIsFilterApplied; using (UI.Info.Form_Warning thisForm = new Info.Form_Warning()) { thisForm.ShowDialog(); } } #endregion #region PROCEED WITH TRANSACTION executionTime.Start(); using (Transaction t = new Transaction(m_doc, "Transfer View Filters")) { Ana_NoOfTemplates = LsvTemplates.CheckedItems.Count; // collect data for analytics t.Start(); // FOR EACH FILTER SELECTED FROM THE LIST, GET HOST VIEW TEMPLATE AND GRAPHIC OVERRIDES foreach (ListViewItem filterItem in LsvFilters.CheckedItems) { ElementId filterId = new ElementId(filterItem.ImageIndex); // GET SOURCE VIEW TEMPLATE TO GET GRAPHIC OVERRIDES Autodesk.Revit.DB.View sourceTemplate = Data.Helpers.GetTemplateByName(m_doc, filterItem.Group.ToString()); OverrideGraphicSettings graphSetting = sourceTemplate.GetFilterOverrides(filterId); //FOR EACH TARGET TEMPLATE SELECTED, APPLY FILTERS foreach (ListViewItem templateItem in LsvTemplates.CheckedItems) { ElementId templateId = new ElementId(templateItem.ImageIndex); Autodesk.Revit.DB.View targetTemplate = m_doc.GetElement(templateId) as Autodesk.Revit.DB.View; if (!targetTemplate.IsFilterApplied(filterId)) // IF FILTER IS NOT APPLIED, ADD FILTER AND OVERRIDE GRAPHICS { targetTemplate.AddFilter(filterId); targetTemplate.SetFilterOverrides(filterId, graphSetting); infoFiltersTransferred.Add(m_doc.GetElement(filterId).Name + " -> " + targetTemplate.Name); Ana_NoOfFilters_Applied += 1; // collect data for analytics } else // IF FILTER ALREADY APPLIED, JUST OVERRIDE GRAPHICS { targetTemplate.SetFilterOverrides(filterId, graphSetting); infoFiltersGraphicOverriden.Add(m_doc.GetElement(filterId).Name + " -> " + targetTemplate.Name); Ana_NoOfFilters_Overriden += 1; // collect data for analytics } Ana_NoOfFilters_Total += 1; // collect data for analytics } } t.Commit(); } executionTime.Stop(); ExecTimeElapseS = executionTime.Elapsed.Seconds.ToString(); // collect data for analytics #endregion #region show Results Form UI.Info.Form_Results.resultHead = "Results"; UI.Info.Form_Results.resultMain1 = "Filters Transferred:"; UI.Info.Form_Results.resultMain2 = "Filters with Graphic Settings Overriden"; UI.Info.Form_Results.resultList1 = infoFiltersTransferred; UI.Info.Form_Results.resultList2 = infoFiltersGraphicOverriden; using (UI.Info.Form_Results thisForm = new Info.Form_Results()) { thisForm.ShowDialog(); } #endregion// show Results Form DialogResult = DialogResult.OK; useTime.Stop(); UseTimeElapseS = useTime.Elapsed.Seconds.ToString(); // collect data for analytics Utilities.GetAnalyticsCSV(m_doc, m_app); Helpers.TransferViewFiltersAnalytics(m_doc, m_app, UseTimeElapseS, ExecTimeElapseS, Ana_NoOfFilters_Total, Ana_NoOfFilters_Applied, Ana_NoOfFilters_Overriden, Ana_NoOfTemplates); }