当前位置: 首页>>代码示例>>C#>>正文


C# FilteredElementCollector.GetElementIterator方法代码示例

本文整理汇总了C#中FilteredElementCollector.GetElementIterator方法的典型用法代码示例。如果您正苦于以下问题:C# FilteredElementCollector.GetElementIterator方法的具体用法?C# FilteredElementCollector.GetElementIterator怎么用?C# FilteredElementCollector.GetElementIterator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FilteredElementCollector的用法示例。


在下文中一共展示了FilteredElementCollector.GetElementIterator方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitializeTreeView

        InitializeTreeView ()
        {

            FilteredElementCollector coll = new FilteredElementCollector(m_app.ActiveUIDocument.Document);
            coll.WherePasses(new LogicalOrFilter(new ElementIsElementTypeFilter(false), new ElementIsElementTypeFilter(true)));

            FilteredElementIterator elemIter = coll.GetElementIterator();
            //ElementIterator elemIter = m_app.ActiveUIDocument.Document.Elements;
            ArrayList elemTypes = new ArrayList();

            /// collect all unique elem types
            while (elemIter.MoveNext()) {

                /// if this elem type is already accounted for, ignore it
                if (elemTypes.Contains(elemIter.Current.GetType()))
                    continue;
                else {
                    elemTypes.Add(elemIter.Current.GetType());
                }
            }

            /// populate tree with elem types
            foreach (Type type in elemTypes) {
                TreeNode treeNode = new TreeNode(type.Name);
                treeNode.Tag = type;
                m_treeView.Nodes.Add(treeNode);
            }

            /// sort the tree
            m_treeView.TreeViewNodeSorter = new TreeSorter();
            m_treeView.Sort();
        }
开发者ID:15921050052,项目名称:RevitLookup,代码行数:32,代码来源:Elements.cs

示例2: Ungroup

        public void Ungroup(Document doc, UIDocument uidoc)
        {
            IList<Category> categoryToDelete = new List<Category>();
            List<Group> ungroupList = new List<Group>();

            //Finds the groups in the project
            FilteredElementCollector collector = new FilteredElementCollector(uidoc.Document).OfClass(typeof(Group));
            FilteredElementIterator itr = collector.GetElementIterator();

            //Gets the dictionary to lookup line
            getLines getlines = new getLines(path);
            var dictionary = getlines.DictionaryLines();

            //iterators over all the groups
            while (itr.MoveNext())
            {
                Element element = (Element)itr.Current;
                Group group = doc.GetElement(element.Id) as Group;
                List<ElementId> groupElements = group.GetMemberIds().ToList();

                foreach (ElementId lineStyle in groupElements)
                {
                    Element elements = doc.GetElement(lineStyle);
                    CurveElement curveElement = elements as CurveElement;
                    try
                    {
                        string lineStyleName = curveElement.LineStyle.Name;
                        if (lineStyleName != null)
                        {
                            //compare lines to dictionary to ungroup.
                            if (dictionary.ContainsKey(lineStyleName))
                            {
                                ungroupList.Add(group);
                            }
                        }
                    }
                    catch { }
                }
            }

            foreach (Group group in ungroupList)
            {
                try
                {
                    ungroup(doc, group);
                    //CreateGroup(doc, uidoc);
                }
                catch { }
            }
        }
开发者ID:dannysbentley,项目名称:Delete-Change-Line-Styles,代码行数:50,代码来源:groups.cs

示例3: CreateGroup

        //TODO figure out how to regroup.
        public void CreateGroup(Document doc, UIDocument uidoc)
        {
            Transaction tx = new Transaction(doc);

            tx.Start("Group");

            Group grpNew = doc.Create.NewGroup(_newgrpElements);

            FilteredElementCollector collector = new FilteredElementCollector(doc).OfClass(typeof(GroupType));
            FilteredElementIterator itr = collector.GetElementIterator();

            _gp = grpNew.GroupType;
            while (itr.MoveNext())
            {

                GroupType groupType = (GroupType)itr.Current;
                //groupType = _gp;
            }

            tx.Commit();
        }
开发者ID:dannysbentley,项目名称:Delete-Change-Line-Styles,代码行数:22,代码来源:groups.cs

示例4: FindFamilyType_Door_v2

    /// <summary>
    /// Find a specific family type for a door. 
    /// another approach will be to look up from Family, then from Family.Symbols property. 
    /// This gets more complicated although it is logical approach. 
    /// </summary>
    public Element FindFamilyType_Door_v2(string doorFamilyName, string doorTypeName)
    {
      // (1) find the family with the given name. 

      var familyCollector = new FilteredElementCollector(_doc);
      familyCollector.OfClass(typeof(Family));

      // Use the iterator 
      Family doorFamily = null;
      FilteredElementIterator familyItr = familyCollector.GetElementIterator();
      //familyItr.Reset(); 
      while ((familyItr.MoveNext()))
      {
        Family fam = (Family)familyItr.Current;
        // Check name and categoty 
        if ((fam.Name == doorFamilyName) & (fam.FamilyCategory.Id.IntegerValue == (int)BuiltInCategory.OST_Doors))
        {
          // We found the family. 
          doorFamily = fam;
          break;
        }
      }

      // (2) Find the type with the given name. 

      Element doorType2 = null;
      // Id of door type we are looking for. 
      if (doorFamily != null)
      {
        // If we have a family, then proceed with finding a type under Symbols property. 

        //FamilySymbolSet doorFamilySymbolSet = doorFamily.Symbols;       // 'Autodesk.Revit.DB.Family.Symbols' is obsolete: 
        // 'This property is obsolete in Revit 2015.  Use Family.GetFamilySymbolIds() instead.'

        // Iterate through the set of family symbols. 
        //FamilySymbolSetIterator doorTypeItr = doorFamilySymbolSet.ForwardIterator();
        //while (doorTypeItr.MoveNext())
        //{
        //  FamilySymbol dType = (FamilySymbol)doorTypeItr.Current;
        //  if ((dType.Name == doorTypeName))
        //  {
        //    doorType2 = dType;  // Found it. 
        //    break;
        //  }
        //}

        /// Following part is modified code for Revit 2015

        ISet<ElementId> familySymbolIds = doorFamily.GetFamilySymbolIds();

        if (familySymbolIds.Count > 0)
        {
          // Get family symbols which is contained in this family
          foreach (ElementId id in familySymbolIds)
          {
            FamilySymbol dType = doorFamily.Document.GetElement(id) as FamilySymbol;
            if ((dType.Name == doorTypeName))
            {
              doorType2 = dType;  // Found it. 
              break;
            }
          }
        }

        /// End of modified code for Revit 2015          

      }
      return doorType2;
    }
开发者ID:vnoves,项目名称:RevitTrainingMaterial,代码行数:74,代码来源:3_ElementFiltering.cs

示例5: FindFamilyType_Wall_v2

    /// <summary>
    /// Find a specific family type for a wall, which is a system family. 
    /// This version uses iteration. (cf. look for example, Developer guide 87) 
    /// </summary>
    public Element FindFamilyType_Wall_v2(string wallFamilyName, string wallTypeName)
    {
      // First, narrow down the collector by Class 
      var wallTypeCollector2 = new FilteredElementCollector(_doc).OfClass(typeof(WallType));

      // Use iterator 
      FilteredElementIterator wallTypeItr = wallTypeCollector2.GetElementIterator();
      wallTypeItr.Reset();
      Element wallType2 = null;
      while (wallTypeItr.MoveNext())
      {
        WallType wType = (WallType)wallTypeItr.Current;
        // We check two names for the match: type name and family name. 
        if ((wType.Name == wallTypeName) & (wType.get_Parameter(BuiltInParameter.SYMBOL_FAMILY_NAME_PARAM).AsString().Equals(wallFamilyName)))
        {
          wallType2 = wType; // We found it. 
          break;
        }
      }

      return wallType2;
    }
开发者ID:vnoves,项目名称:RevitTrainingMaterial,代码行数:26,代码来源:3_ElementFiltering.cs

示例6: ScanCategories

        /// <summary>
        /// Scans all elements in the active document and creates a list of
        /// the categories of those elements.
        /// </summary>
        /// <returns>Sorted dictionary of categories.</returns>
        public SortedDictionary<string, Category> ScanCategories()
        {
            m_Categories = new SortedDictionary<string, Category>();

            // get all elements in the active document
            FilteredElementCollector filterCollector = new FilteredElementCollector(m_ActiveDocument);

            filterCollector.WhereElementIsNotElementType();

            FilteredElementIterator iterator = filterCollector.GetElementIterator();

            // create sorted dictionary of the categories of the elements
            while (iterator.MoveNext())
            {
                Element element = iterator.Current;

                if (element.Category != null)
                {
                    if (!m_Categories.ContainsKey(element.Category.Name))
                    {
                        m_Categories.Add(element.Category.Name, element.Category);
                    }
                }
            }

            return m_Categories;
        }
开发者ID:redscorpion201,项目名称:STLExporterForRevit,代码行数:32,代码来源:DataGenerator.cs

示例7: Execute

        public Autodesk.Revit.UI.Result Execute(Autodesk.Revit.UI.ExternalCommandData cmdData, ref string msg, ElementSet elems)
        {
            Autodesk.Revit.UI.Result result;

               try
               {
               Snoop.CollectorExts.CollectorExt.m_app = cmdData.Application;
               Snoop.CollectorExts.CollectorExt.m_activeDoc = cmdData.Application.ActiveUIDocument.Document;   // TBD: see note in CollectorExt.cs

               UIDocument revitDoc = cmdData.Application.ActiveUIDocument;
               Autodesk.Revit.DB.View view = revitDoc.Document.ActiveView;
               ElementSet ss = cmdData.Application.ActiveUIDocument.Selection.Elements;

               if (ss.Size == 0)
               {
                   FilteredElementCollector collector = new FilteredElementCollector(revitDoc.Document, view.Id);
                   collector.WhereElementIsNotElementType();
                   FilteredElementIterator i = collector.GetElementIterator();
                   i.Reset();
                   ElementSet ss1 = cmdData.Application.Application.Create.NewElementSet();
                   while (i.MoveNext())
                   {
                       Element e = i.Current as Element;
                       ss1.Insert(e);
                   }
                   ss = ss1;
               }

               Snoop.Forms.Objects form = new Snoop.Forms.Objects(ss);
               ActiveDoc.UIApp = cmdData.Application;
               form.ShowDialog();

               result = Autodesk.Revit.UI.Result.Succeeded;
               }
               catch (System.Exception e)
               {
               msg = e.Message;
               result = Autodesk.Revit.UI.Result.Failed;
               }

               return result;
        }
开发者ID:halad,项目名称:RevitLookup,代码行数:42,代码来源:TestCmds.cs


注:本文中的FilteredElementCollector.GetElementIterator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。