/// <summary> /// Adds 1 to all elements with the same prefix and bigger number than the one on selection /// </summary> public static void SetElementsUpStream() { tools.AddToSelection(); if (tools.selectedElement != null) { //Get the selected element Element element = tools.selectedElement; //Get Shared parameter with the Prefix and number var startNumber = getNumber(element); //Get Number and prefix of the selected element var limit = GetNumberAndPrexif(startNumber); //Get filter with all the MEP categories LogicalOrFilter logicalOrFilter = new LogicalOrFilter(MEPCategories.listCat()); //Get all MEP elements in active view var collector = new FilteredElementCollector(doc, doc.ActiveView.Id).WherePasses(logicalOrFilter).WhereElementIsNotElementType(); if (limit != null) { foreach (var item in collector.ToElements()) { var number = getNumber(item); if (number != null) { if (number.Contains(limit.Item1)) { var itemNumber = GetNumberAndPrexif(number); if (itemNumber != null) { var limitNumber = int.Parse(limit.Item2); var currentNumber = int.Parse(itemNumber.Item2); if (limitNumber < currentNumber) { var newnumber = createNumbering(itemNumber.Item1, MainForm.Separator, currentNumber + 1, itemNumber.Item2.Count()); AssingPartNumber(item, newnumber); } } } } } } } else { MessageBox.Show("Please select an element"); } }
/// <summary> /// Subtract 1 to all elements with the same prefix and bigger number than the one on selection /// </summary> internal static void SetElementsDnStream() { tools.AddToSelection(); if (tools.selectedElement != null) { Element element = tools.selectedElement; LogicalOrFilter logicalOrFilter = new LogicalOrFilter(MEPCategories.listCat()); var collector = new FilteredElementCollector(doc, doc.ActiveView.Id).WherePasses(logicalOrFilter).WhereElementIsNotElementType(); var startNumber = getNumber(element); var limit = GetNumberAndPrexif(startNumber); if (limit != null) { foreach (var item in collector.ToElements()) { var number = getNumber(item); if (number != null) { if (number.Contains(limit.Item1)) { var itemNumber = GetNumberAndPrexif(number); if (itemNumber != null) { var limitNumber = int.Parse(limit.Item2); var currentNumber = int.Parse(itemNumber.Item2); if (limitNumber < currentNumber) { var newnumber = createNumbering(itemNumber.Item1, MainForm.Separator, currentNumber - 1, itemNumber.Item2.Count()); AssingPartNumber(item, newnumber); } } } } } } } else { MessageBox.Show("Please select an element"); } }