Exemplo n.º 1
0
        public static List <DeletableItem> Revisions(Document doc)
        {
            var result = new List <DeletableItem>();

            using (var f = new FilteredElementCollector(doc))
            {
                f.OfCategory(BuiltInCategory.OST_Revisions);
                foreach (Element revision in f)
                {
                    string s        = GetParameterList(revision.Parameters);
                    var    nodeName = revision.get_Parameter(BuiltInParameter.PROJECT_REVISION_REVISION_DATE).AsString() + " - " +
                                      revision.get_Parameter(BuiltInParameter.PROJECT_REVISION_REVISION_DESCRIPTION).AsString();
                    var tn = new DeletableItem(nodeName);
                    tn.Info = "Name = " + revision.Name + System.Environment.NewLine +
                              "id - " + revision.Id;
                    tn.Info += System.Environment.NewLine + s;
                    tn.Id    = revision.Id;
                    if (revision.get_Parameter(BuiltInParameter.PROJECT_REVISION_SEQUENCE_NUM).AsInteger() > 1)
                    {
                        result.Add(tn);
                    }
                }
            }
            return(result);
        }
Exemplo n.º 2
0
        public static List <DeletableItem> Imports(Document doc, bool linked)
        {
            var result = new List <DeletableItem>();

            using (var f = new FilteredElementCollector(doc))
            {
                f.OfClass(typeof(ImportInstance));
                var name = string.Empty;
                foreach (var element in f)
                {
                    var ii = (ImportInstance)element;
                    if (ii.IsLinked == linked)
                    {
                        var s = string.Empty;
                        s += "View Specific - " + ii.ViewSpecific.ToString(System.Globalization.CultureInfo.CurrentCulture) + System.Environment.NewLine;
                        s += "Owner view id - " + ii.OwnerViewId + System.Environment.NewLine;
                        ParameterSet p = ii.Parameters;
                        foreach (Parameter param in p)
                        {
                            s += param.Definition.Name + " - " + param.AsString() + System.Environment.NewLine;
                            if (param.Definition.Name == "Name")
                            {
                                name = param.AsString();
                            }
                        }
                        s += "Element id - " + ii.Id;
                        var tn = new DeletableItem(name);
                        tn.Id   = ii.Id;
                        tn.Info = s;
                        result.Add(tn);
                    }
                }
            }
            return(result);
        }
Exemplo n.º 3
0
        public static List <DeletableItem> UnusedViewFilters(Document doc)
        {
            Dictionary <ElementId, ElementId> usedFilters = new Dictionary <ElementId, ElementId>();

            using (var viewCollecter = new FilteredElementCollector(doc))
            {
                viewCollecter.OfClass(typeof(View));
                foreach (var element in viewCollecter)
                {
                    var view = (View)element;
                    if (view.AreGraphicsOverridesAllowed())
                    {
                        foreach (ElementId id in view.GetFilters())
                        {
                            if (!usedFilters.ContainsKey(id))
                            {
                                usedFilters.Add(id, id);
                            }
                        }
                    }
                }
            }

            var result = new List <DeletableItem>();

            using (var f = new FilteredElementCollector(doc))
            {
                f.OfClass(typeof(FilterElement));
                foreach (Element filter in f)
                {
                    if (!usedFilters.ContainsKey(filter.Id))
                    {
                        string s        = GetParameterList(filter.Parameters);
                        var    nodeName = filter.Name;
                        var    tn       = new DeletableItem(nodeName);
                        tn.Info = "Name = " + filter.Name + System.Environment.NewLine +
                                  "id - " + filter.Id;
                        tn.Info += System.Environment.NewLine + s;
                        tn.Id    = filter.Id;
                        result.Add(tn);
                    }
                }
            }
            return(result);
        }
Exemplo n.º 4
0
        public static List <DeletableItem> Images(Document doc)
        {
            var result = new List <DeletableItem>();

            using (var f = new FilteredElementCollector(doc))
            {
                f.OfCategory(BuiltInCategory.OST_RasterImages);
                foreach (Element image in f)
                {
                    var s  = GetParameterList(image.Parameters);
                    var tn = new DeletableItem(image.Name)
                    {
                        Info = "Name = " + image.Name + System.Environment.NewLine +
                               "id - " + image.Id
                    };
                    tn.Info += System.Environment.NewLine + s;
                    tn.Id    = image.Id;

                    var typeId = image.GetTypeId();
                    tn.ParentId = typeId;
                    var type = doc.GetElement(typeId) as ImageType;
                    if (type == null)
                    {
                        continue;
                    }
                    try
                    {
                        tn.PreviewImage = type.GetImage();
                        tn.HasParent    = true;
                    }
                    catch
                    {
                        tn.PreviewImage = null;
                    }
                    result.Add(tn);
                }
            }
            return(result);
        }
Exemplo n.º 5
0
        public static List <DeletableItem> UnboundRooms(Document doc)
        {
            var result = new List <DeletableItem>();

            using (var f = new FilteredElementCollector(doc))
            {
                f.OfCategory(BuiltInCategory.OST_Rooms);
                foreach (Element room in f)
                {
                    string       s     = string.Empty;
                    bool         bound = false;
                    ParameterSet p     = room.Parameters;
                    foreach (Parameter param in p)
                    {
                        if (param.HasValue)
                        {
                            s += param.Definition.Name + " - " + param.AsString() + param.AsValueString() + System.Environment.NewLine;
                        }
                        if (param.Definition.Name == "Area" && param.AsDouble() > 0)
                        {
                            bound = true;
                        }
                    }
                    var tn = new DeletableItem(room.Name)
                    {
                        Info = "Name = " + room.Name + System.Environment.NewLine + "id - " + room.Id
                    };
                    tn.Info += System.Environment.NewLine + s;
                    tn.Id    = room.Id;
                    if (!bound)
                    {
                        result.Add(tn);
                    }
                }
            }
            return(result);
        }
Exemplo n.º 6
0
        // FIXME add view templates and project browser views to new category
        public static List <DeletableItem> Views(Document doc, bool placedOnSheet, ViewType type)
        {
            var result = new List <DeletableItem>();

            using (var f = new FilteredElementCollector(doc))
            {
                f.OfClass(typeof(View));
                foreach (var element in f)
                {
                    var view = (View)element;
                    if (view.ViewType == type && !view.IsTemplate)
                    {
                        var s   = string.Empty;
                        var num = string.Empty;
                        var os  = false;

                        Parameter p = GetParameterByName(view, "Dependency");

                        s += "Name - " + view.Name + System.Environment.NewLine;
                        if (p != null)
                        {
                            var d = p.AsString();
                            if (d == "Primary")
                            {
                                s += "Dependency - " + d + " [May be safe to delete]" + System.Environment.NewLine;
                                os = true;
                            }
                            else
                            {
                                s += "Dependency - " + d + System.Environment.NewLine;
                            }
                        }

                        var p2 = GetParameterByName(view, "Sheet Number");
                        if (p2 != null)
                        {
                            num = p2.AsString();
                            s  += "Sheet Number - " + num + System.Environment.NewLine;
                            os |= num != "---" && !string.IsNullOrEmpty(num);
                        }
                        else
                        {
                            s += @"Sheet Number - N/A" + System.Environment.NewLine;
                        }
                        s += "Element id - " + view.Id + System.Environment.NewLine;
                        s += System.Environment.NewLine + "[EXTENDED INFO]" + System.Environment.NewLine;
                        s += GetParameterList(view.Parameters);

                        string n;
                        if (type == ViewType.DrawingSheet)
                        {
                            n = num + " - " + view.Name;
                        }
                        else
                        {
                            n = view.Name;
                        }

                        var tn = new DeletableItem(n)
                        {
                            Info = s, Id = view.Id, HasParent = s.Contains(@"Parent View")
                        };
                        if (tn.HasParent)
                        {
                            Parameter parentId = view.GetParameters(@"Parent View")[0];
                            var       pId      = parentId.AsElementId();
                            tn.ParentId = pId;
                        }
                        if (view.ViewType == ViewType.ProjectBrowser || view.ViewType == ViewType.SystemBrowser)
                        {
                            continue;
                        }

                        if (view.ViewType != ViewType.Internal)
                        {
                            if (os && placedOnSheet)
                            {
                                result.Add(tn);
                            }
                            if (!os && !placedOnSheet)
                            {
                                result.Add(tn);
                            }
                        }
                    }
                }
            }
            return(result);
        }