Community
Navisworks API
Welcome to Autodesk’s Navisworks API Forums. Share your knowledge, ask questions, and explore popular Navisworks API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Not able to export dwf file using ExportAsDwf

13 REPLIES 13
Reply
Message 1 of 14
krantichandra
1664 Views, 13 Replies

Not able to export dwf file using ExportAsDwf

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.

13 REPLIES 13
Message 2 of 14

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

Message 3 of 14

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();

        }
    }
}

 


  

 

 

 

Message 4 of 14

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.

Message 5 of 14

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;

 

Message 6 of 14

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.

Message 7 of 14

just got a reply that this is a problem becasue .NET control should support ExportAsDwf. Sorry.

 

Message 8 of 14

Thanks for your reply.

 

But how can I solve this. Any solution ?

Is this API ( i.e ExportAsDwf ) working in your environment ?

 

 

Message 9 of 14

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.

Message 10 of 14
JohnHon
in reply to: xiaodong_liang

Hi Xiaodong,

 

Does ExportAsDWF still not work now?

 

Thanks,

John

Message 11 of 14

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

Message 12 of 14
andgonro
in reply to: JohnHon

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?

Message 13 of 14
cgs1809
in reply to: krantichandra

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.

Message 14 of 14
naveen.kumar.t
in reply to: cgs1809

Hi @cgs1809 ,

 

Could you please explain what error message you are getting?
Could you please explain your issue in detail?
Could you please also tell me which Navisworks Version you are using?


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


Autodesk Design & Make Report