Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Filter System Families from Component Families

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Dale.Bartlett
1210 Views, 3 Replies

Filter System Families from Component Families

Is it possible to filter just for System Families and ignore Component Families? I have used this example, however despite the heading, it actually returns all families.

http://adndevblog.typepad.com/aec/2012/05/accessing-system-families-in-a-revit-template.html

I know that I can filter by a specified Type:

FilteredElementCollector coll = new FilteredElementCollector(pDoc);
// get all the wall types as wall type objects:
coll.OfClass(typeof(WallType));
IEnumerable<WallType> types = coll.Cast<WallType>();

 

What I need is to to return all Types that are System Families. Any and all suggestions appreciated; I have Googled to a standstill.

 

Regards, Dale




______________
Yes, I'm Satoshi.
3 REPLIES 3
Message 2 of 4

You could try .WhereElementIsElementType() plus new ElementClassFilter(typeof(FamilySymbol), true /* inverted */)

You can apply these two sequentially and that should get what need.

Cheers
Message 3 of 4

Check this command

 

[Transaction(TransactionMode.Manual)]

publicclassCommand : IExternalCommand

{

publicResultExecute(

  ExternalCommandDatacommandData,

  refstringmessage,

  ElementSetelements)

  {

    UIApplicationuiapp=commandData.Application;

    UIDocumentuidoc=uiapp.ActiveUIDocument;

    Applicationapp=uiapp.Application;

    Documentdoc=uidoc.Document;

 

    // WhereElementIsElementType is pretty self explanatory  

    // since it will give back only elements that are ElementType

    FilteredElementCollectorcoll=newFilteredElementCollector(doc)

                                        .WhereElementIsElementType();

    // the true value after the typeof will give back the 

    // inverted of what it was asked

    ElementClassFilterfilterInv= 

                   newElementClassFilter(typeof(FamilySymbol), true);

    // add a watch to coll.WherePasses(filterInv) when debugging, 

    //when the result is checked every inverted FamilySymbol will 

    //get displayed.

    coll.WherePasses(filterInv); 

    returnResult.Succeeded;

 

  }

}

 

I added comments but a quick explanation will be that when you add the True flag at the end of the newElementClassFilter will return you the inverted list which is what you are looking for. Try to Add to Watch the last line and open it and check the results list you will see all the inverted ones from FamilySymbol. Hope this helps.

 

 



Jaime Rosales D.
Sr. Developer Consultant
Twitter | AEC ADN DevBlog
Message 4 of 4

Thank you Jaime, working well now. Others may be interested to reference your blog:

http://adndevblog.typepad.com/aec/2014/08/system-families-filter-and-beach-aerial-picture.html

Regards, Dale

 

 




______________
Yes, I'm Satoshi.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community