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 all model elements except symbol elements

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
rita.aguiar
1078 Views, 2 Replies

Filter all model elements except symbol elements

How can I filter all model elements but not also the symbol elements?

I am creating a plugin using the Lab4_2_ExportParametersToExcel from the Revit API .NET Labs.

In Lab4_2_ExportParametersToExcel we are iterating "over all elements, both symbols and model elements, and then in the dictionary." (see attached .png)

 

How can I get all model elements but not the symbol elements?

The reason why I'm asking this is because when I run this plugin on a project with just a few columns and walls to make a small test, I get an endless list of elements (on an excel file) that I have no idea of where they came from and what they are, so I guess they might be symbol elements. (see excel file)

 

Any help would be appretiated

 

  [Transaction(TransactionMode.ReadOnly)]
  public class Lab4_2_ExportParametersToExcel : IExternalCommand
  {
    public Result Execute(ExternalCommandData commandData,
        ref string message, ElementSet elements )
    {
      UIApplication app = commandData.Application;
      Document doc = app.ActiveUIDocument.Document;

      // Extract and group the data from Revit in a dictionary,
      //where the key is the category name and the value is a list of elements.

      Stopwatch sw = Stopwatch.StartNew();

      Dictionary<string, List<Element>> sortedElements
        = new Dictionary<string, List<Element>>();

            // Iterate over all elements, both symbols and 
            // model elements, and then in the dictionary.

        ElementFilter f = new LogicalOrFilter(
        new ElementIsElementTypeFilter( false ),
        new ElementIsElementTypeFilter( true ) );

      FilteredElementCollector collector
        = new FilteredElementCollector( doc )
          .WherePasses( f );

 

 

2 REPLIES 2
Message 2 of 3
jeremytammik
in reply to: rita.aguiar

The sample you are using is retrieving absolutely all Revit database elements.

 

It uses a union of two Booleans, one set to true, one to false.

 

This is not what you are after at all.

 

I suggest that you read a little bit more about the basics of filtered element collectors and implement your own filter that really does want you need and retrieves the elements you are interested in:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.9

 

Cheers,

 

Jeremy

 

 

 

 

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 3 of 3
so-chong
in reply to: rita.aguiar

Hi,

 

This might be useful to you as an example how to filter all model elements.

 

https://github.com/jeremytammik/AdnRevitApiLabsXtra/blob/09c5ef80b6b4730159f4eb2e0a84c64d124bec92/Xt...

 

If you are new to the Revit API i also recommend you to study how to use filtered element collectors, for your own need as Jeremy mentioned.

 

Hope this helps,

 

Cheers,

So-Chong

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

Post to forums  

Rail Community


Autodesk Design & Make Report