I appreciate you giving an answer here but there are some fundamental mistakes in your code:
- First, you are referencing variables that are not defined. That would confuse even an experienced programmer, not to mention the inexperienced ones. Please post all of the import statements etc.
- It's very inefficient to create Options for every variable. It would make more sense to define them outside of the loop, and then just change the View Id.
- You don't need that elif>pass statement. That loop will continue regardless.
- No need to show code that was commented out.
- You are in a loop, potentially exporting many views but you never change the name/path of the file, so basically it will either throw an exception or just override the same file and you will end up with your last one only.
This is what this should look like:
# Import DocumentManager and TransactionManager
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument
collector = FilteredElementCollector(doc).OfClass(View)
options = NavisworksExportOptions()
options.ExportScope = NavisworksExportScope.View
folder = r"C:\SomeFolder"
for view in collector:
if view.ViewType == ViewType.ThreeD and view.Name.Contains("Navisworks"):
options.ViewId = view.Id
doc.Export(folder, "Export-" + view.Name + ".nwc", options)
OUT = 0
It's also worth mentioning that for this code to work you have to have Navisworks exporter installed in Revit.
Ps. This is very much untested but should work just fine.