Пример #1
0
        //(9.03,10.13,0) --> (-14.59,10.13,0)
        //(-14.59,10.13,0) --> (-14.59,1.93,0)
        //(-14.59,1.93,0) --> (-2.45,1.93,0)
        //(-2.45,1.93,0) --> (-2.45,-3.98,0)
        //(-2.45,-3.98,0) --> (9.03,-3.98,0)
        //(9.03,-3.98,0) --> (9.03,10.13,0)
        //(0.98,-0.37,0) --> (0.98,1.93,0)
        //(0.98,1.93,0) --> (5.57,1.93,0)
        //(5.57,1.93,0) --> (5.57,-0.37,0)
        //(5.57,-0.37,0) --> (0.98,-0.37,0)

        //(9.03,10.13) --> (-14.59,10.13)
        //(-14.59,10.13) --> (-14.59,1.93)
        //(-14.59,1.93) --> (-2.45,1.93)
        //(-2.45,1.93) --> (-2.45,-3.98)
        //(-2.45,-3.98) --> (9.03,-3.98)
        //(9.03,-3.98) --> (9.03,10.13)
        //(0.98,-0.37) --> (0.98,1.93)
        //(0.98,1.93) --> (5.57,1.93)
        //(5.57,1.93) --> (5.57,-0.37)
        //(5.57,-0.37) --> (0.98,-0.37)

        //Room Rooms <212639 Room 1> has 2 loops:
        //  0: (2753,3087), (-4446,3087), (-4446,587), (-746,587), (-746,-1212), (2753,-1212)
        //  1: (298,-112), (298,587), (1698,587), (1698,-112)
        #endregion // Get room boundary loops

        #region Get furniture contained in given room
        /// <summary>
        /// Return the element ids of all furniture and
        /// equipment family instances contained in the
        /// given room.
        /// </summary>
        static List <Element> GetFurniture(Room room)
        {
            BoundingBoxXYZ bb = room.get_BoundingBox(null);

            Outline outline = new Outline(bb.Min, bb.Max);

            BoundingBoxIntersectsFilter filter
                = new BoundingBoxIntersectsFilter(outline);

            Document doc = room.Document;

            // Todo: add category filters and other
            // properties to narrow down the results

            // what categories of family instances
            // are we interested in?

            BuiltInCategory[] bics = new BuiltInCategory[] {
                BuiltInCategory.OST_Furniture,
                BuiltInCategory.OST_PlumbingFixtures,
                BuiltInCategory.OST_SpecialityEquipment
            };

            LogicalOrFilter categoryFilter
                = new LogicalOrFilter(bics
                                      .Select <BuiltInCategory, ElementFilter>(
                                          bic => new ElementCategoryFilter(bic))
                                      .ToList <ElementFilter>());

            FilteredElementCollector familyInstances
                = new FilteredElementCollector(doc)
                  .WhereElementIsNotElementType()
                  .WhereElementIsViewIndependent()
                  .OfClass(typeof(FamilyInstance))
                  .WherePasses(categoryFilter)
                  .WherePasses(filter);

            int roomid = room.Id.IntegerValue;

            List <Element> a = new List <Element>();

            foreach (FamilyInstance fi in familyInstances)
            {
                if (null != fi.Room &&
                    fi.Room.Id.IntegerValue.Equals(roomid))
                {
                    Debug.Assert(fi.Location is LocationPoint,
                                 "expected all furniture to have a location point");

                    a.Add(fi);
                }
            }
            return(a);
        }
Пример #2
0
        /// <summary>
        /// Return the element ids of all furniture and 
        /// equipment family instances contained in the 
        /// given room.
        /// </summary>
        static List<Element> GetFurniture( Room room )
        {
            BoundingBoxXYZ bb = room.get_BoundingBox( null );

              Outline outline = new Outline( bb.Min, bb.Max );

              BoundingBoxIntersectsFilter filter
            = new BoundingBoxIntersectsFilter( outline );

              Document doc = room.Document;

              // Todo: add category filters and other
              // properties to narrow down the results

              // what categories of family instances
              // are we interested in?

              BuiltInCategory[] bics = new BuiltInCategory[] {
            BuiltInCategory.OST_Furniture,
            BuiltInCategory.OST_PlumbingFixtures,
            BuiltInCategory.OST_SpecialityEquipment
              };

              LogicalOrFilter categoryFilter
            = new LogicalOrFilter( bics
              .Select<BuiltInCategory,ElementFilter>(
            bic => new ElementCategoryFilter( bic ) )
              .ToList<ElementFilter>() );

              FilteredElementCollector familyInstances
            = new FilteredElementCollector( doc )
              .WhereElementIsNotElementType()
              .WhereElementIsViewIndependent()
              .OfClass( typeof( FamilyInstance ) )
              .WherePasses( categoryFilter )
              .WherePasses( filter );

              int roomid = room.Id.IntegerValue;

              List<Element> a = new List<Element>();

              foreach( FamilyInstance fi in familyInstances )
              {
            if( null != fi.Room
              && fi.Room.Id.IntegerValue.Equals( roomid ) )
            {
              Debug.Assert( fi.Location is LocationPoint,
            "expected all furniture to have a location point" );

              a.Add( fi );
            }
              }
              return a;
        }