示例#1
0
        protected override void Updater_ElementsDeleted(
            Document document, IEnumerable <ElementId> deleted)
        {
            if (!SelectionResults.Any() ||
                !document.Equals(SelectionOwner) ||
                !deleted.Any())
            {
                return;
            }

            // If the deleting operations does not make any elements in SelectionResults
            // invalid, then there is no need to update.
            if (SelectionResults.Where(el => !el.IsValidObject).Count() == 0)
            {
                return;
            }

            // We are given a set of ElementIds, but because the elements
            // have already been deleted from Revit, we can't get the
            // corresponding GUID. Instead, we just go through the collection of
            // elements and get the ones that are still valid.

            var validEls = Selection.Where(el => el.IsValidObject).ToList();

            UpdateSelection(validEls);
        }
示例#2
0
        protected override void Updater_ElementsDeleted(
            Document document, IEnumerable <ElementId> deleted)
        {
            // If an element is deleted, ensure all references which refer
            // to that element are removed from the selection

            if (!SelectionResults.Any() || !document.Equals(SelectionOwner))
            {
                return;
            }

            UpdateSelection(SelectionResults.Where(x => !deleted.Contains(x.ElementId)));

            RaisePropertyChanged("SelectionResults");
            RaisePropertyChanged("Text");
            RequiresRecalc = true;
        }
示例#3
0
        protected override void Updater_ElementsModified(IEnumerable <string> updated)
        {
            // If nothing has been updated, then return

            if (!updated.Any())
            {
                return;
            }

            // If the updated list doesn't include any objects in the current selection
            // then return;
            if (!SelectionResults.Where(x => x.IsValidObject).Select(x => x.UniqueId).Any(updated.Contains))
            {
                return;
            }

            UpdateSelection(Selection);
        }
示例#4
0
        protected override void Updater_ElementsDeleted(
            Document document, IEnumerable <ElementId> deleted)
        {
            // If an element is deleted, ensure all references which refer
            // to that element are removed from the selection

            // If there is no selection, or the doc of the deleted
            // elements is not this doc, or if there is nothing
            // in the deleted set, then return

            if (!SelectionResults.Any() ||
                !document.Equals(SelectionOwner) ||
                !deleted.Any() ||
                !SelectionResults.Any(x => deleted.Contains(x.ElementId)))
            {
                return;
            }

            // The new selections is everything in the current selection
            // that is not in the deleted collection as well
            var newSelection = SelectionResults.Where(x => !deleted.Contains(x.ElementId));

            UpdateSelection(newSelection);
        }