Revit API

Reply
Active Member
ricobano
Posts: 7
Registered: ‎06-28-2011
Message 1 of 4 (291 Views)

Filter selection of elements by family

291 Views, 3 Replies
06-30-2011 02:36 AM

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?

Distinguished Contributor
ollikat
Posts: 148
Registered: ‎04-01-2011
Message 2 of 4 (279 Views)

Re: Filter selection of elements by family

06-30-2011 05:16 AM 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::smileyfrustrated:ymbol and furthermore family with FamilySymbol::Family

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

Active Member
ricobano
Posts: 7
Registered: ‎06-28-2011
Message 3 of 4 (275 Views)

Re: Filter selection of elements by family

06-30-2011 06:42 AM in reply to: ollikat

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

Distinguished Contributor
ollikat
Posts: 148
Registered: ‎04-01-2011
Message 4 of 4 (245 Views)

Re: Filter selection of elements by family

06-30-2011 11:08 PM 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^)
    {
      ;
    }

 

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Revit Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Revit helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Revit

Twitter

Facebook

Blogs

Youtube