void mi_Click(object sender, System.Windows.RoutedEventArgs e) { if (!AllElements.Any()) { return; } //select the elements DocumentManager.Instance.CurrentUIDocument.Selection.Elements.Clear(); var existingElements = new List <Element>(); foreach (var id in AllElements) { Element el; if (dynUtils.TryGetElement(id, out el)) { existingElements.Add(el); } } existingElements.ForEach(x => DocumentManager.Instance.CurrentUIDocument.Selection.Elements.Add(x)); //show the elements DocumentManager.Instance.CurrentUIDocument.ShowElements(existingElements.Select(x => x.Id).ToList()); }
void mi_Click(object sender, System.Windows.RoutedEventArgs e) { if (!AllElements.Any()) { return; } //select the elements dynRevitSettings.Doc.Selection.Elements.Clear(); var existingElements = new List <Element>(); foreach (var id in AllElements) { Element el; if (dynUtils.TryGetElement(id, typeof(Element), out el)) { existingElements.Add(el); } } existingElements.ForEach(x => dynRevitSettings.Doc.Selection.Elements.Add(x)); //show the elements dynRevitSettings.Doc.ShowElements(existingElements.Select(x => x.Id).ToList()); }
public bool AddElement(Element element) { if (!(element is Wire)) { if (AllElements.Any(x => x.Rect.IntersectsWith(element.Rect))) { return(false); } ConnectElement(element); } else { Wire createdWire = element as Wire; if (createdWire.Length == 0) { return(false); } if (WirePlacementConflict(createdWire)) { return(false); } Wire adjacentInput = null; Wire adjacentOutput = null; foreach (var wire in Wires) { if (PointInWire(createdWire.Position, wire)) { SplitWire(wire, createdWire.Position); break; } if (createdWire.WireDirection == wire.WireDirection) { if (createdWire.Position == wire.OutputPositions[0] && wire.OutputCounter == 0) { adjacentInput = wire; } if (createdWire.OutputPositions[0] == wire.Position) { adjacentOutput = wire; } if (adjacentInput != null && adjacentOutput != null) { break; } } } if (adjacentInput != null) { createdWire.Position = adjacentInput.Position; createdWire.Length += adjacentInput.Length; RemoveElement(adjacentInput); } if (adjacentOutput != null && Wires.Where(w => w.Position == createdWire.OutputPositions[0]).Count() == 1) { createdWire.Length += adjacentOutput.Length; RemoveElement(adjacentOutput); } ConnectElement(createdWire); } if (element is CircuitInput) { inputs.Add(element as CircuitInput); return(true); } if (element is CircuitOutput) { outputs.Add(element as CircuitOutput); return(true); } elements.Add(element); return(true); }