Export NWC By Python

dears;
i am trying to export nwc from Revit by below Script, i have problem that the Navisworks export Dialogue just popup without any export progress.


Please post an actual code. I doubt anyone wants to re-type your code just so they can debug it for you.

1 Like
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

import System

import math

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

coll = FilteredElementCollector(doc).OfClass(ProjectLocation)

output = []
path = IN[0]
name = IN[1]

TransactionManager.Instance.EnsureInTransaction(doc)
activeView = uidoc.ActiveView.Id 
scope = Autodesk.Revit.DB.NavisworksExportScope().View
Options = Autodesk.Revit.DB.NavisworksExportOptions()



doc.Export(path,name,Options)

TransactionManager.Instance.TransactionTaskDone()

doc.Regenerate()
OptionalFunctionalityUtils.IsNavisworksExporterAvailable()
#OUT = dir(Autodesk.Revit.DB.NavisworksExportOptions.ExportScope)
OUT = Autodesk.Revit.DB.NavisworksExportOptions().ViewId

i figure it out:

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
# Import geometry conversion extension methods
clr.ImportExtensions(Revit.GeometryConversion)
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *

import System

import math

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

coll = FilteredElementCollector(doc).OfClass(ProjectLocation)

output = []
path = IN[0]
name = IN[1]
#path = Autodesk.Revit.DB.FilePath(pathName)
Options = Autodesk.Revit.DB.NavisworksExportOptions()
Options.ExportScope = NavisworksExportScope.View
Options.ViewId = uidoc.ActiveView.Id
doc.Export(path,name , Options)
TransactionManager.Instance.EnsureInTransaction(doc)



TransactionManager.Instance.TransactionTaskDone()
doc.Regenerate()
#OUT = dir(Autodesk.Revit.DB.NavisworksExportOptions.ExportScope)
OUT = 0
1 Like

Hello just making you aware that NWC exports are or should use 3D views…i will post code later but is this your intention? Also its best to create a new topic and link this topic coz this was already tagged solved by the OP.

Did you ever figure this code out? Im looking to be able to Input a certain view name and export it. Can you help?

Try this as an alternative…

https://forum.dynamobim.com/t/export-a-list-of-revit-3d-views-into-nwc-through-python/12953/3

Just follow and try…

I tried that and its not quite what im looking for. I have a script that will create a section box at each level and create a new 3d view. I just want to be able to choose certain views to export without having to rename them.

Ok no probs i will create one with selected views input tomorrow and will post on the above topic and NOT to this one coz this is already mark as solved by the OP.

I started a form on it. Sorry if this was done and is repetitive.

Ok will reply to both topic then…unless others beat me to it til tomorrow…

1 Like

By the way…i am not trying to change the way you do things…but in future having “navis” or “navisworks” on your view name will be recommended (the ones you want to export to nwc) Also if you have made so far creating views with their names via dynamo adding “navis” on the name is not going to be hard? Or does it?

Til tomorrow

1 Like

Your right it wouldn’t be hard but i get alot of files with pre-made viewpoints from coworkers and if i could just select the view instead of renaming it and then running the script that would be ideal.

1 Like

Hi everyone! I Want to know if someone knows how can I solve this problem that appears every time that I try to export a 3D from revit to a nwc file.

1 Like