Hi all, I have a script to export a selected view to Navisworks and everything works great when I use it on the active document. I now have the need to export models on a regular basis. All of these models happen to be a link and I figured I would alter the script from active doc to linked doc.
When I ran it I got no warning but rather than getting an nwd I go a .log file with the following.
Autodesk.Revit.Exceptions.InvalidOperationException: Document is a linked file. Transactions can only be used in primary documents (projects or families.)
at Autodesk.Revit.DB.Transaction.Commit()
at NavisWorks19.LcIRevitBase.ExportDocument(String& return_message, ElementSet elements, LcIRevitParameters* params)
My script does not have a transaction so I am guessing the API call has one built in.
I know that I could export a view from the active doc containing linked element (I think at least) but I am hoping to use a view that was set up in each of the linked files. Has anyone else had luck with this before?
This is the code I wrote if anyone wanted to take a look.
def export(doc,name,settings,view,folder):
#settings is a dictionary object containing all of the user-specified settings.
options = NavisworksExportOptions()
options.ConvertElementProperties = settings['ConvertElementProperties']
options.ConvertLights = settings['ConvertLights']
options.ConvertLinkedCADFormats = settings['ConvertLinkedCADFormats']
for i in System.Enum.GetValues(Autodesk.Revit.DB.NavisworksCoordinates):
if str(i) == settings['Coordinates']:
options.Coordinates = i
options.DivideFileIntoLevels = settings['DivideFileIntoLevels']
options.ExportElementIds = settings['ExportElementIds']
options.ExportLinks = settings['ExportLinks']
options.ExportParts = settings['ExportParts']
options.ExportRoomAsAttribute = settings['ExportRoomAsAttribute']
options.ExportRoomGeometry = settings['ExportRoomGeometry']
for i in System.Enum.GetValues(Autodesk.Revit.DB.NavisworksExportScope):
if str(i) == settings['ExportScope']:
options.ExportScope = i
if view != None:
options.ViewId = view
options.ExportUrls = settings['ExportUrls']
options.FacetingFactor = settings['FacetingFactor']
options.FindMissingMaterials = settings['FindMissingMaterials']
for i in System.Enum.GetValues(Autodesk.Revit.DB.NavisworksParameters):
if str(i) == settings['Parameters']:
options.Parameters = i
name = Prefix + Deliminator + name + Deliminator + Suffix
doc.Export(folder, name, options)
Thanks for any help you are able to provide.