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


C# FilteredElementCollector.Select方法代码示例

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


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

示例1: Execute

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

              var fillPatternElements
            = new FilteredElementCollector( doc )
              .OfClass( typeof( FillPatternElement ) )
              .OfType<FillPatternElement>()
              .OrderBy( fp => fp.Name )
              .ToList();

              var fillPatterns
            = fillPatternElements.Select(
              fpe => fpe.GetFillPattern() );

              FillPatternsViewModel fillPatternsViewModel
            = new FillPatternsViewModel( fillPatterns
              .Select( x => new FillPatternViewModel(
            x ) ) );

              FillPatternsView fillPatternsView
            = new FillPatternsView()
              {
            DataContext = fillPatternsViewModel
              };

              fillPatternsView.ShowDialog();

              return Result.Succeeded;
        }
开发者ID:kfpopeye,项目名称:AddMaterials,代码行数:34,代码来源:FillPatternBenchmarkCommand.cs

示例2: GetInstancesIntersectingElement

        /// <summary>
        /// Retrieve all family instances intersecting a
        /// given BIM element, e.g. all columns 
        /// intersecting a wall.
        /// </summary>
        void GetInstancesIntersectingElement( Element e )
        {
            #region Joe's code
            #if JOE_CODE
            // Find intersections between family instances and a selected element

            Reference Reference = uidoc.Selection.PickObject(
            ObjectType.Element, "Select element that will "
            + "be checked for intersection with all family "
            + "instances" );

            Element e = doc.GetElement( reference );

            GeometryElement geomElement = e.get_Geometry(
            new Options() );

            Solid solid = null;
            foreach( GeometryObject geomObj in geomElement )
            {
            solid = geomObj as Solid;
            if( solid = !null ) break;
            }

            FilteredElementCollector collector
            = new FilteredElementCollector( doc )
              .OfClass( typeof( FamilyInstance ) )
              .WherePasses( new ElementIntersectsSolidFilter(
            solid ) );

            TaskDialog.Show( "Revit", collector.Count() +
            "Family instances intersect with selected element ("
            + element.Category.Name + "ID:" + element.Id + ")" );
            #endif // JOE_CODE
              #endregion // Joe's code

              // Test this in these SDK sample models:
              // C:\a\lib\revit\2015\SDK\Samples\FindReferencesByDirection\FindColumns\FindColumns-Basic.rvt
              // C:\a\lib\revit\2015\SDK\Samples\FindReferencesByDirection\FindColumns\FindColumns-TestCases.rvt

              Document doc = e.Document;

              Solid solid = e.get_Geometry( new Options() )
            .OfType<Solid>()
            .Where<Solid>( s => null != s && !s.Edges.IsEmpty )
            .FirstOrDefault();

              FilteredElementCollector intersectingInstances
            = new FilteredElementCollector( doc )
              .OfClass( typeof( FamilyInstance ) )
              .WherePasses( new ElementIntersectsSolidFilter(
            solid ) );

              int n1 = intersectingInstances.Count<Element>();

              intersectingInstances
            = new FilteredElementCollector( doc )
              .OfClass( typeof( FamilyInstance ) )
              .WherePasses( new ElementIntersectsElementFilter(
            e ) );

              int n = intersectingInstances.Count<Element>();

              Debug.Assert( n.Equals( n1 ),
            "expected solid intersection to equal element intersection" );

              string result = string.Format(
            "{0} family instance{1} intersect{2} the "
            + "selected element {3}{4}",
            n, Util.PluralSuffix( n ),
            ( 1 == n ? "s" : "" ),
            Util.ElementDescription( e ),
            Util.DotOrColon( n ) );

              string id_list = 0 == n
            ? string.Empty
            : string.Join( ", ",
            intersectingInstances
              .Select<Element, string>(
                x => x.Id.IntegerValue.ToString() ) )
              + ".";

              Util.InfoMsg2( result, id_list );
        }
开发者ID:nbright,项目名称:the_building_coder_samples,代码行数:88,代码来源:CmdCollectorPerformance.cs

示例3: MyTest

        public static void MyTest( Document doc )
        {
            string familyName = "Single-Flush";

              // get the family we want
              FilteredElementCollector fec = new FilteredElementCollector( doc );
              fec.OfClass( typeof( Family ) );

              Func<Element, bool> nameEquals = e => e.Name.Equals( familyName );

              Family f = fec.First<Element>( nameEquals ) as Family;

              // get the symbols of that family
              FamilySymbolFilter fsf = new FamilySymbolFilter( f.Id );
              fec = new FilteredElementCollector( doc );
              fec.WherePasses( fsf );

              // list them

              Func<Element, string> getName = e => e.Name;

              string str = string.Join( "\n",
            fec.Select<Element, string>( getName ).ToArray<string>() );

              System.Windows.Forms.MessageBox.Show( str.ToString(), "FamilySymbols of " + familyName );
        }
开发者ID:jeremytammik,项目名称:AdnRevitApiLabsXtra,代码行数:26,代码来源:LabUtils.cs

示例4: UpdateBim

    /// <summary>
    /// Apply all current cloud database 
    /// changes to the BIM.
    /// </summary>
    public void UpdateBim()
    {
      Util.Log( "UpdateBim begin" );

      using( JtTimer pt = new JtTimer( "UpdateBim" ) )
      {
        Document doc = _uiapp.ActiveUIDocument.Document;

        // Retrieve all room unique ids in model:

        FilteredElementCollector rooms
          = new FilteredElementCollector( doc )
            .OfClass( typeof( SpatialElement ) )
            .OfCategory( BuiltInCategory.OST_Rooms );

        IEnumerable<string> roomUniqueIds
          = rooms.Select<Element, string>(
            e => e.UniqueId );

        // Convert to a dictionary for faster lookup:

        _roomUniqueIdDict
          = new Dictionary<string, int>(
            roomUniqueIds.Count() );

        foreach( string s in roomUniqueIds )
        {
          _roomUniqueIdDict.Add( s, 1 );
        }

        //string ids = "?keys=[%22" + string.Join(
        //  "%22,%22", roomUniqueIds ) + "%22]";

        // Retrieve all furniture transformations 
        // after the last sequence number:

        CouchDatabase db = new RoomEditorDb().Db;

        ChangeOptions opt = new ChangeOptions();

        opt.IncludeDocs = true;
        opt.Since = LastSequence;
        opt.View = "roomedit/map_room_to_furniture";

        // I tried to add a filter to this view, but 
        // that is apparently not supported by the 
        // CouchDB or DreamSeat GetChanges functionality.
        //+ ids; // failed attempt to filter view by room id keys

        // Specify filter function defined in 
        // design document to get updates
        //opt.Filter = 

        CouchChanges<DbFurniture> changes
          = db.GetChanges<DbFurniture>( opt );

        CouchChangeResult<DbFurniture>[] results
          = changes.Results;

        foreach( CouchChangeResult<DbFurniture> result
          in results )
        {
          UpdateBimFurniture( result.Doc );

          LastSequence = result.Sequence;
        }
      }
      Util.Log( "UpdateBim end" );
    }
开发者ID:mtumminello,项目名称:RoomEditorApp,代码行数:73,代码来源:DbUpdater.cs

示例5: GetBeamsIntersectingTwoColumns

        /// <summary>
        /// Retrieve all beam family instances 
        /// intersecting two columns, cf.
        /// http://forums.autodesk.com/t5/revit-api/check-to-see-if-beam-exists/m-p/6223562
        /// </summary>
        FilteredElementCollector GetBeamsIntersectingTwoColumns(
            Element column1,
            Element column2)
        {
            Document doc = column1.Document;

              if( column2.Document.GetHashCode() != doc.GetHashCode() )
              {
            throw new ArgumentException(
              "Expected two columns from same document." );
              }

              FilteredElementCollector intersectingStructuralFramingElements
            = new FilteredElementCollector( doc )
              .OfClass( typeof( FamilyInstance ) )
              .OfCategory( BuiltInCategory.OST_StructuralFraming )
              .WherePasses( new ElementIntersectsElementFilter( column1 ) )
              .WherePasses( new ElementIntersectsElementFilter( column2 ) );

              int n = intersectingStructuralFramingElements.Count<Element>();

              string result = string.Format(
            "{0} structural framing family instance{1} "
            + "intersect{2} the two beams{3}",
            n, Util.PluralSuffix( n ),
            ( 1 == n ? "s" : "" ),
            Util.DotOrColon( n ) );

              string id_list = 0 == n
            ? string.Empty
            : string.Join( ", ",
            intersectingStructuralFramingElements
              .Select<Element, string>(
                x => x.Id.IntegerValue.ToString() ) )
              + ".";

              Util.InfoMsg2( result, id_list );

              return intersectingStructuralFramingElements;
        }
开发者ID:jeremytammik,项目名称:the_building_coder_samples,代码行数:45,代码来源:CmdCollectorPerformance.cs


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