Skip empty views when using Dynamo to export multple NWCs

I’ve been running a modified version of the scripts shown in some of the threads like here . It takes a keyword and exports NWCs for any views with that keyword.

But if I have a model with many views, each with a section box for a different area, and some views don’t have model content in them, yet, is there a setting in the NavisworksExportOptions to automatically skip over views that don’t have model content in them?

Right now, I must watch the script as it runs to manually click the ‘OK’ button on the popup for each empty view.

I didn’t see an option in the Revit API ( to skip over empty views – but am I missing something?

Workarounds I’ve considered:

  • Count the elements in a view collector, and only export if that list is greater than 0. But FilteredElementCollector** (doc, view.Id). ToElements ()” still returns elements that are outside the view’s section box.
  • Hardcode an exclusion list. But the model is being constantly updated, so I want to avoid maintaining a list. Also, I’d have to search through the model to find which views are still empty whenever I want to export.


My suggestion is to use this filter:

Create a boundingbox for your section box and voila, you can use that filter.

Hi Kavin and welcome to the community,

The same issue has been discussed in this post on the autodesk forum.

According to their comments, you could use “try” and “except” to work around this warning. You might want to look for the exact exception type (maybe InvalidOperationException, as one comment suggests) and skip to the next view.

SInce @Konrad_K_Sobon created that post (back in 2016 :slight_smile: ) he might know of a different approach.

To add onto this, Revit-specific exceptions have to be imported from the Autodesk.Revit.Exceptions namespace. For example:

import clr
from Autodesk.Revit.Exceptions import InvalidOperationException

    # something
except InvalidOperationException:
    # catch Exception
    # execute rest of code