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


#1

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?.


#2

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

#3

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


#4

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

@Konrad_K_Sobon thanx a lot for your advice :slight_smile:


#6

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"


#7

yes! That’s correct. Thank you


#8

And a final addition is to import the Revit API:

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

#9

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!


#10

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.


#11

It worked, thank you!

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


#12

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?