public virtual Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements) { UIApplication uiapp = commandData.Application; UIDocument uidoc = uiapp.ActiveUIDocument; Document doc = uidoc.Document; Application app = uiapp.Application; RevitTools.Doc = doc; RevitTools.App = app; RevitTools.Uidoc = uidoc; Autodesk.Revit.DB.View view = doc.ActiveView; if (doc.ActiveView.ViewType != ViewType.ThreeD) { TaskDialog.Show("Error", "It only works on a 3D view"); return(Result.Failed); } if (doc.PathName.ToString() == "" || doc.PathName.ToString().EndsWith("a")) { TaskDialog.Show("Error", "It doesn't work inside revit families"); return(Result.Failed); } var testView = doc.ActiveView as View3D; if (!testView.IsSectionBoxActive) { using (Transaction tx = new Transaction(doc)) { tx.Start("ClashDetective"); testView.IsSectionBoxActive = true; uiapp.ActiveUIDocument.RefreshActiveView(); tx.Commit(); } } //Debug var link = Clash.Documents(doc, app); try { App.thisApp.ShowForm(); return(Result.Succeeded); } catch (Exception ex) { message = ex.Message; return(Result.Failed); } }
public void Execute(UIApplication app) { using (Transaction tx = new Transaction(app.ActiveUIDocument.Document)) { tx.Start("ClashDetective"); Clash.Execute(app.ActiveUIDocument.Document); //MainUserControl.thisForm.FillResults(); app.ActiveUIDocument.RefreshActiveView(); tx.Commit(); } }
public void FillForm() { //Fill combo with linked documents foreach (var item in Clash.Documents(RevitTools.Doc, RevitTools.App)) { ListOfLinks.Items.Add(item.Key); } var SelectionA = new List <CheckBox>(); var SelectionB = new List <CheckBox>(); var categories = FormTools.ListOfCategories(RevitTools.Doc); foreach (var c in categories) { //List of CheckBox chbox = new CheckBox(); chbox.Content = c.Key; SelectionB.Add(chbox); // SelectionAList.Items.Add(chbox); } foreach (var c in categories) { //List of CheckBox chbox = new CheckBox(); chbox.Content = c.Key; SelectionA.Add(chbox); // SelectionAList.Items.Add(chbox); } SelectionAList.ItemsSource = SelectionA; SelectionBList.ItemsSource = SelectionB; //Presetting everything from a previous run foreach (var item in Clasher.Properties.Settings.Default.SelectionB) { int i = int.Parse(item); CheckBox chbox = SelectionBList.Items[i] as CheckBox; chbox.IsChecked = true; } foreach (var item in Clasher.Properties.Settings.Default.SelectionA) { int i = int.Parse(item); CheckBox chbox = SelectionAList.Items[i] as CheckBox; chbox.IsChecked = true; } ListOfLinks.SelectedIndex = Properties.Settings.Default.ListOfLinks; }
public static void Execute(Document doc) { if (!MainUserControl._Reset) { var clashing = Clash.clashingElements(RevitTools.Doc, RevitTools.App); string format = new string('0', clashing.Count.ToString().Length); for (int i = 0; i < clashing.Count; i++) { var item = clashing[i]; item.Number = (i).ToString(format);; MainUserControl.elementsClashingA.Add(item); } RevitTools.OverrideInView(clashing, RevitTools.Doc); } else { RevitTools.OverrideInView(new List <Element>(), RevitTools.Doc); } }
private void Run_Click(object sender, RoutedEventArgs e) { this.Results.Items.Clear(); SaveConfiguration(); RevitTools.CropBox = RevitTools.GetCropBox(); StringCollection selectionACollection = Properties.Settings.Default.SelectionA; StringCollection selectionBCollection = Properties.Settings.Default.SelectionB; string validationMessage = string.Empty; bool validationFlag = false; // Validation of elements selected if (selectionACollection.Count == 0 || selectionBCollection.Count == 0) { validationFlag = true; validationMessage = "Both categories must have elements selected to check for clashes"; } if (ListOfLinks.SelectedItem == null) { validationFlag = true; validationMessage = "Select a document to do the clash detection"; } // If validationFlag is true. The validation dialog is showed. if (validationFlag) { TaskDialog.Show("Clash Detection", validationMessage, TaskDialogCommonButtons.Ok); return; } _Reset = false; //Save Selection SaveConfiguration(); _wasExecuted = false; var index = Properties.Settings.Default.ListOfLinks; var l = Clash.Documents(RevitTools.Doc, RevitTools.App); // Get document from select index FormTools.linkedDocument = l.Values[index]; FormTools.SelectedCategories = new List <ElementFilter>(); FormTools.SelectedHostCategories = new List <ElementFilter>(); //Categories var cat = FormTools.ListOfCategories(RevitTools.Doc); //Get categories from select index foreach (var i in Properties.Settings.Default.SelectionB) { int item = int.Parse(i); BuiltInCategory myCatEnum = (BuiltInCategory)Enum.Parse(typeof(BuiltInCategory), cat.Values[item].Id.ToString()); FormTools.SelectedCategories.Add(new ElementCategoryFilter(myCatEnum)); } //Get categories from select index foreach (var i in Properties.Settings.Default.SelectionA) { int item = int.Parse(i); BuiltInCategory myCatEnum = (BuiltInCategory)Enum.Parse(typeof(BuiltInCategory), cat.Values[item].Id.ToString()); FormTools.SelectedHostCategories.Add(new ElementCategoryFilter(myCatEnum)); //Saving the local categories for a new run } m_ExEvent.Raise(); }