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


C# ElementClassFilter类代码示例

本文整理汇总了C#中ElementClassFilter的典型用法代码示例。如果您正苦于以下问题:C# ElementClassFilter类的具体用法?C# ElementClassFilter怎么用?C# ElementClassFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ElementClassFilter类属于命名空间,在下文中一共展示了ElementClassFilter类的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: OnStartup

        public Result OnStartup(UIControlledApplication a)
        {
            //Create Ribbon Panel add the UI button on start up
            RibbonPanel alignViewsPanel = ribbonPanel(a);

            //Register location updater with Revit.
            LocationUpdater updater = new LocationUpdater(a.ActiveAddInId);
            UpdaterRegistry.RegisterUpdater(updater, true);

            ElementCategoryFilter viewPortFilter = new ElementCategoryFilter(BuiltInCategory.OST_Viewports);
            ElementCategoryFilter viewFilter = new ElementCategoryFilter(BuiltInCategory.OST_Views);
            LogicalOrFilter filter = new LogicalOrFilter(viewPortFilter, viewFilter);

            //Parameter to send to the trigger.
            ElementClassFilter viewPort = new ElementClassFilter(typeof(Viewport));
            ElementId viewPortNumberId = new ElementId(BuiltInParameter.VIEWPORT_DETAIL_NUMBER);

            //Set trigger
            UpdaterRegistry.AddTrigger(updater.GetUpdaterId(), viewPort, Element.GetChangeTypeParameter(viewPortNumberId));
            UpdaterRegistry.AddTrigger(updater.GetUpdaterId(), filter, Element.GetChangeTypeElementAddition());

            //add buttons to ribbon
            addVRCommandButtons(alignViewsPanel);
            pushButton_Setting(alignViewsPanel);

            return Result.Succeeded;
        }
开发者ID:dannysbentley,项目名称:alignviewtosheetcell,代码行数:27,代码来源:App.cs

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

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

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

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

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

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

示例10: FilterToCategory

        /// <summary>
        /// Given an Enumerable set of Elements, walk through them and filter out the ones of a specific 
        /// category.
        /// </summary>
        /// <param name="filterForCategoryEnum">The BuiltInCategory enum to filter for</param>
        /// <param name="doc">The current Document object</param>
        /// <returns>The filtered ElementSet</returns>
        public static ElementSet FilterToCategory(BuiltInCategory filterForCategoryEnum, bool includeSymbols, Document doc)
        {
            ElementSet elemSet = new ElementSet();
               FilteredElementCollector fec = new FilteredElementCollector(doc);
               ElementClassFilter elementsAreWanted = new ElementClassFilter(typeof(Element));
               fec.WherePasses(elementsAreWanted);
               List<Element> elements = fec.ToElements() as List<Element>;

               foreach (Element element in elements)
               {
              elemSet.Insert(element);
               }

            return FilterToCategory(elemSet, filterForCategoryEnum, includeSymbols, doc);
        }
开发者ID:halad,项目名称:RevitLookup,代码行数:22,代码来源:Selection.cs

示例11: OfFamilyType

        public static IList<Element> OfFamilyType(FamilySymbol familyType)
        {
            var instanceFilter = new ElementClassFilter(typeof(Autodesk.Revit.DB.FamilyInstance));
            var fec = new FilteredElementCollector(DocumentManager.Instance.CurrentDBDocument);

            var familyInstances = fec.WherePasses(instanceFilter)
                .WhereElementIsNotElementType()
                .ToElements()
                .Cast<Autodesk.Revit.DB.FamilyInstance>()
                .Where(x => x.Symbol.IsSimilarType(familyType.InternalFamilySymbol.Id));

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

示例12: CollectWindows

        /// <summary>
        /// Finds all windows in the active document.
        /// </summary>
        /// <returns>An enumerable containing all windows.</returns>
        protected IEnumerable<FamilyInstance> CollectWindows()
        {
            // Windows are family instances whose category is correctly set.

            ElementClassFilter familyInstanceFilter = new ElementClassFilter(typeof(FamilyInstance));
            ElementCategoryFilter windowCategoryFilter = new ElementCategoryFilter(BuiltInCategory.OST_Windows);
            LogicalAndFilter andFilter = new LogicalAndFilter(familyInstanceFilter, windowCategoryFilter);
            FilteredElementCollector collector = new FilteredElementCollector(Document);
               ICollection<Element> elementsToProcess = collector.WherePasses(andFilter).ToElements();

            // Convert to IEnumerable of FamilyInstance using LINQ
            IEnumerable<FamilyInstance> windows = from window in elementsToProcess.Cast<FamilyInstance>() select window;

            return windows;
        }
开发者ID:AMEE,项目名称:revit,代码行数:19,代码来源:FindSouthFacingWindows.cs

示例13: 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 one sheet view to place panel schedule.
            ViewSheet sheet = doc.ActiveView as ViewSheet;
            if (null == sheet)
            {
                message = "please go to a sheet view.";
                return Result.Failed;
            }

            // 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>;

            Transaction placePanelScheduleOnSheet = new Transaction(doc, "placePanelScheduleOnSheet");
            placePanelScheduleOnSheet.Start();

            XYZ nextOrigin = new XYZ(0.0, 0.0, 0.0);
            foreach (Element element in psViews)
            {
                PanelScheduleView psView = element as PanelScheduleView;
                if (psView.IsPanelScheduleTemplate())
                {
                    // ignore the PanelScheduleView instance which is a template.
                    continue;
                }

                PanelScheduleSheetInstance onSheet = PanelScheduleSheetInstance.Create(doc, psView.Id, sheet);
                onSheet.Origin = nextOrigin;
                BoundingBoxXYZ bbox = onSheet.get_BoundingBox(doc.ActiveView);
                double width = bbox.Max.X - bbox.Min.X;
                nextOrigin = new XYZ(onSheet.Origin.X + width, onSheet.Origin.Y, onSheet.Origin.Z);
            }

            placePanelScheduleOnSheet.Commit();

            return Result.Succeeded;

        }
开发者ID:jamiefarrell,项目名称:Panel-Schedules-to-Excel,代码行数:60,代码来源:SheetImport.cs

示例14: OnStartup

        public Result OnStartup(UIControlledApplication a)
        {
            DeletionUpdater deletionUpdater
              = new DeletionUpdater(a.ActiveAddInId);

            UpdaterRegistry.RegisterUpdater(
              deletionUpdater);

            ElementClassFilter filter
              = new ElementClassFilter(
                typeof(Dimension), true);

            UpdaterRegistry.AddTrigger(
              deletionUpdater.GetUpdaterId(), filter,
              Element.GetChangeTypeElementDeletion());

            //FailureDefinitionRegistry

            return Result.Succeeded;
        }
开发者ID:mjkkirschner,项目名称:GrimshawTools,代码行数:20,代码来源:App.cs

示例15: InitializeListView

        /// <summary>
        /// populate with levels
        /// </summary>
        private void InitializeListView()
        {
            FilteredElementCollector fec = new FilteredElementCollector(m_app.ActiveUIDocument.Document);
               ElementClassFilter levelsAreWanted = new ElementClassFilter(typeof(Level));
               fec.WherePasses(levelsAreWanted);
               List<Element> elements = fec.ToElements() as List<Element>;

               foreach (Element element in elements)
               {
              Autodesk.Revit.DB.Level sysLevel = element as Autodesk.Revit.DB.Level;
              if (sysLevel != null)
              {
                 ListViewItem lev = new ListViewItem(sysLevel.Name);
                 lev.SubItems.Add(sysLevel.Elevation.ToString());
                 lev.Tag = sysLevel;

                 m_levlv.Items.Add(lev);
              }
               }
        }
开发者ID:jeremytammik,项目名称:RevitLookup,代码行数:23,代码来源:Levels.cs


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