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 selection of elements by family

3 REPLIES 3
Reply
Message 1 of 4
ricobano
633 Views, 3 Replies

Filter selection of elements by family

Hi guys i need to filter the selected elements by family.  We have a timber beam family and i need to modify only selected elements that are part of the timber family.

 

Any ideas?

3 REPLIES 3
Message 2 of 4
ollikat
in reply to: ricobano

First solution that came to my mind:

 

Go trough all you elements in selection and...

 

1. First of all accept only those which can be casted to FamilyInstance(s).

2. Get the family symbol with FamilyInstance::Symbol and furthermore family with FamilySymbol::Family

3. If family element ID is same than timber family's ID, you got your element 😉

Message 3 of 4
ricobano
in reply to: ollikat

Thanks Any chance of some code.  Im all new to autodesk

Message 4 of 4
ollikat
in reply to: ricobano

This is just quick sample I wrote (C++ CLI)...not even tested that it compiles. If you are using C#, you have to figure out your self how to convert syntax 😉

 

List<Element^> timberElems;

  for each (Element ^elem in ActiveUIDocument->Selection->Elements)
  {
    try
    {
      FamilyInstance ^fInst = safe_cast<>(elem);
      Family ^selFam = fInst->Symbol->Family;

      if (selFam->Id->IntegerValue == timberFam->Id->IntegerValue)
        timberElems.Add(elem);
    }
    catch (InvalidCastException^)
    {
      ;
    }

 

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