Results 1 to 2 of 2

Thread: Filtered Element Collector using a List of System Family Categories?

  1. #1
    Administrator Twiceroadsfool's Avatar
    Join Date
    December 7, 2010
    Dallas, TX
    Current Local Time
    04:04 AM

    Not allowed! Not allowed!

    Filtered Element Collector using a List of System Family Categories?

    So im gathering all of the objects in the model, for some stuff.

    I made a List of FamilyInstance Categories, like this:

    List<BuiltInCategory> FamilyModelCategories = new List<BuiltInCategory>(2);

    FamilyModelCategories.Add(BuiltInCategory.OST_Duct Terminal);
    FamilyModelCategories.Add(BuiltInCategory.OST_Cabl eTray);
    FamilyModelCategories.Add(BuiltInCategory.OST_Cabl eTrayDrop);
    FamilyModelCategories.Add(BuiltInCategory.OST_Cabl eTrayFitting);

    Then i gathered them with:

    FilteredElementCollector ModeledComponents
    = new FilteredElementCollector(doc)
    .WherePasses(new ElementMulticategoryFilter(FamilyModelCategories)) ;

    It worked great. But, even though the System Families exist in the OST_ area of BuiltInCategories, they dont work. So i have a seperate list of:

    List<Type> SysFamCategories = new List<Type>(2);


    And that appears to work fine (not that i can tell, though). Because, i cant figure out that goes in .WherePasses for this FilteredCollector...?

    FilteredElementCollector ModeledSystems = new FilteredElementCollector(doc)
    .WherePasses( What the heck goes here?? (SysFamCategories));

    Or is this not going to fly? I was making the individual system category Collections individually, and UnionWith-ing them all together. But since this worked for the FamilyInstance part, i figured it would be a little more streamlined. But if not...

  2. #2
    Member feio's Avatar
    Join Date
    December 13, 2010
    Decadent Lisbon
    Current Local Time
    09:04 AM

    Not allowed! Not allowed!
    I would suggest the union. Much simpler.
    To join multiple FilteredElementCollector you need a LogicalOrFilter, see this example: The Building Coder: Do Not Filter For All Elements
    And start using static methods. Makes your code much more clean. For start try this:
    public static class Collectors
        public static IList<Element> InstancesList(this Document doc)
           return new FilteredElementCollector(doc).WherePasses(new ElementIsElementTypeFilter(false)).ToElements();
    This way you can access the instances list directly from a Document instance, as in:
    IList<Element> instances = doc.InstancesList();
    Later, you will want to complicate the parameters passed in the method, but that's in the human nature

Similar Threads

  1. Family Categories
    By dzatto in forum Architecture - Family Creation
    Replies: 12
    Last Post: June 12th, 2017, 03:08 PM
  2. 2D Element into 3D Family
    By MachoMan in forum Architecture and General Revit Questions
    Replies: 4
    Last Post: November 21st, 2011, 09:51 AM
  3. Replies: 7
    Last Post: October 23rd, 2011, 01:03 PM
  4. Family Element Visibility Settings
    By ELaforge in forum MEP - Family Creation
    Replies: 1
    Last Post: May 4th, 2011, 08:07 PM
  5. Revit SDK 2012 Retrieve Filtered Elements example
    By Nelson in forum Third party Add-Ins, API and R&D
    Replies: 7
    Last Post: April 28th, 2011, 01:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts