List all possible curtain wall families in project

List all possible curtain wall families in project

ssw9UZNL
Advocate Advocate
1,189 Views
5 Replies
Message 1 of 6

List all possible curtain wall families in project

ssw9UZNL
Advocate
Advocate

Hello All,

 

I want to simply get a list of all the possible curtain wall families in my project.

 

I can use the filtered element collector to find all the curtain walls that have bene placed in my project, but I actually just want the list of all the different options (imagining I am yet to place the curtain panels).

 

Additionally, I have 5000 + panels in my project and only 20 families, so I would rather just save the computational time and sort over the families as opposed to all the panels.

 

I have seen the way below, but when I pass in CurtainWallPanels, it does not seem to work.

 

Thankyou.

 

collector = new FilteredElementCollector(doc).OfClass(typeof(Family));

 

0 Likes
1,190 Views
5 Replies
Replies (5)
Message 2 of 6

jeremy_tammik
Alumni
Alumni

You can explore your project with RevitLookup to see what characteristics you can use to set up an appropriate filtered element collector to retrieve only the families that you require. It might include the Family class, the curtain family category, and maybe other aspects.

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 6

ssw9UZNL
Advocate
Advocate

Hi @jeremy_tammik ,

 

Exactly, I would like to find all the families belong to the 'CurtainWallPanels' category.

 

I just cant work our how I would find that.

 

Thanks

0 Likes
Message 4 of 6

jeremy_tammik
Alumni
Alumni

Have you worked through the getting started material? It is explained there.

  

Have you used RevitLookup at all?

   

Anyway, to answer your question, just add a category filter to the collector.

  

For instance, to check for Wall elements of category Walls, you could say:

 

          .OfCategory( BuiltInCategory.OST_Walls )
          .OfClass( typeof( Wall ) )

 

You want Family elements with curtain wall category.

 

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 5 of 6

ssw9UZNL
Advocate
Advocate

hello,

 

yes I have, the bit where I get stuck is with OfClass, what does this actually mean?

 

Test = DB.FilteredElementCollector(doc).OfCategory(inputcat).OfClass(typeof( Wall ) )

 

In the documentation it says that I want to be passing a string in- but would this be a string that matches what my family is called?

 

Thanks for your help.

 

https://docs.microsoft.com/en-us/dotnet/api/system.type?redirectedfrom=MSDN&view=net-5.0

0 Likes
Message 6 of 6

jeremy_tammik
Alumni
Alumni

Actually, you can use the GetFamiliesOfCategory method from The Building Coder samples:

 

https://github.com/jeremytammik/the_building_coder_samples/blob/master/BuildingCoder/BuildingCoder/C...

 

    // for http://forums.autodesk.com/t5/revit-api-forum/having-trouble-filtering-to-ost-titleblocks/m-p/6827759
    static bool FamilyFirstSymbolCategoryEquals(
      Family f,
      BuiltInCategory bic )
    {
      Document doc = f.Document;

      ISet<ElementId> ids = f.GetFamilySymbolIds();

      Category cat = (0 == ids.Count)
        ? null
        : doc.GetElement( ids.First<ElementId>() ).Category;

      return null != cat
        && cat.Id.IntegerValue.Equals( (int) bic );
    }

    static void GetFamiliesOfCategory(
      Document doc,
      BuiltInCategory bic )
    {
      // This does not work:

      //FilteredElementCollector collector
      //  = new FilteredElementCollector( doc );
      //ICollection<Element> titleFrames = collector
      //  .OfCategory( BuiltInCategory.OST_TitleBlocks )
      //  .OfClass( typeof( Family ) )
      //  .ToElements();

      IEnumerable<Family> families
        = new FilteredElementCollector( doc )
          .OfClass( typeof( Family ) )
          .Cast<Family>()
          .Where<Family>( f =>
            FamilyFirstSymbolCategoryEquals( f, bic ) );
    }

 

How to use the class and category filters is documented in the getting started material; that would answer all those questions right out of the box:

 

https://thebuildingcoder.typepad.com/blog/about-the-author.html#2

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes