Hi ,
I am trying to export dwf file using API ExportAsDwf. But its crashing while executing & getting below crash report
An unhandled exception of type 'System.InvalidOperationException' occurred in autodesk.navisworks.api.dll
Additional information: The Plugin was not found
Am I missing anything ?
I am using trial version of NavisWork Manage 2012 . Through application I am able to export to DWF but not through API.
Please help.
Hi,
The method works well at my Manage 2012. Can you export it to dwf by UI? If not, I suspected the related plugin is broken. You would need to repair Manage to see if it helps.
Regards,
Xiaodong Liang
Developer Technical Services
Hi
Thanks for reply.
I am able to export NWD file to DWF from UI. But not through API
Below is my code snippet I am trying.
using System; using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using Autodesk.Navisworks.Api; using Autodesk.Navisworks.Api.Plugins; using Autodesk.Navisworks.Api.Controls; using Autodesk.Navisworks.Api.DocumentParts; using System.Text; namespace WindowsFormsApp { static class Program { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main() { //Set to single document mode Autodesk.Navisworks.Api.Controls.ApplicationControl.ApplicationType = ApplicationType.MultipleDocument; Autodesk.Navisworks.Api.Controls.ApplicationControl.RequestedRuntime = RuntimeNames.NavisworksManage; //Initialise the api Autodesk.Navisworks.Api.Controls.ApplicationControl.Initialize(); DocumentControl DocControl = new DocumentControl(); if (DocControl.Document.TryOpenFile(@"D:\\kranti\\Project\\NavisWork\\api\\net\\examples\\Basic Examples\\ice stadium.nwd")) { DocControl.SetAsMainDocument(); PluginRecord pluginTest = Autodesk.Navisworks.Api.Application.Plugins.FindPlugin("NativeExportPluginAdaptor_LcDwfExporterPlugin_Export.Navisworks"); if (Autodesk.Navisworks.Api.Application.ActiveDocument.IsClear == false) Autodesk.Navisworks.Api.Application.ActiveDocument.ExportAsDwf("D:\\kranti\\test.dwf"); } /* //create the published NWD try { Autodesk.Navisworks.Api.Application.ActiveDocument.PublishFile(@"C:\publishedFile.nwd", properties); } catch (Autodesk.Navisworks.Api.DocumentFileException) { //Failed to publish ile, perhaps try saving in //an alternate location using the exception safe method if (!Autodesk.Navisworks.Api.Application.ActiveDocument.TryPublishFile(@"C:\publishedFile2.nwd", properties)) { MessageBox.Show("Failed to publish the file"); } } catch (System.InvalidOperationException) { MessageBox.Show("Document is clear"); }*/ //Dispose of the DocumentControl DocControl.Dispose(); //Finish use of the API. Autodesk.Navisworks.Api.Controls.ApplicationControl.Terminate(); } } }
I see. you are using multi-documents with document control. Help document says:
SingleDocument Single document application. Only one DocumentControl may be created. A single document application supports rendering with Presenter materials and a full range of file readers.
MultipleDocument Multiple document application. Any number of DocumentControls may be created. A multiple document application only supports basic materials and Navisworks native file formats.
So, I think this is an unsupported scenario currently.
I have tried using Single document but still its not working.
Do I need to do anything else to make it work?
Autodesk.Navisworks.Api.Controls.ApplicationControl.ApplicationType = ApplicationType.SingleDocument;
hum...It looks .NET control does not support exporting DWF. Sorry. But it is not clear why the SDK sample of 2012 SDIViewer has one menu to export to DWF, which does not work, either.
just got a reply that this is a problem becasue .NET control should support ExportAsDwf. Sorry.
Thanks for your reply.
But how can I solve this. Any solution ?
Is this API ( i.e ExportAsDwf ) working in your environment ?
I meant this is a problem which has been reported to our engineer team. I do not know when it will work. What I can think of is to use automation (calling a plugin which do ExportAsDwf) in your application of control, but i cannot gurantee it would work.
Hi Xiaodong,
I'm running into this problem in Navisworks 2018, is it solved in Navisworks 2019 or Navisworks 2020?
I am using automation that calls a plugin which uses ExportAsDwf, but keep receiving this error when trying to call "doc.ExportAsDwf(); ":
Exception thrown: 'System.InvalidOperationException' in Autodesk.Navisworks.Api.dll
Thanks,
Matt
I am also encountering the same issue with Navisworks Manage 2021.
Is there are solution to make this work
Autodesk.Navisworks.Api.Application.ActiveDocument.ExportAsDwf(@"C:\myfile.dwf")
or is there any plan to fix it in future version?
Hi @xiaodong_liang
Do you have any news regarding this topic? I am also tried to export to DWF using the API. But Autodesk.Navisworks.Api.Application.ActiveDocument.ExportAsDwf doesn't work for me.