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


C# FilteredElementCollector.OfClass方法代码示例

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


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

示例1: DividedSurface

        public void DividedSurface()
        {
            var model = ViewModel.Model;

            string samplePath = Path.Combine(workingDirectory, @".\DividedSurface\DividedSurface.dyn");
            string testPath = Path.GetFullPath(samplePath);
            
            ViewModel.OpenCommand.Execute(testPath);
            ViewModel.Model.RunExpression();

            FilteredElementCollector fec = new FilteredElementCollector(DocumentManager.Instance.CurrentUIDocument.Document);
            fec.OfClass(typeof(DividedSurface));

            //did it create a divided surface?
            Assert.AreEqual(1, fec.ToElements().Count());

            var ds = (DividedSurface)fec.ToElements()[0];
            Assert.AreEqual(5, ds.USpacingRule.Number);
            Assert.AreEqual(5, ds.VSpacingRule.Number);

            //can we change the number of divisions
            var numNode = ViewModel.Model.Nodes.OfType<DoubleInput>().First();
            numNode.Value = "10";
            ViewModel.Model.RunExpression();

            //did it create a divided surface?
            Assert.AreEqual(10, ds.USpacingRule.Number);
            Assert.AreEqual(10, ds.VSpacingRule.Number);

            //ensure there is a warning when we try to set a negative number of divisions
            numNode.Value = "-5";
            ViewModel.Model.RunExpression();
            Assert.Greater(ViewModel.Model.EngineController.LiveRunnerCore.RuntimeStatus.WarningCount, 0);
        }
开发者ID:whztt07,项目名称:Dynamo,代码行数:34,代码来源:DividedSurfaceTests.cs

示例2: CanChangeLacingAndHaveElementsUpdate

        public void CanChangeLacingAndHaveElementsUpdate()
        {
            string samplePath = Path.Combine(_testPath, @".\Core\LacingTest.dyn");
            string testPath = Path.GetFullPath(samplePath);

            Controller.DynamoViewModel.OpenCommand.Execute(testPath);

            var xyzNode = dynSettings.Controller.DynamoModel.Nodes.First(x => x.NickName == "Point.ByCoordinates");
            Assert.IsNotNull(xyzNode);
            
            //test the shortest lacing
            xyzNode.ArgumentLacing = LacingStrategy.Shortest;
            dynSettings.Controller.RunExpression(true);
            var fec = new FilteredElementCollector((Autodesk.Revit.DB.Document)DocumentManager.Instance.CurrentDBDocument);
            fec.OfClass(typeof(ReferencePoint));
            Assert.AreEqual(4, fec.ToElements().Count());

            //test the longest lacing
            xyzNode.ArgumentLacing = LacingStrategy.Longest;
            dynSettings.Controller.RunExpression(true);
            fec = null;
            fec = new FilteredElementCollector((Autodesk.Revit.DB.Document)DocumentManager.Instance.CurrentDBDocument);
            fec.OfClass(typeof(ReferencePoint));
            Assert.AreEqual(5, fec.ToElements().Count());

            //test the cross product lacing
            xyzNode.ArgumentLacing = LacingStrategy.CrossProduct;
            dynSettings.Controller.RunExpression(true);
            fec = null;
            fec = new FilteredElementCollector((Autodesk.Revit.DB.Document)DocumentManager.Instance.CurrentDBDocument);
            fec.OfClass(typeof(ReferencePoint));
            Assert.AreEqual(20, fec.ToElements().Count());
        }
开发者ID:heegwon,项目名称:Dynamo,代码行数:33,代码来源:CoreTests.cs

示例3: GetClosestFace

        public static Tuple<Face, Reference> GetClosestFace(Document document, XYZ p)
        {
            Face resultFace = null;
            Reference resultReference = null;

            double min_distance = double.MaxValue;
            FilteredElementCollector collector = new FilteredElementCollector(document);
            var walls = collector.OfClass(typeof (Wall));
            foreach (Wall wall in walls)
            {
                IList<Reference> sideFaces =
                    HostObjectUtils.GetSideFaces(wall, ShellLayerType.Interior);
                // access the side face
                Face face = document.GetElement(sideFaces[0]).GetGeometryObjectFromReference(sideFaces[0]) as Face;
                var intersection = face.Project(p);

                if (intersection != null)
                {
                    if (intersection.Distance < min_distance)
                    {
                        resultFace = face;
                        resultReference = sideFaces[0];
                        min_distance = intersection.Distance;
                    }
                }
            }
            //resultFace.
            return new Tuple<Face,Reference>( resultFace, resultReference);
        }
开发者ID:KonbOgonb,项目名称:revit-psElectro-bridge,代码行数:29,代码来源:FindWallHelper.cs

示例4: TestOne

        public void TestOne()
        {
            using (var t = new Transaction(DocumentManager.Instance.CurrentDBDocument))
            {
                if (t.Start("Test one.") == TransactionStatus.Started)
                {
                    //create a reference point
                    var pt = DocumentManager.Instance.CurrentDBDocument.FamilyCreate.NewReferencePoint(new XYZ(5, 5, 5));

                    if (t.Commit() != TransactionStatus.Committed)
                    {
                        t.RollBack();
                    }
                }
                else
                {
                    throw new Exception("Transaction could not be started.");
                }
            }

            //verify that the point was created
            var collector = new FilteredElementCollector(DocumentManager.Instance.CurrentDBDocument);
            collector.OfClass(typeof (ReferencePoint));

            Assert.AreEqual(1, collector.ToElements().Count);
        }
开发者ID:algobasket,项目名称:Dynamo,代码行数:26,代码来源:TestExamples.cs

示例5: ReferenceCurve

        public void ReferenceCurve()
        {
            var model = dynSettings.Controller.DynamoModel;

            string samplePath = Path.Combine(_testPath, @".\ReferenceCurve\ReferenceCurve.dyn");
            string testPath = Path.GetFullPath(samplePath);

            model.Open(testPath);
            dynSettings.Controller.RunExpression(true);

            FilteredElementCollector fec = new FilteredElementCollector(dynRevitSettings.Doc.Document);
            fec.OfClass(typeof(CurveElement));

            //verify five model curves created
            int count = fec.ToElements().Count;
            Assert.IsInstanceOf(typeof(ModelCurve), fec.ToElements().First());
            Assert.IsTrue(((ModelCurve)fec.ToElements().First()).IsReferenceLine);
            Assert.AreEqual(5, count);

            ElementId id = fec.ToElements().First().Id;

            //update any number node and verify
            //that the element gets updated not recreated
            var doubleNodes = dynSettings.Controller.DynamoModel.Nodes.Where(x => x is DoubleInput);
            var node = doubleNodes.First() as DoubleInput;

            Assert.IsNotNull(node);

            node.Value = node.Value + .1;
            dynSettings.Controller.RunExpression(true);
            Assert.AreEqual(5, fec.ToElements().Count);
        }
开发者ID:riteshchandawar,项目名称:Dynamo,代码行数:32,代码来源:ReferenceCurveTests.cs

示例6: Level

        public void Level()
        {
            var model = dynSettings.Controller.DynamoModel;

            string samplePath = Path.Combine(_testPath, @".\Level\Level.dyn");
            string testPath = Path.GetFullPath(samplePath);

            model.Open(testPath);
            Assert.DoesNotThrow(() => dynSettings.Controller.RunExpression(true));

            //ensure that the level count is the same
            var levelColl = new FilteredElementCollector(dynRevitSettings.Doc.Document);
            levelColl.OfClass(typeof(Autodesk.Revit.DB.Level));
            Assert.AreEqual(levelColl.ToElements().Count(), 6);

            //change the number and run again
            var numNode = (DoubleInput)dynRevitSettings.Controller.DynamoModel.Nodes.First(x => x is DoubleInput);
            numNode.Value = "0..20..2";
            Assert.DoesNotThrow(() => dynSettings.Controller.RunExpression(true));

            //ensure that the level count is the same
            levelColl = new FilteredElementCollector(dynRevitSettings.Doc.Document);
            levelColl.OfClass(typeof(Autodesk.Revit.DB.Level));
            Assert.AreEqual(levelColl.ToElements().Count(), 11);
        }
开发者ID:riteshchandawar,项目名称:Dynamo,代码行数:25,代码来源:LevelTests.cs

示例7: Execute

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

              FilteredElementCollector collector
            = new FilteredElementCollector( doc );

              collector.OfClass( typeof( Level ) );
              Level level = collector.FirstElement() as Level;

              Transaction t = new Transaction( doc );

              t.Start( "Create unbounded room" );

              FailureHandlingOptions failOpt
            = t.GetFailureHandlingOptions();

              failOpt.SetFailuresPreprocessor(
            new RoomWarningSwallower() );

              t.SetFailureHandlingOptions( failOpt );

              doc.Create.NewRoom( level, new UV( 0, 0 ) );

              t.Commit();

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

示例8: GetSchedules

        public static IEnumerable<ViewSchedule> GetSchedules(this ViewSheet viewSheet)
        {
            var doc = viewSheet.Document;

            FilteredElementCollector collector =
                new FilteredElementCollector(doc, viewSheet.Id);

            var scheduleSheetInstances =
                collector
                    .OfClass(typeof(ScheduleSheetInstance))
                    .ToElements()
                    .OfType<ScheduleSheetInstance>();

            foreach (var scheduleSheetInstance in
                scheduleSheetInstances)
            {
                var scheduleId =
                    scheduleSheetInstance
                        .ScheduleId;
                if (scheduleId == ElementId.InvalidElementId)
                    continue;

                var viewSchedule =
                    doc.GetElement(scheduleId)
                    as ViewSchedule;

                if (viewSchedule != null)
                    yield return viewSchedule;
            }
        }
开发者ID:vchekalin,项目名称:ScheduleAPIDemo,代码行数:30,代码来源:GetSchedulesOnSheetCommand.cs

示例9: changeFamiliesNames

        public void changeFamiliesNames(Document doc)
        {
            //Gets the families
            Family familyNames = null;
            FilteredElementCollector collector = new FilteredElementCollector(doc);
            ICollection<Element> collection = collector.OfClass(typeof(Family)).ToElements();

            ValueDictionary dictionaryList = new ValueDictionary();
            var dictionary = dictionaryList.GetRenameFamilies();

            using (Transaction t = new Transaction(doc))
            {
                t.Start("new name");

                foreach (Element e in collection)
                {
                    familyNames = e as Family;
                    string familyName = familyNames.Name;

                    //Checks the dictionary and if found renames the family
                    if (dictionary.ContainsKey(familyName))
                    {
                        string value = dictionary[familyName];
                        familyNames.Name = value;
                        count++;
                    }
                }
                t.Commit();
                string message = "Number of Families Renamed: ";
                MessageBox.Show(message + count.ToString());
            }
        }
开发者ID:dannysbentley,项目名称:Family-Rename,代码行数:32,代码来源:changeFamilyNames.cs

示例10: GetAddressInStorage

        /// <summary>
        /// Get saved addresses in Storage. Currently only one address is supported 
        /// </summary>
        /// <param name="document">The document storing the saved address.</param>
        /// <param name="schema">The schema for address.</param>
        /// <returns>List of stored addresses</returns>
        private IList<DataStorage> GetAddressInStorage(Document document, Schema schema)
        {
            FilteredElementCollector collector = new FilteredElementCollector(document);
            collector.OfClass(typeof(DataStorage));
            Func<DataStorage, bool> hasTargetData = ds => (ds.GetEntity(schema) != null && ds.GetEntity(schema).IsValid());

            return collector.Cast<DataStorage>().Where<DataStorage>(hasTargetData).ToList<DataStorage>();
        }
开发者ID:whztt07,项目名称:RevitIFC,代码行数:14,代码来源:IFCAddress.cs

示例11: PopulateItems

        public override void PopulateItems()
        {
            var wallTypesColl = new FilteredElementCollector(dynRevitSettings.Doc.Document);
            wallTypesColl.OfClass(typeof(WallType));

            Items.Clear();

            wallTypesColl.ToElements().ToList().ForEach(x => Items.Add(new DynamoDropDownItem(x.Name, x)));
        }
开发者ID:kscalvin,项目名称:Dynamo,代码行数:9,代码来源:Wall.cs

示例12: CurveByPoints

        public void CurveByPoints()
        {
            var model = dynSettings.Controller.DynamoModel;

            string samplePath = Path.Combine(_testPath, @".\Curve\CurveByPoints.dyn");
            string testPath = Path.GetFullPath(samplePath);

            Controller.DynamoViewModel.OpenCommand.Execute(testPath);
            Assert.DoesNotThrow(() => dynSettings.Controller.RunExpression());

            //cerate some points and wire them
            //to the selections
            ReferencePoint p1, p2, p3, p4;

            using (_trans = new Transaction(DocumentManager.Instance.CurrentUIDocument.Document))
            {
                _trans.Start("Create reference points for testing.");

                p1 = DocumentManager.Instance.CurrentUIDocument.Document.FamilyCreate.NewReferencePoint(new XYZ(1, 5, 12));
                p2 = DocumentManager.Instance.CurrentUIDocument.Document.FamilyCreate.NewReferencePoint(new XYZ(5, 1, 12));
                p3 = DocumentManager.Instance.CurrentUIDocument.Document.FamilyCreate.NewReferencePoint(new XYZ(12, 1, 5));
                p4 = DocumentManager.Instance.CurrentUIDocument.Document.FamilyCreate.NewReferencePoint(new XYZ(5, 12, 1));

                _trans.Commit();
            }

            var ptSelectNodes = dynSettings.Controller.DynamoModel.Nodes.Where(x => x is DSModelElementSelection);
            if (!ptSelectNodes.Any())
                Assert.Fail("Could not find point selection nodes in dynamo graph.");

            ((DSModelElementSelection)ptSelectNodes.ElementAt(0)).SelectedElement = p1.Id;
            ((DSModelElementSelection)ptSelectNodes.ElementAt(1)).SelectedElement = p2.Id;
            ((DSModelElementSelection)ptSelectNodes.ElementAt(2)).SelectedElement = p3.Id;
            ((DSModelElementSelection)ptSelectNodes.ElementAt(3)).SelectedElement = p4.Id;

            dynSettings.Controller.RunExpression(true);

            FilteredElementCollector fec = new FilteredElementCollector(DocumentManager.Instance.CurrentUIDocument.Document);
            fec.OfClass(typeof(CurveElement));

            Assert.AreEqual(fec.ToElements().Count(), 1);

            CurveByPoints mc = (CurveByPoints)fec.ToElements().ElementAt(0);
            Assert.IsTrue(mc.IsReferenceLine);

            //now flip the switch for creating a reference curve
            var boolNode = dynSettings.Controller.DynamoModel.Nodes.Where(x => x is DSCoreNodesUI.BoolSelector).First();

            ((DSCoreNodesUI.BasicInteractive<bool>)boolNode).Value = false;

            dynSettings.Controller.RunExpression(true);
            Assert.AreEqual(fec.ToElements().Count(), 1);

            mc = (CurveByPoints)fec.ToElements().ElementAt(0);
            Assert.IsFalse(mc.IsReferenceLine);
        }
开发者ID:heegwon,项目名称:Dynamo,代码行数:56,代码来源:CurveTests.cs

示例13: CollectExteriorWalls

 /// <summary>
 /// Finds all exterior walls in the active document.
 /// </summary>
 /// <returns>An enumerable containing exterior walls.</returns>
 protected IEnumerable<Wall> CollectExteriorWalls()
 {
     FilteredElementCollector collector = new FilteredElementCollector(Document);
     IList<Element> elementsToProcess = collector.OfClass(typeof(Wall)).ToElements();
     // Use a LINQ query to filter out only Exterior walls
     IEnumerable<Wall> exteriorWalls = from wall in elementsToProcess.Cast<Wall>()
                                       where IsExterior(Document.get_Element(wall.GetTypeId()) as ElementType)
                                       select wall;
     return exteriorWalls;
 }
开发者ID:AMEE,项目名称:revit,代码行数:14,代码来源:FindSouthFacingWalls.cs

示例14: LevelHasViews

        /// <summary>
        /// Checks if level has views.
        /// </summary>
        /// <param name="level">
        /// The level.
        /// </param>
        /// <returns>
        /// True if the level has views generated, false otherwise.
        /// </returns>
        public static bool LevelHasViews(Level level)
        {
            if (level == null)
                return false;
            FilteredElementCollector viewCollector = new FilteredElementCollector(level.Document);
            viewCollector.OfClass(typeof(View));
            Func<View, bool> viewIsNonTemplateAndGeneratedByLevel = view => !view.IsTemplate && IsViewGeneratedByLevel(view, level);

            return viewCollector.Cast<View>().FirstOrDefault<View>(viewIsNonTemplateAndGeneratedByLevel) != null;
        }
开发者ID:whztt07,项目名称:RevitCustomIFCexporter,代码行数:19,代码来源:LevelUtil.cs

示例15: Evaluate

        public override Value Evaluate(FSharpList<Value> args)
        {
            var elementType = (Type) ((Value.Container) args[0]).Item;

            var collector = new FilteredElementCollector(dynRevitSettings.Doc.Document);
            collector.OfClass(elementType);

            var results = collector.ToElements().Aggregate(FSharpList<Value>.Empty, (current, el) => FSharpList<Value>.Cons(Value.NewContainer(el), current));
            return Value.NewList(results);
        }
开发者ID:riteshchandawar,项目名称:Dynamo,代码行数:10,代码来源:Selection.cs


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