Exemplo n.º 1
0
        private void PurgeViews(UIDocument uiDoc, Transaction t)
        {
            var doc = uiDoc.Document;
            IEnumerable <View> docViews = new FilteredElementCollector(doc)
                                          .OfClass(typeof(View))
                                          .AsEnumerable()
                                          .Cast <View>();

            PurgeElementsWindow purgeWindow = new PurgeElementsWindow(doc, typeof(View))
            {
                PurgeRegExString =
                    @"(^Фасад ([1-9][0-9]|[1-9]) - [a-d]$)|(^3D вид ([1-9][0-9]|[1-9])$)|(^Разрез ([1-9][0-9]|[1-9])$)|(^Чертеж [1-9]?[0-9]$)|(^Узел [1-9]?[0-9]$)|(^Фрагмент of .*)|(^Копия .*)"
            };

            purgeWindow.ShowDialog();
            if (false == purgeWindow.DialogResult)
            {
                return;
            }

            ICollection <ElementId> viewsToDelete = new List <ElementId>();
            ElementId match;

            foreach (var viewName in purgeWindow.MatchingElementsListBox.Items)
            {
                match = docViews
                        .Where(v => (string)viewName == v.Name)
                        .Select(v => v.Id)
                        .FirstOrDefault();
                if (null != match)
                {
                    viewsToDelete.Add(match);
                }
            }

            t.Start("Purge Views");
            doc.Delete(viewsToDelete);
            t.Commit();
        }
Exemplo n.º 2
0
        private static void PurgeLinePattern(UIDocument uiDoc, Transaction t)
        {
            var doc = uiDoc.Document;

            IEnumerable <LinePatternElement> docLinePatternElements = new FilteredElementCollector(doc)
                                                                      .OfClass(typeof(LinePatternElement))
                                                                      .AsEnumerable()
                                                                      .Cast <LinePatternElement>();

            PurgeElementsWindow purgeWindow =
                new PurgeElementsWindow(doc, typeof(LinePatternElement))
            {
                PurgeRegExString = @"^IMPORT-.*$"
            };

            purgeWindow.ShowDialog();
            if (false == purgeWindow.DialogResult)
            {
                return;
            }

            ICollection <ElementId> patternsToDelete = new List <ElementId>();
            ElementId match;

            foreach (var patternName in purgeWindow.MatchingElementsListBox.Items)
            {
                match = docLinePatternElements
                        .FirstOrDefault(p => (string)patternName == p.Name)?.Id;
                if (null != match)
                {
                    patternsToDelete.Add(match);
                }
            }

            t.Start("Purge LinePatterns");
            doc.Delete(patternsToDelete);
            t.Commit();
        }