• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# ElementClassFilter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



ElementClassFilter类属于命名空间,在下文中一共展示了ElementClassFilter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: OnStartup

        public Result OnStartup(UIControlledApplication application)
        {
            AddRibbonPanel(application);

            // Failure Definition Registry
            // Implemented in Prevent Deletion Tool
            PreventDeletionUpdater deletionUpdater
              = new PreventDeletionUpdater(application.ActiveAddInId);

            UpdaterRegistry.RegisterUpdater(
              deletionUpdater);

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

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

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


示例17: docOpen

        private void docOpen(object sender, DocumentOpenedEventArgs e)
        {
            Autodesk.Revit.ApplicationServices.Application app = sender as Autodesk.Revit.ApplicationServices.Application;
             UIApplication uiApp = new UIApplication(app);
             Document doc = uiApp.ActiveUIDocument.Document;

             FilteredElementCollector collector = new FilteredElementCollector(doc);
             collector.WherePasses(new ElementClassFilter(typeof(FamilyInstance)));
             var sphereElements = from element in collector where element.Name == "sphere" select element;
             if (sphereElements.Count() == 0)
             {
            TaskDialog.Show("Error", "Sphere family must be loaded");
            return;
             }
             FamilyInstance sphere = sphereElements.Cast<FamilyInstance>().First<FamilyInstance>();
             FilteredElementCollector viewCollector = new FilteredElementCollector(doc);
             ICollection<Element> views = viewCollector.OfClass(typeof(View3D)).ToElements();
             var viewElements = from element in viewCollector where element.Name == "AVF" select element;
             if (viewElements.Count() == 0)
             {
            TaskDialog.Show("Error", "A 3D view named 'AVF' must exist to run this application.");
            return;
             }
             View view = viewElements.Cast<View>().First<View>();

             SpatialFieldUpdater updater = new SpatialFieldUpdater(uiApp.ActiveAddInId, sphere.Id, view.Id);
             if (!UpdaterRegistry.IsUpdaterRegistered(updater.GetUpdaterId())) UpdaterRegistry.RegisterUpdater(updater);
             ElementCategoryFilter wallFilter = new ElementCategoryFilter(BuiltInCategory.OST_Walls);
             ElementClassFilter familyFilter = new ElementClassFilter(typeof(FamilyInstance));
             ElementCategoryFilter massFilter = new ElementCategoryFilter(BuiltInCategory.OST_Mass);
             IList<ElementFilter> filterList = new List<ElementFilter>();
             filterList.Add(wallFilter);
             filterList.Add(familyFilter);
             filterList.Add(massFilter);
             LogicalOrFilter filter = new LogicalOrFilter(filterList);

             UpdaterRegistry.AddTrigger(updater.GetUpdaterId(), filter, Element.GetChangeTypeGeometry());
             UpdaterRegistry.AddTrigger(updater.GetUpdaterId(), filter, Element.GetChangeTypeElementDeletion());
        }
开发者ID:AMEE,项目名称:revit,代码行数:39,代码来源:Command.cs


示例18: CanCreateAndDeleteAReferencePoint

        public void CanCreateAndDeleteAReferencePoint()
        {
            using (var trans = new Transaction(RevitData.Document.Document, "CreateAndDeleteAreReferencePoint"))
            {
                trans.Start();

                FailureHandlingOptions fails = trans.GetFailureHandlingOptions();
                fails.SetClearAfterRollback(true);
                trans.SetFailureHandlingOptions(fails);

                ReferencePoint rp = dynRevitSettings.Doc.Document.FamilyCreate.NewReferencePoint(new XYZ());

                //make a filter for reference points.
                ElementClassFilter ef = new ElementClassFilter(typeof(ReferencePoint));
                FilteredElementCollector fec = new FilteredElementCollector(dynRevitSettings.Doc.Document);
                fec.WherePasses(ef);
                Assert.AreEqual(1, fec.ToElements().Count());

                RevitData.Document.Document.Delete(rp);
                trans.Commit();
            }
        }
开发者ID:riteshchandawar,项目名称:Dynamo,代码行数:22,代码来源:ReferencePointTests.cs


示例19: GetAllWallElements

        /// <summary>
        /// This function gets all the walls in the current Revit document
        /// </summary>
        /// <param name="startNewTransaction">whether do the filtering in a new transaction</param>
        /// <returns>the walls</returns>
        private static IList<Element> GetAllWallElements(bool startNewTransaction)
        {
            if (startNewTransaction)
            {
                using (var trans = new Transaction(DocumentManager.Instance.CurrentUIDocument.Document, "FilteringElements"))
                {
                    trans.Start();

                    ElementClassFilter ef = new ElementClassFilter(typeof(Wall));
                    FilteredElementCollector fec = new FilteredElementCollector(DocumentManager.Instance.CurrentUIDocument.Document);
                    fec.WherePasses(ef);

                    trans.Commit();
                    return fec.ToElements();
                }
            }
            else
            {
                ElementClassFilter ef = new ElementClassFilter(typeof(Wall));
                FilteredElementCollector fec = new FilteredElementCollector(DocumentManager.Instance.CurrentUIDocument.Document);
                fec.WherePasses(ef);
                return fec.ToElements();
            }
        }
开发者ID:heegwon,项目名称:Dynamo,代码行数:29,代码来源:ElementBindingTests.cs


示例20: Execute

            public Result Execute(
                ExternalCommandData commandData,
                ref string message,
                ElementSet elements)
            {
                try
                {
                  UIApplication uiApp = commandData.Application;
                  UIDocument uidoc = uiApp.ActiveUIDocument;
                  Application app = uiApp.Application;
                  Document doc = uidoc.Document;

                  Stopwatch sw = Stopwatch.StartNew();

                  // f5 = f1 && f4
                  // = f1 && (f2 || f3)
                  // = family instance and (door or window)

                  #region Filters and collector definitions

                  ElementClassFilter f1
                = new ElementClassFilter(
                  typeof( FamilyInstance ) );

                  ElementCategoryFilter f2
                = new ElementCategoryFilter(
                  BuiltInCategory.OST_Doors );

                  ElementCategoryFilter f3
                = new ElementCategoryFilter(
                  BuiltInCategory.OST_Windows );

                  LogicalOrFilter f4
                = new LogicalOrFilter( f2, f3 );

                  LogicalAndFilter f5
                = new LogicalAndFilter( f1, f4 );

                  FilteredElementCollector collector
                = new FilteredElementCollector( doc );

                  #endregion

                  //#region Filtering with a class filter
                  //List<Element> openingInstances =
                  //  collector.WherePasses(f5).ToElements()
                  //    as List<Element>;
                  //#endregion

                  //#region Filtering with an anonymous method
                  //List<Element> openings = collector
                  //  .WherePasses(f4)
                  //  .ToElements() as List<Element>;
                  //List<Element> openingInstances
                  //  = openings.FindAll(
                  //    e => e is FamilyInstance );
                  //#endregion

                  #region Filtering with LINQ
                  List<Element> openings = collector
                .WherePasses( f4 )
                .ToElements() as List<Element>;

                  List<Element> openingInstances
                = ( from instances in openings
                where instances is FamilyInstance
                select instances ).ToList<Element>();
                  #endregion

                  int n = openingInstances.Count;
                  sw.Stop();

                  Debug.WriteLine( string.Format(
                "Time to get {0} elements: {1}ms",
                n, sw.ElapsedMilliseconds ) );

                  return Result.Succeeded;
                }
                catch( Exception ex )
                {
                  message = ex.Message + ex.StackTrace;
                  return Result.Failed;
                }
            }
开发者ID:nbright,项目名称:the_building_coder_samples,代码行数:84,代码来源:CmdCollectorPerformance.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ElementCollection类代码示例发布时间:2022-05-24
下一篇:
C# ElementChangedEventArgs类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap