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
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:
- 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 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!
@Konrad_K_Sobon thanx a lot for your advice
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:
You could set options.ExportLinks = True after the options.ExportScope = line.
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