Export each 3D view in the Revit project to Navisworks (nwc)

I have a Master file in Revit, in this file, i linked each MEP file, i created a 3D view for each MEP discipline and subdiscipline, i have 14 3D Views in my Master File Revit that i want to export to Navisworks like a seperated files, one for each 3D view.
Do you have any idea?.

hi @J_Josue_Correa:
try this Python:


    coll = FilteredElementCollector(ghstFile).OfCategory(BuiltInCategory.OST_Views)
		
for v in coll:
	if v.Name.Contains("Navisworks"):
					
		Options = Autodesk.Revit.DB.NavisworksExportOptions()
		Options.ExportScope = NavisworksExportScope.View
		Options.ViewId = v.Id
		doc.Export(path,  nm, Options)
	elif:
		pass
					


###################################################		
TransactionManager.Instance.EnsureInTransaction(doc)

TransactionManager.Instance.TransactionTaskDone()
###################################################


OUT =0
1 Like

I try with this; But honestly i had never write a script. I hope to do it well.
I will tell you about the results

I appreciate you giving an answer here but there are some fundamental mistakes in your code:

  1. 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.
  2. 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.
  3. You donā€™t need that elif>pass statement. That loop will continue regardless.
  4. No need to show code that was commented out.
  5. 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 clr
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument

clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

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.

Cheers!

5 Likes

@Konrad_K_Sobon thanx a lot for your advice :slight_smile:

I havenā€™t tested the code either, just noticed a small typo. In python the raw string should be prefixed with r, not @ as in C#.

folder = r"C:\some\folder"

yes! Thatā€™s correct. Thank you

And a final addition is to import the Revit API:

clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

The script works fine, except for the views where only the elements of Revit links are visible. In the export settings of the NWC exporter, this option is enabled. Has this something to do with the ā€œoptions = NavisworksExportOptions()ā€ line?

Thanks in advance!

Suspect so. Is it giving you a ā€˜Thereā€™s nothing to exportā€™ error?

Default is NavisworkExportOptions.ExportLinks = False, so that is the setting you will get from a new instance:

http://revitapisearch.com.s3-website-us-east-1.amazonaws.com/html/8a8483f0-b8b8-219e-1bcd-e26833495ba8.htm

You could set options.ExportLinks = True after the options.ExportScope = line.

1 Like

It worked, thank you!

Will this principle also work for the external IFC exporter add-in from Autodesk?

Not sure. The interfaces are not the same.

There is access to IFC Export through the API, and thereā€™s an IFCExportOptions with a FilterViewId property:

http://www.revitapidocs.com/2017/b90adabd-0502-fb8f-3a0d-bfa412393f61.htm

I havenā€™t tried it, so Iā€™m not sure if the IFC API is different with the plug-in installed?

how to do the reverse task? Navisworks to Revit?

For that youā€™ll need Navisworks API I think. See what is in the dynaworks package thoigh.

it did not work unfortunately, the nodes not working unknown reason in this package