Пример #1
1
 public static IList<Element> AtLevel(Level arg)
 {
     var levFilter = new ElementLevelFilter(arg.InternalLevel.Id);
     var fec = new FilteredElementCollector(DocumentManager.Instance.CurrentDBDocument);
     var instances =
         fec.WherePasses(levFilter)
             .WhereElementIsNotElementType()
             .ToElementIds()
             .Select(id => ElementSelector.ByElementId(id.IntegerValue))
             .ToList();
     return instances;
 }
Пример #2
0
        public static Double Solstructurelparniveau(Document doc, Level level)
        {
            ElementId          levelid   = level.Id;
            ElementLevelFilter parniveau = new ElementLevelFilter(levelid);
            Dictionary <Level, List <Floor> > Dicosolparniveau = new Dictionary <Level, List <Floor> >();

            FilteredElementCollector floors = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Floors).WhereElementIsNotElementType().WherePasses(parniveau);
            double SDPniveau = 0.00;

            //int compte = floors.ToList().Count;
            //TaskDialog.Show("nombre de sols dans le niveau", string.Format("niveau :{0} , nombre de sol : {1}", level.Name.ToString(), compte));

            foreach (Floor floor in floors)
            {
                foreach (CompoundStructureLayer layer in floor.FloorType.GetCompoundStructure().GetLayers())
                {
                    if (layer.Function == MaterialFunctionAssignment.Structure & floor.Name.Contains("Terrasse") == false)
                    {
                        double surfacesol = floor.get_Parameter(BuiltInParameter.HOST_AREA_COMPUTED).AsDouble();
                        surfacesol = UnitUtils.ConvertFromInternalUnits(surfacesol, DisplayUnitType.DUT_SQUARE_METERS);
                        SDPniveau += surfacesol;
                    }
                }
            }

            return(SDPniveau);
        }
        private int GetCurrentLevelMaxFloorTags(Element level)
        {
            ElementCategoryFilter    elementCategoryFilter = new ElementCategoryFilter(BuiltInCategory.OST_Floors);
            ElementLevelFilter       elementLevelFilter    = new ElementLevelFilter(level.Id);
            FilteredElementCollector collectors            = new FilteredElementCollector(m_uIDocument.Document);
            IList <Element>          elementLists          = collectors.WherePasses(elementCategoryFilter).WhereElementIsNotElementType().WherePasses(elementLevelFilter).ToElements();

            List <int> tagLabels = new List <int>();

            int max = 0;

            foreach (var floor in elementLists)
            {
                string tagName = floor.LookupParameter("标记").AsString();
                if (!string.IsNullOrEmpty(tagName))
                {
                    int current = int.Parse(tagName.Split('-')[1]);
                    if (current > max)
                    {
                        max = current;
                    }
                }
            }

            TaskDialog.Show("Message", "该层最大标记值为: " + max.ToString());
            return(max);
        }
        public void CreateLevelFloorTags(Document doc)
        {
            Autodesk.Revit.DB.View view = doc.ActiveView;
            Element Level = GetCurrentLevel(doc, view.Name);

            ElementCategoryFilter    elementCategoryFilter = new ElementCategoryFilter(BuiltInCategory.OST_Floors);
            ElementLevelFilter       elementLevelFilter    = new ElementLevelFilter(Level.Id);
            FilteredElementCollector collectors            = new FilteredElementCollector(m_uIDocument.Document);
            IList <Element>          elementLists          = collectors.WherePasses(elementCategoryFilter).WhereElementIsNotElementType().WherePasses(elementLevelFilter).ToElements();

            int index = 1;

            foreach (var floor in elementLists)
            {
                string labelContent = RenameLabel(floor, index);
                CreateOneFloorIndependentTag(doc, floor as Floor, labelContent);
                index++;
            }

            //ICollection<ElementId> elementids = m_selection.GetElementIds();

            //int index = 1;
            //foreach (var floorId in elementids)
            //{
            //    Element floor = doc.GetElement(floorId);
            //    string labelContent = RenameLabel(floor, index);
            //    CreateOneFloorIndependentTag(doc, floor as Floor, labelContent);
            //    index++;
            //}
        }
Пример #5
0
        public static IList <Element> AtLevel(Level arg)
        {
            var levFilter = new ElementLevelFilter(arg.InternalLevel.Id);
            var fec       = new FilteredElementCollector(DocumentManager.Instance.CurrentDBDocument);
            var instances =
                fec.WherePasses(levFilter)
                .WhereElementIsNotElementType()
                .ToElementIds()
                .Select(id => ElementSelector.ByElementId(id.IntegerValue))
                .ToList();

            return(instances);
        }
        /// <summary>
        /// 获取某标高上的模型图元
        /// </summary>
        /// <param name="doc">当前文档</param>
        /// <param name="level">该标高</param>
        /// <returns></returns>
        public List <Element> GetElementOfLevel(Document doc, Level level)
        {
            ElementLevelFilter       levelFilter = new ElementLevelFilter(level.Id, false);
            FilteredElementCollector elements    = new FilteredElementCollector(doc).WherePasses(levelFilter);
            List <Element>           elsList     = new List <Element>();

            if (elements.ToList().Count != 0)
            {
                foreach (Element el in elements)
                {
                    if (el.Category.CategoryType == CategoryType.Model)
                    {
                        elsList.Add(el);
                    }
                }
            }
            return(elsList);
        }
        public void MarkFloorInfo(Document doc)
        {
            Autodesk.Revit.DB.View view = doc.ActiveView;
            Element Level = GetCurrentLevel(doc, view.Name);

            ElementCategoryFilter    elementCategoryFilter = new ElementCategoryFilter(BuiltInCategory.OST_Floors);
            ElementLevelFilter       elementLevelFilter    = new ElementLevelFilter(Level.Id);
            FilteredElementCollector collectors            = new FilteredElementCollector(m_uIDocument.Document);
            IList <Element>          elementLists          = collectors.WherePasses(elementCategoryFilter).WhereElementIsNotElementType().WherePasses(elementLevelFilter).ToElements();

            foreach (var floor in elementLists)
            {
                string dep   = floor.LookupParameter("科室").AsString();
                string usage = floor.LookupParameter("用途").AsString();
                string area  = floor.LookupParameter("房间面积").AsString();
                //string number = floor.LookupParameter("空间-新").AsString();
                string labelContent = dep + "\n" + usage + "\n" + area;
                CreateOneFloorIndependentTag(doc, floor as Floor, labelContent);
            }
        }
Пример #8
0
        public static double Surfacemurextparniveau(Document doc, Level level)
        {
            double                   surfacetot = 0.00;
            ElementId                levelid    = level.Id;
            ElementLevelFilter       parniveau  = new ElementLevelFilter(levelid);
            FilteredElementCollector walls      = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls).WhereElementIsNotElementType().WherePasses(parniveau);

            foreach (Wall wall in walls)
            {
                string fonction = wall.WallType.LookupParameter("Fonction").AsString();

                if (fonction == "exterieur")
                {
                    double longueur = wall.LookupParameter("Longueur").AsDouble();
                    longueur = UnitUtils.ConvertFromInternalUnits(longueur, DisplayUnitType.DUT_METERS);
                    double epais = wall.WallType.Width;
                    epais = UnitUtils.ConvertFromInternalUnits(epais, DisplayUnitType.DUT_METERS);
                    double surfacemurext = epais * longueur;
                    surfacetot += surfacemurext;
                }
            }
            return(surfacetot);
        }
Пример #9
0
        public static WallType[] GetTypesOfWallsForLevel(ElementId levelId)
        {
            var collector       = new FilteredElementCollector(Document);
            var levelFilter     = new ElementLevelFilter(levelId);
            var allWallsOnLevel = collector
                                  .OfClass(typeof(Wall))
                                  .WherePasses(levelFilter)
                                  .ToElements()
                                  .Select(x => ((Wall)x).WallType)
                                  .Where(x => x.Width < 0.17);
            List <WallType> result   = new List <WallType>();
            List <int>      resultId = new List <int>();

            foreach (var wall in allWallsOnLevel)
            {
                if (!resultId.Contains(wall.Id.IntegerValue))
                {
                    result.Add(wall);
                    resultId.Add(wall.Id.IntegerValue);
                }
            }
            return(result.ToArray());
        }
        // 383_param_filter.htm
        void f1( Document doc )
        {
            FilteredElementCollector collector
            = new FilteredElementCollector( doc );

              ICollection<Element> levels
            = collector.OfClass( typeof( Level ) )
              .ToElements();

              for( int i = 0; i < levels.Count; i++ )
              {
            ElementId levelId = levels.ElementAt( i ).Id;

            ElementLevelFilter levelFilter
              = new ElementLevelFilter( levelId );

            collector = new FilteredElementCollector( doc );

            ICollection<Element> allOnLevel
              = collector.WherePasses( levelFilter )
            .ToElements();

            // . . .
              }
        }
Пример #11
0
        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument uidoc = uiapp.ActiveUIDocument;
            Application app = uiapp.Application;
            Document doc = uidoc.Document;
            _app = app;
            _doc = doc;

            // Set project units to Meters then back after
            // This is how DIALux reads the data from the STF File.

            Units pUnit = doc.GetUnits();
            FormatOptions formatOptions = pUnit.GetFormatOptions(UnitType.UT_Length);

            //DisplayUnitType curUnitType = pUnit.GetDisplayUnitType();
            DisplayUnitType curUnitType = formatOptions.DisplayUnits;

            using (Transaction tx = new Transaction(doc))
            {
                tx.Start("STF EXPORT");
                const DisplayUnitType meters = DisplayUnitType.DUT_METERS;
                formatOptions.DisplayUnits = meters;
                // Comment out, different in 2014
                //formatOptions.Units = meters;
                //formatOptions.Rounding = 0.0000000001;]

                formatOptions.Accuracy = 0.0000000001;
                // Fix decimal symbol for int'l versions (set back again after finish)
                if (pUnit.DecimalSymbol == DecimalSymbol.Comma)
                {
                    intlVersion = true;
                    //TESTING
                    //TaskDialog.Show("INTL", "You have an internationalized version of Revit!");
                    formatOptions.UseDigitGrouping = false;
                    pUnit.DecimalSymbol = DecimalSymbol.Dot;
                }

                try
                {
                    // Filter for only active view.
                    ElementLevelFilter filter = new ElementLevelFilter(doc.ActiveView.GenLevel.Id);

                    FilteredElementCollector fec = new FilteredElementCollector(doc, doc.ActiveView.Id)
                        .OfCategory(BuiltInCategory.OST_MEPSpaces)
                        .WherePasses(filter);

                    int numOfRooms = fec.Count();
                    writer += "[VERSION]\n"
                              + "STFF=" + stfVersionNum + "\n"
                              + "Progname=Revit\n"
                              + "Progvers=" + app.VersionNumber + "\n"
                              + "[Project]\n"
                              + "Name=" + _doc.ProjectInformation.Name + "\n"
                              + "Date=" + DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" +
                              DateTime.Now.Day.ToString() + "\n"
                              + "Operator=" + app.Username + "\n"
                              + "NrRooms=" + numOfRooms + "\n";

                    for (int i = 1; i < numOfRooms + 1; i++)
                    {
                        string _dialuxRoomName = "Room" + i.ToString() + "=ROOM.R" + i.ToString();
                        writer += _dialuxRoomName + "\n";
                    }

                    int increment = 1;

                    // Space writer
                    try
                    {
                        foreach (Element e in fec)
                        {
                            Space s = e as Space;
                            string roomRNum = "ROOM.R" + increment.ToString();
                            writer += "[" + roomRNum + "]\n";
                            SpaceInfoWriter(s.Id, roomRNum);
                            increment++;
                        }

                        // Write out Luminaires to bottom
                        writeLumenairs();

                        // Reset back to original units
                        formatOptions.DisplayUnits = curUnitType;
                        if (intlVersion)
                            pUnit.DecimalSymbol = DecimalSymbol.Comma;

                        tx.Commit();

                        SaveFileDialog dialog = new SaveFileDialog
                        {
                            FileName = doc.ProjectInformation.Name,
                            Filter = "STF File | *.stf",
                            FilterIndex = 2,
                            RestoreDirectory = true
                        };

                        if (dialog.ShowDialog() == DialogResult.OK)
                        {
                            StreamWriter sw = new StreamWriter(dialog.FileName);
                            string[] ar = writer.Split('\n');
                            for (int i = 0; i < ar.Length; i++)
                            {
                                sw.WriteLine(ar[i]);
                            }
                            sw.Close();
                        }

                        return Result.Succeeded;
                    }
                    catch (IndexOutOfRangeException)
                    {
                        return Result.Failed;
                    }
                }
                catch (NullReferenceException)
                {
                    TaskDialog.Show("Incorrect View", "Cannot find Spaces to export.\nMake sure you are in a Floorplan or Ceiling Plan view and Spaces are visible.");
                    return Result.Failed;
                }
            }
        }
Пример #12
0
        public Result Execute(
            ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument    uidoc = uiapp.ActiveUIDocument;
            Application   app   = uiapp.Application;
            Document      doc   = uidoc.Document;

            _app = app;
            _doc = doc;

            // Set project units to Meters then back after
            // This is how DIALux reads the data from the STF File.

            Units         pUnit         = doc.GetUnits();
            FormatOptions formatOptions = pUnit.GetFormatOptions(UnitType.UT_Length);

            //DisplayUnitType curUnitType = pUnit.GetDisplayUnitType();
            DisplayUnitType curUnitType = formatOptions.DisplayUnits;

            using (Transaction tx = new Transaction(doc))
            {
                tx.Start("STF EXPORT");
                const DisplayUnitType meters = DisplayUnitType.DUT_METERS;
                formatOptions.DisplayUnits = meters;
                // Comment out, different in 2014
                //formatOptions.Units = meters;
                //formatOptions.Rounding = 0.0000000001;]

                formatOptions.Accuracy = 0.0000000001;
                // Fix decimal symbol for int'l versions (set back again after finish)
                if (pUnit.DecimalSymbol == DecimalSymbol.Comma)
                {
                    intlVersion = true;
                    //TESTING
                    //TaskDialog.Show("INTL", "You have an internationalized version of Revit!");
                    formatOptions.UseDigitGrouping = false;
                    pUnit.DecimalSymbol            = DecimalSymbol.Dot;
                }

                // Filter for only active view.
                try
                {
                    ElementLevelFilter filter = new ElementLevelFilter(doc.ActiveView.GenLevel.Id);

                    FilteredElementCollector fec = new FilteredElementCollector(doc, doc.ActiveView.Id)
                                                   .OfCategory(BuiltInCategory.OST_MEPSpaces)
                                                   .WherePasses(filter);

                    if (fec.Count() < 1)
                    {
                        throw new NullReferenceException();
                    }

                    int numOfRooms = fec.Count();
                    writer += "[VERSION]\n"
                              + "STFF=" + stfVersionNum + "\n"
                              + "Progname=Revit\n"
                              + "Progvers=" + app.VersionNumber + "\n"
                              + "[Project]\n"
                              + "Name=" + _doc.ProjectInformation.Name + "\n"
                              + "Date=" + DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString() + "-" +
                              DateTime.Now.Day.ToString() + "\n"
                              + "Operator=" + app.Username + "\n"
                              + "NrRooms=" + numOfRooms + "\n";

                    for (int i = 1; i < numOfRooms + 1; i++)
                    {
                        string _dialuxRoomName = "Room" + i.ToString() + "=ROOM.R" + i.ToString();
                        writer += _dialuxRoomName + "\n";
                    }

                    int increment = 1;

                    // Space writer
                    try
                    {
                        foreach (Element e in fec)
                        {
                            Space  s        = e as Space;
                            string roomRNum = "ROOM.R" + increment.ToString();
                            writer += "[" + roomRNum + "]\n";
                            SpaceInfoWriter(s.Id, roomRNum);
                            increment++;
                        }


                        // Write out Luminaires to bottom
                        writeLumenairs();

                        // Reset back to original units
                        formatOptions.DisplayUnits = curUnitType;
                        if (intlVersion)
                        {
                            pUnit.DecimalSymbol = DecimalSymbol.Comma;
                        }


                        tx.Commit();

                        SaveFileDialog dialog = new SaveFileDialog
                        {
                            FileName         = doc.ProjectInformation.Name,
                            Filter           = "File format STF | *.stf",
                            FilterIndex      = 2,
                            RestoreDirectory = true
                        };

                        if (dialog.ShowDialog() == DialogResult.OK)
                        {
                            StreamWriter sw = new StreamWriter(dialog.FileName, false, Encoding.UTF8);
                            string[]     ar = writer.Split('\n');
                            for (int i = 0; i < ar.Length; i++)
                            {
                                sw.WriteLine(ar[i]);
                            }
                            sw.Close();

                            TaskDialog.Show("Done", "STF file writed.");
                        }

                        return(Result.Succeeded);
                    }
                    catch (IndexOutOfRangeException)
                    {
                        return(Result.Failed);
                    }
                }
                catch (NullReferenceException)
                {
                    TaskDialog.Show("Incorrect View", "Cannot find Spaces to export.\nMake sure you are in a Floorplan or Ceiling Plan view and Spaces are visible.");
                    return(Result.Failed);
                }
            }
        }
Пример #13
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            Document doc = commandData.Application.ActiveUIDocument.Document;

            // Call WPF for user input
            using (NumberBySplineWPF customWindow = new NumberBySplineWPF(commandData))
            {
                // Revit application as window's owner
                System.Windows.Interop.WindowInteropHelper helper = new System.Windows.Interop.WindowInteropHelper(customWindow);
                helper.Owner = System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle;

                customWindow.ShowDialog();
                ElementId curveId = customWindow.CurveId;

                if (customWindow.Cancel == false && curveId != null)
                {
                    CurveElement eCurve = doc.GetElement(curveId) as CurveElement;
                    Curve        curve  = eCurve.GeometryCurve as Curve;

                    XYZ[] points = Helpers.HelpersGeometry.DivideEquallySpline(curve, 1000);

                    // Retrieve elements of selected category
                    Category  cat          = customWindow.SelectedComboItemCategories.Tag as Category;
                    Level     level        = customWindow.SelectedComboItemLevels.Tag as Level;
                    Parameter selParameter = customWindow.SelectedComboItemParameters.Tag as Parameter;
                    string    startNumber  = customWindow.StartNumber;
                    string    prefix       = customWindow.Prefix;

                    ElementLevelFilter       levelFilter     = new ElementLevelFilter(level.Id);
                    FilteredElementCollector collectElements = new FilteredElementCollector(doc).OfCategoryId(cat.Id).WhereElementIsNotElementType();

                    // Create two list that contains all selected elements
                    List <Element> selElements     = new List <Element>();
                    List <Element> selElementsCopy = new List <Element>();

                    foreach (Element element in collectElements)
                    {
                        if (element.LevelId == level.Id)
                        {
                            selElements.Add(element);
                            selElementsCopy.Add(element);
                        }
                    }

                    // Renumber selected elements
                    using (Transaction tx = new Transaction(doc))
                    {
                        tx.Start("Draw Curves at Points");

                        int number = int.Parse(startNumber);

                        // Loop through each point to check if it is inside the selected elements
                        foreach (XYZ point in points)
                        {
                            // Inner loop to check point is inside the element, if so, remove element from list and proceed until end of list
                            for (int j = 0; j < selElementsCopy.Count; j++)
                            {
                                // Retrieve bounding box of element
                                BoundingBoxXYZ bBox         = selElementsCopy[j].get_BoundingBox(null);
                                int            intersResult = Helpers.HelpersGeometry.IsPointInsideRectangle(point, bBox.Min, bBox.Max);

                                if (intersResult != 0)
                                {
                                    Parameter param = selElementsCopy[j].LookupParameter(selParameter.Definition.Name);
                                    param.Set(prefix + number.ToString());
                                    selElementsCopy.Remove(selElementsCopy[j]);

                                    number++;
                                    break;
                                }
                            }
                        }
                        tx.Commit();
                    }
                    return(Result.Succeeded);
                }
                return(Result.Cancelled);
            }
        }
Пример #14
0
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elementset)
        {
            UIDocument uiDoc = commandData.Application.ActiveUIDocument;
            Document   doc   = commandData.Application.ActiveUIDocument.Document;

            #region 获取项目内的标高
            FilteredElementCollector levelcollector = new FilteredElementCollector(doc);
            ElementCategoryFilter    levelfilter    = new ElementCategoryFilter(BuiltInCategory.OST_Levels);
            levelcollector.WhereElementIsNotElementType();
            levelcollector.WherePasses(levelfilter);
            List <Level> levellist = levelcollector.Select(e => e as Level).ToList();
            #endregion


            #region 窗口
            MyWindow mywindow = new MyWindow();
            List <System.Windows.Controls.CheckBox> checkboxs = new List <System.Windows.Controls.CheckBox>();
            foreach (Level level in levellist)
            {
                System.Windows.Controls.CheckBox checkbox = new System.Windows.Controls.CheckBox();
                checkbox.Content   = level.Name;
                checkbox.IsChecked = true;
                checkboxs.Add(checkbox);
            }
            mywindow.listbox.ItemsSource = checkboxs;

            if (mywindow.ShowDialog() == true)
            {
                List <string> uncheckeds = new List <string>();
                foreach (System.Windows.Controls.CheckBox whoisunchecked in mywindow.listbox.ItemsSource)
                {
                    if (whoisunchecked.IsChecked != true)
                    {
                        uncheckeds.Add(whoisunchecked.Content as string);
                    }
                }

                for (int i = levellist.Count - 1; i >= 0; i--)
                {
                    foreach (string str in uncheckeds)
                    {
                        if (levellist[i].Name == str)
                        {
                            levellist.Remove(levellist[i]);
                            break;
                        }
                    }
                }
            }
            #endregion

            #region 根据类别和类型和标高处理框的图元(保留一个filters)
            List <ElementId>      elementids = uiDoc.Selection.GetElementIds().ToList();
            List <ElementFilter>  filters    = new List <ElementFilter>();
            ElementCategoryFilter filter2    = new ElementCategoryFilter(BuiltInCategory.OST_Doors);
            ElementCategoryFilter filter3    = new ElementCategoryFilter(BuiltInCategory.OST_Windows);
            ElementCategoryFilter filter4    = new ElementCategoryFilter(BuiltInCategory.OST_GenericModel);
            ElementCategoryFilter filter5    = new ElementCategoryFilter(BuiltInCategory.OST_Furniture);
            ElementCategoryFilter filter6    = new ElementCategoryFilter(BuiltInCategory.OST_SpecialityEquipment);
            filters.Add(filter2);
            filters.Add(filter3);
            filters.Add(filter4);
            filters.Add(filter5);
            filters.Add(filter6);
            LogicalOrFilter orfilter = new LogicalOrFilter(filters);

            List <ElementFilter> filters2 = new List <ElementFilter>();
            foreach (Level level in levellist)
            {
                ElementLevelFilter filterlevel = new ElementLevelFilter(level.Id);
                filters2.Add(filterlevel);
            }
            LogicalOrFilter orfilter2 = new LogicalOrFilter(filters2);
            #endregion


            foreach (ElementId elementid in elementids)
            {
                //使用过滤器过滤不需要的图元
                FilteredElementCollector collector = new FilteredElementCollector(doc);
                collector.WherePasses(orfilter);
                collector.WherePasses(orfilter2);
                collector.WhereElementIsNotElementType(); //去掉类型,仅保留模型图元.


                Element element = doc.GetElement(elementid);
                //先判断选中的图元是不是在  常规模型\家具\窗\门\专用设备  五个类别内.
                Category        category        = element.Category;
                BuiltInCategory builtincategory = (BuiltInCategory)category.Id.IntegerValue;
                if ((builtincategory != BuiltInCategory.OST_Furniture) && (builtincategory != BuiltInCategory.OST_GenericModel) && (builtincategory != BuiltInCategory.OST_Windows) &&
                    (builtincategory != BuiltInCategory.OST_Doors) && (builtincategory != BuiltInCategory.OST_SpecialityEquipment))
                {
                    continue;
                }


                //再根据类型进行筛选.
                ElementId            typeid  = element.GetTypeId();
                FamilyInstanceFilter filter7 = new FamilyInstanceFilter(doc, typeid);
                collector.WherePasses(filter7);


                //TaskDialog.Show("revit", Convert.ToString(collector.Count()));

                //根据XY相同 Z不同进行判断是否删除
                Location      location      = element.Location;
                LocationPoint locationpoint = location as LocationPoint;

                List <ElementId> ids = new List <ElementId>();

                XYZ point = locationpoint.Point;

                foreach (Element ele in collector)
                {
                    if (ele.Location as LocationPoint == null)
                    {
                        continue;
                    }
                    XYZ point2 = (ele.Location as LocationPoint).Point;
                    if (point.X == point2.X && point.Y == point2.Y && point.Z != point2.Z)
                    {
                        ids.Add(ele.Id);
                    }
                }

                using (Transaction transaction = new Transaction(doc))  //删除重复图元
                {
                    transaction.Start("GroupLike");
                    doc.Delete(ids);
                    transaction.Commit();
                }
            }
            TaskDialog.Show("revit", "已删除处于相同XY坐标不同Z坐标的同类型图元.");
            return(Result.Succeeded);
        }