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


C# FilteredElementCollector.WherePasses方法代码示例

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


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

示例1: GetAllViews

        /// <summary>
        /// Finds all the views in the active document.
        /// </summary>
        /// <param name="doc">the active document</param>
        public static ViewSet GetAllViews (Document doc)
        {
            ViewSet allViews = new ViewSet();

            FilteredElementCollector fec = new FilteredElementCollector(doc);
            ElementClassFilter elementsAreWanted = new ElementClassFilter(typeof(FloorType));
            fec.WherePasses(elementsAreWanted);
            List<Element> elements = fec.ToElements() as List<Element>;

            foreach (Element element in elements)
            {
               Autodesk.Revit.DB.View view = element as Autodesk.Revit.DB.View;

               if (null == view)
               {
                  continue;
               }
               else
               {
                  
                  ElementType objType = doc.GetElement(view.GetTypeId()) as ElementType;
                  if (null == objType || objType.Name.Equals("Drawing Sheet"))
                  {
                     continue;
                  }
                  else
                  {
                     allViews.Insert(view);
                  }
               }
            }

            return allViews;
        }
开发者ID:15921050052,项目名称:RevitLookup,代码行数:38,代码来源:View.cs

示例2: GetAllSheets

        /// <summary>
        /// Gather up all the available sheets.
        /// </summary>
        /// <param name="doc"></param>
        /// <param name="sheet"></param>
        /// <returns></returns>
        public static ElementSet GetAllSheets(Document doc)
        {
            ElementSet allSheets = new ElementSet();
            FilteredElementCollector fec = new FilteredElementCollector(doc);
            ElementClassFilter elementsAreWanted = new ElementClassFilter(typeof(ViewSheet));
            fec.WherePasses(elementsAreWanted);
            List<Element> elements = fec.ToElements() as List<Element>;

            foreach (Element element in elements)
            {
               ViewSheet viewSheet = element as ViewSheet;

               if (null == viewSheet)
               {
                  continue;
               }
               else
               {
                  ElementId objId = viewSheet.GetTypeId();
                  if (ElementId.InvalidElementId == objId)
                  {
                     continue;
                  }
                  else
                  {
                     allSheets.Insert(viewSheet);
                  }
               }
            }

            return allSheets;
        }
开发者ID:halad,项目名称:RevitLookup,代码行数:38,代码来源:View.cs

示例3: Execute

        /// <summary>
        /// Adds 1 to the mark of every column in the document
        /// </summary>
        /// <param name="commandData">the revit command data</param>
        /// <param name="message">a message to return</param>
        /// <param name="elements">Elements to display in a failed message dialog</param>
        /// <returns>Suceeded, Failed or Cancelled</returns>
        public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            //we want the 'database' document, which represents the Revit Model itself.
            Document dbDoc = commandData.Application.ActiveUIDocument.Document;

            //Use a FilteredElementCollector to get all the columns in the model.
            FilteredElementCollector collector = new FilteredElementCollector(dbDoc);

            //for this, we use a Category Filter which finds all elements in the Column category
            ElementCategoryFilter columnFilter = new ElementCategoryFilter(BuiltInCategory.OST_Columns);

            //structural columns have a different category
            ElementCategoryFilter structuralColumnFilter =new ElementCategoryFilter(BuiltInCategory.OST_StructuralColumns);

            //to get elements that match either of these categories, we us a logical 'Or' filter.
            LogicalOrFilter orFilter = new LogicalOrFilter(columnFilter, structuralColumnFilter);

            //you can then get these elements as a list.
            //we also specify WhereElementIsNotElementType() so that we don't get FamilySymbols
            IList<Element> allColumns = collector.WherePasses(orFilter).WhereElementIsNotElementType().ToElements();

            string results = "Updated Marks For : " + Environment.NewLine;
            //loop through this list and update the mark
            foreach (Element element in allColumns)
            {
                UpdateMark(element);
                results += element.Id + Environment.NewLine;
            }

            TaskDialog.Show("Updated Elements", results);
            return Result.Succeeded;
        }
开发者ID:RodH257,项目名称:IntroToRevitSamples,代码行数:39,代码来源:ModifyingParameters.cs

示例4: Execute

        public Result Execute(
            ExternalCommandData commandData,
            ref string message,
            ElementSet elements)
        {
            UIApplication app = commandData.Application;
              m_doc = app.ActiveUIDocument.Document;

              // filter for family instance and (door or window):

              ElementClassFilter fFamInstClass = new ElementClassFilter( typeof( FamilyInstance ) );
              ElementCategoryFilter fDoorCat = new ElementCategoryFilter( BuiltInCategory.OST_Doors );
              ElementCategoryFilter fWindowCat = new ElementCategoryFilter( BuiltInCategory.OST_Windows );
              LogicalOrFilter fCat = new LogicalOrFilter( fDoorCat, fWindowCat );
              LogicalAndFilter f = new LogicalAndFilter( fCat, fFamInstClass );
              FilteredElementCollector openings = new FilteredElementCollector( m_doc );
              openings.WherePasses( f );

              // map with key = host element id and
              // value = list of hosted element ids:

              Dictionary<ElementId, List<ElementId>> ids =
            GetElementIds( openings );

              DumpHostedElements( ids );
              m_doc = null;

              return Result.Succeeded;
        }
开发者ID:nbright,项目名称:the_building_coder_samples,代码行数:29,代码来源:CmdRelationshipInverter.cs

示例5: LinePatternViewer

        public void LinePatternViewer()
        {
            LPMainWindow main_win = null;
            try
            {
                Document theDoc = this.ActiveUIDocument.Document;
                System.Collections.ObjectModel.ObservableCollection<LinePattern> data =
                    new System.Collections.ObjectModel.ObservableCollection<LinePattern>();

                //Collect all line pattern elements
                FilteredElementCollector collector = new FilteredElementCollector(theDoc);
                IList<Element> linepatternelements = collector.WherePasses(new ElementClassFilter(typeof(LinePatternElement))).ToElements();
                foreach (LinePatternElement lpe in linepatternelements)
                {
                    data.Add(lpe.GetLinePattern());
                }
                //start main window
                main_win = new LinePatternMacro.LPMainWindow(data);
                System.Windows.Interop.WindowInteropHelper x = new System.Windows.Interop.WindowInteropHelper(main_win);
                x.Owner = Process.GetCurrentProcess().MainWindowHandle;
                main_win.ShowDialog();
            }
            catch (Exception err)
            {
                Debug.WriteLine(new string('*', 100));
                Debug.WriteLine(err.ToString());
                Debug.WriteLine(new string('*', 100));
                if (main_win != null && main_win.IsActive)
                    main_win.Close();
            }
        }
开发者ID:kfpopeye,项目名称:LinePatternViewerWpfControl,代码行数:31,代码来源:macro.cs

示例6: Execute

        Execute ()
        {
            //Get every level by iterating through all elements
            systemLevelsData = new List<LevelsDataSource>();

            FilteredElementCollector fec = new FilteredElementCollector(m_app.ActiveUIDocument.Document);
            ElementClassFilter elementsAreWanted = new ElementClassFilter(typeof(Level));
            fec.WherePasses(elementsAreWanted);
            List<Element> elements = fec.ToElements() as List<Element>;

            foreach (Element element in elements)
            {
               Level systemLevel = element as Level;
               if (systemLevel != null)
               {
                  LevelsDataSource levelsDataSourceRow = new LevelsDataSource();

                  levelsDataSourceRow.LevelIDValue = systemLevel.Id.IntegerValue;
                  levelsDataSourceRow.Name = systemLevel.Name;

                  levelsDataSourceRow.Elevation = systemLevel.Elevation;

                  systemLevelsData.Add(levelsDataSourceRow);
               }
            }

            LevelsForm displayForm = new LevelsForm(this);
            displayForm.ShowDialog();

            return true;
        }
开发者ID:15921050052,项目名称:RevitLookup,代码行数:31,代码来源:LevelsCommand.cs

示例7: 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

示例8: application_DocumentOpened

        public void application_DocumentOpened(object sender, DocumentOpenedEventArgs args)
        {
            Document doc = args.Document;
            //add new parameter when a document opens
            Transaction transaction = new Transaction(doc, "Add PhaseGraphics");
            if (transaction.Start() == TransactionStatus.Started)
            {
                var fileName = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"Autodesk\Revit\Addins\2012\PhaseSyncSharedParams.txt");
                SetNewParameterToInstances(doc, fileName.ToString());
                transaction.Commit();
            }
            //sync phasegraphics param with Phases of all empty PhaseGraphics objects
            Transaction transaction2 = new Transaction(doc, "Sync PhaseGraphics");
            ICollection<Element> types = null;
            if (transaction2.Start() == TransactionStatus.Started)
            {

                  // Apply the filter to the elements in the active document
                FilteredElementCollector collector = new FilteredElementCollector(doc);
                types = collector.WherePasses(PhaseGraphicsTypeFilter()).ToElements();
                foreach (Element elem in types)

                {
                    //get the phasegraphics parameter from its guid
                    if (elem.get_Parameter(new Guid(PhaseGraphicsGUID)).HasValue == false)
                    {
                        SyncPhaseGraphics(doc, elem);
                    }

                }
                transaction2.Commit();
            }
        }
开发者ID:Tadwork,项目名称:PhaseGraphicsAddin,代码行数:33,代码来源:App.cs

示例9: ExtractObjects

 private static void ExtractObjects()
 {
     ElementFilter ductFilter = new ElementCategoryFilter(BuiltInCategory.OST_DuctCurves);
     ElementFilter faminsFilter = new ElementClassFilter(typeof(MEPCurve));
     FilteredElementCollector ductCollector = new FilteredElementCollector(_doc);
     ductCollector.WherePasses(ductFilter).WherePasses(faminsFilter);
     foreach (MEPCurve duct in ductCollector) _ducts.Add(duct);
 }
开发者ID:Xiang-Zeng,项目名称:P58_Loss,代码行数:8,代码来源:PDuct.cs

示例10: ExtractObjects

        private static void ExtractObjects()
        {
            List<ElementId> materials = null;
            Material material = null;
            ElementFilter WallFilter = new ElementCategoryFilter(BuiltInCategory.OST_Walls);
            ElementFilter NonStruWallFilter = new StructuralWallUsageFilter(StructuralWallUsage.NonBearing);
            ElementFilter WallClassFilter = new ElementClassFilter(typeof(Wall));
            FilteredElementCollector GypWalls = new FilteredElementCollector(_doc);
            GypWalls.WherePasses(WallFilter).WherePasses(NonStruWallFilter);
            int[] count1 = new int[2];              //0:Gyp, 1:wallpaper, 2:ceramic
            foreach (Wall wall in GypWalls)
            {
                materials = wall.GetMaterialIds(false).ToList();

                foreach (ElementId eleId in materials)
                {
                    material = _doc.GetElement(eleId) as Material;
                    if (material.MaterialCategory == _addiInfo.materialTypes[(byte)PGMaterialType.Gypsum]) ++count1[0];
                    else if (material.MaterialCategory == _addiInfo.materialTypes[(byte)PGMaterialType.WallPaper]) ++count1[1];
                    else if (material.MaterialCategory == _addiInfo.materialTypes[(byte)PGMaterialType.Ceramic]) ++count1[2];
                }
                //assert: count1[i] is non-negative
                if (count1[0] == 0) continue;
                if (count1[1] == 0 && count1[2] == 0) _GypWalls.Add(new RichWall(wall,FinishType.None));
                else if(count1[2] == 0)             //assert: count1[1] != 0
                {
                    if (count1[1] == 1) _GypWalls.Add(new RichWall(wall,FinishType.OneWallpaper));
                    else if (count1[1] == 2) _GypWalls.Add(new RichWall(wall,FinishType.TwoWallpaper));
                }
                else if(count1[1] == 0)             //assert: count1[2] != 0
                {
                    if (count1[2] == 1) _GypWalls.Add(new RichWall(wall,FinishType.OneCeramic));
                    else if (count1[2] == 2) _GypWalls.Add(new RichWall(wall,FinishType.TwoCeramic));
                }
                else _abandonWriter.WriteAbandonment(wall, AbandonmentTable.TooManyFinishes);
            }

            if (_addiInfo.requiredComp[(byte)PGComponents.WallFinish])
            {
                int count2 = 0;
                FilteredElementCollector GeneticWalls = new FilteredElementCollector(_doc);
                GeneticWalls.WherePasses(WallFilter).WherePasses(WallClassFilter);
                foreach (Wall wall in GeneticWalls)
                {
                    materials = wall.GetMaterialIds(false).ToList();
                    foreach (ElementId eleId in materials)
                    {
                        material = _doc.GetElement(eleId) as Material;
                        if (material.MaterialCategory == _addiInfo.materialTypes[(byte)PGMaterialType.Wood]
                        || material.MaterialCategory == _addiInfo.materialTypes[(byte)PGMaterialType.Marble]) ++count2;
                    }
                    if (count2 == 1) _GeneticWalls.Add(new RichWall(wall,FinishType.OneWood));
                    else if (count2 == 2) _GeneticWalls.Add(new RichWall(wall,FinishType.TwoWood));
                    else if (2 <= count2) _abandonWriter.WriteAbandonment(wall, AbandonmentTable.TooManyFinishes);
                }
            }
        }
开发者ID:Xiang-Zeng,项目名称:P58_Loss,代码行数:57,代码来源:PGypWall.cs

示例11: OfElementType

        public static IList<Element> OfElementType(Type elementType)
        {
            var elFilter = new ElementClassFilter(elementType);
            var fec = new FilteredElementCollector(DocumentManager.Instance.CurrentDBDocument);
            fec.WherePasses(elFilter);

            var instances = fec.ToElements()
                .Select(x => ElementSelector.ByElementId(x.Id.IntegerValue)).ToList();
            return instances;
        }
开发者ID:algobasket,项目名称:Dynamo,代码行数:10,代码来源:ElementQueries.cs

示例12: Execute

        /// <summary>
        /// Implement this method as an external command for Revit.
        /// </summary>
        /// <param name="commandData">An object that is passed to the external application 
        /// which contains data related to the command, 
        /// such as the application object and active view.</param>
        /// <param name="message">A message that can be set by the external application 
        /// which will be displayed if a failure or cancellation is returned by 
        /// the external command.</param>
        /// <param name="elements">A set of elements to which the external application 
        /// can add elements that are to be highlighted in case of failure or cancellation.</param>
        /// <returns>Return the status of the external command. 
        /// A result of Succeeded means that the API external method functioned as expected. 
        /// Cancelled can be used to signify that the user cancelled the external operation 
        /// at some point. Failure should be returned if the application is unable to proceed with 
        /// the operation.</returns>
        public virtual Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData
            , ref string message, Autodesk.Revit.DB.ElementSet elements)
        {
            Autodesk.Revit.DB.Document doc = commandData.Application.ActiveUIDocument.Document;

            // get all PanelScheduleView instances in the Revit document.
            FilteredElementCollector fec = new FilteredElementCollector(doc);
            ElementClassFilter PanelScheduleViewsAreWanted = new ElementClassFilter(typeof(PanelScheduleView));
            fec.WherePasses(PanelScheduleViewsAreWanted);
            List<Element> psViews = fec.ToElements() as List<Element>;

            bool noPanelScheduleInstance = true;

            foreach (Element element in psViews)
            {
                PanelScheduleView psView = element as PanelScheduleView;
                if (psView.IsPanelScheduleTemplate())
                {
                    // ignore the PanelScheduleView instance which is a template.
                    continue;
                }
                else
                {
                    noPanelScheduleInstance = false;
                }

                // choose what format export to, it can be CSV or HTML.
                TaskDialog alternativeDlg = new TaskDialog("Choose Format to export");
                alternativeDlg.MainContent = "Click OK to export in .CSV format, Cancel to export in HTML format.";
                alternativeDlg.CommonButtons = TaskDialogCommonButtons.Ok | TaskDialogCommonButtons.Cancel;
                alternativeDlg.AllowCancellation = true;
                TaskDialogResult exportToCSV = alternativeDlg.Show();
                
                Translator translator = TaskDialogResult.Cancel == exportToCSV ? new HTMLTranslator(psView) : new CSVTranslator(psView) as Translator;
                string exported = translator.Export();

                // open the file if export successfully.
                if (!string.IsNullOrEmpty(exported))
                {
                    System.Diagnostics.Process.Start(exported);
                }
            }

            if (noPanelScheduleInstance)
            {
                TaskDialog messageDlg = new TaskDialog("Warnning Message");
                messageDlg.MainIcon = TaskDialogIcon.TaskDialogIconWarning;
                messageDlg.MainContent = "No panel schedule view is in the current document.";
                messageDlg.Show();
                return Result.Cancelled;
            }

            return Result.Succeeded;
        }
开发者ID:jamiefarrell,项目名称:Panel-Schedules-to-Excel,代码行数:70,代码来源:PanelScheduleExport.cs

示例13: OfCategory

 public static IList<Element> OfCategory(Category category)
 {
     var catFilter = new ElementCategoryFilter(category.InternalCategory.Id);
     var fec = new FilteredElementCollector(DocumentManager.Instance.CurrentDBDocument);
     var instances = 
         fec.WherePasses(catFilter)
             .WhereElementIsNotElementType()
             .ToElementIds()
             .Select(id => ElementSelector.ByElementId(id.IntegerValue))
             .ToList();
     return instances;
 }
开发者ID:algobasket,项目名称:Dynamo,代码行数:12,代码来源:ElementQueries.cs

示例14: AtLevel

 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;
 }
开发者ID:algobasket,项目名称:Dynamo,代码行数:12,代码来源:ElementQueries.cs

示例15: DFS

        private static int DFS(IList<ElementId> columnIds, IList<ElementId> beamIds, out int num_IndividualColumn)
        {
            num_IndividualColumn = 0;
            List<Element> columns = (new FilteredElementCollector(_doc, columnIds)).OfClass(typeof(FamilyInstance)).ToList();
            List<Element> beams = (new FilteredElementCollector(_doc, beamIds)).OfClass(typeof(FamilyInstance)).ToList();
            int k = 0;
            LinkedList<Element> open = new LinkedList<Element>();
            HashSet<ElementId> discovered = new HashSet<ElementId>();
            foreach(Element column in columns)
            {
                if (!discovered.Contains(column.Id))
                {
                    ++k;
                    open.AddFirst(column);
                    discovered.Add(column.Id);
                    while (open.Count != 0)
                    {
                        Element e = open.First();
                        open.RemoveFirst();
                        BoundingBoxXYZ bbXYZ = e.get_BoundingBox(_doc.ActiveView);
                        XYZ deltaXYZ = new XYZ(ErrorCTRL_BB, ErrorCTRL_BB, _maxBB.Max.Z);
                        BoundingBoxIntersectsFilter bbFilter = new BoundingBoxIntersectsFilter(new Outline(bbXYZ.Min - deltaXYZ, bbXYZ.Max + deltaXYZ));
                        FilteredElementCollector fec = null;
                        if (((FamilyInstance)e).StructuralUsage == StructuralInstanceUsage.Column)
                        {
                            fec = new FilteredElementCollector(_doc, beamIds);
                            fec.WherePasses(bbFilter);
                            if (fec.Count() == 0)
                            {
                                ++num_IndividualColumn;
                                --k;
                            }
                        }
                        else
                        {
                            fec = new FilteredElementCollector(_doc, columnIds);
                            fec.WherePasses(bbFilter);
                        }

                        foreach (Element intersectedEle in fec)
                        {
                            if (!discovered.Contains(intersectedEle.Id))
                            {
                                open.AddFirst(intersectedEle);
                                discovered.Add(intersectedEle.Id);
                            }
                        }
                    }
                }
            }
            return k;
        }
开发者ID:Xiang-Zeng,项目名称:P58_Loss,代码行数:52,代码来源:PBracedFrame.cs


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