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

Navisworks Export

12 REPLIES 12
SOLVED
Reply
Message 1 of 13
travis_cadnetics
4365 Views, 12 Replies

Navisworks Export

I was writting a addin that would export a NWC File to the location and file based on 2 parameters.


The actual code to export was working fine in 2014, but when built the code for 2015 the NWC export pop up dialog just hangs.


Is anyone aware of any changes the Document.Export() method that would make this not work on the newer version?

Tags (1)
12 REPLIES 12
Message 2 of 13

Hello tjohnson,

 

I tried on both 2014 and 2015 rebuilt a small piece of code to do an export to NWC, both of them work, can you provide what you are trying to check it out ? also at the beginning I noticed that my Revit 2015 didn't have the export functionality available but I fixed that and after that the popup dialog does what it's supposed to and everything works fine.


Looking forward to hear from you so I can help.

 

Cheers,



Jaime Rosales D.
Sr. Developer Consultant
Twitter | AEC ADN DevBlog
Message 3 of 13

The standard 2015 Exporter works from my Revit fine.

 

Here is trimmed code that I tried to get to work with no luck. It just hangs.

 

#region Namespaces
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;


#endregion

namespace ExportNWC
{
    [Transaction(TransactionMode.Manual)]
    public class Command : IExternalCommand
    {
        public Result Execute(
          ExternalCommandData commandData,
          ref string message,
          ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument uidoc = uiapp.ActiveUIDocument;
            Application app = uiapp.Application;
            Document doc = uidoc.Document;
       
         //create NWExportOptions
            NavisworksExportOptions nweOptions = new NavisworksExportOptions();
            nweOptions.ExportScope = NavisworksExportScope.Model;
            nweOptions.ViewId = uidoc.ActiveView.Id;

            // Modify document within a transaction

            using (Transaction tx = new Transaction(doc))
            {
                tx.Start("Export");
                
               doc.Export(@"D:\Shared",@"test.nwc", nweOptions); 
              
                tx.Commit();
            }

            return Result.Succeeded;
        }
    }

}

 

Message 4 of 13

I admit I am not very familiar with the implementation of the latest version of Navis Exported, but I am fairly familiar with the code the exported depends on. I'll make two suggestions that may (but may not) help:

  • I believe transaction should not be needed. I am basing this on the fact that that underlying export code does not need one. However, it is possible (though strange) that the Navis exporter would require transaction for changes it may make to the mode.
  • I think the export works for 3D views only, but I suppose the Active one already is a 3D (otherwise I would expect an exception to be thrown).
  • Naturally, both ActiveDocument and ActiveView may be null and should be checked, but that is probably not the problem here,

TJohnson, you reported that Revit hangs with a dialog up. What kind of dialog is that?

Arnošt Löbel
Message 5 of 13
rosalesduquej
in reply to: arnostlobel

Hi TJohnson, 

 

As my colleague Arnost Lobel said, Transaction might not be needed, I tested your code and removing it makes the exporter work, can you please try it and let us know if you are good to go. Arnost the dialog is the one launched by Revit when the Document.Export call uses for the NWC file to be created. 

 

Here is how your code looks now. 

 

Snippet

      UIApplication uiapp = commandData.Application;
      UIDocument uidoc = uiapp.ActiveUIDocument;
      Application app = uiapp.Application;
      Document doc = uidoc.Document;

      //create NWExportOptions
      NavisworksExportOptions nweOptions = new NavisworksExportOptions();
      nweOptions.ExportScope = NavisworksExportScope.Model;
      nweOptions.ViewId = uidoc.ActiveView.Id;
      
      doc.Export(@"D:\Shared"@"test.nwc"nweOptions);
      
      return Result.Succeeded;


Jaime Rosales D.
Sr. Developer Consultant
Twitter | AEC ADN DevBlog
Message 6 of 13

That worked.

 

So something must have changed in the transaction class? The Export worked in 2014 inside of the transaction.

 

Either way, doesnt matter to me.


Thank you very much!

Message 7 of 13
arnostlobel
in reply to: rosalesduquej

I am still puzzled by the possible presence / appearance of a dialog during an export to Navis. Jaime, you said: “The dialog is the one launched by Revit when the Document.Export call uses for the NWC file to be created”. However, the file to export to is given to the Export method (second argument) together with the output folder and options. From those arguments Revit should have all information to proceed with the export withouth any interaction. I reached out to the group who implemented Export to Navis and they confirmed to me that there should indeed be no dialog popping up during an export. At least in R2015 there should not be one. Can you post a snapshot of the dialog?

 

Thank you

Arnošt Löbel
Message 8 of 13

Its not a dialog that is interactable by the user. Its more of a progress dialog that shows you the amount of items exported out of the total items.

 

See attached screen shot.

 

Navis_Export.PNG

Message 9 of 13

Thank you, tjohnson, for the added information about the "mistery" dialog. According to the Navis development team the progress dialog is expected to show up, thus everything works as it should. Although I personally would preffer if the dialog was not shown the way it is and I will keep looking into that, I consider the issue discussed here in this thread resolved.

 

Thank you for your contribution.

Arnošt Löbel
Message 10 of 13

As a user, I prefer the dialog box, as it lets me know that everything is exporting properly.

 

From a API Standpoint I think not having the dialog can be good, but maybe its part of the Export Options, so you can choose to implement it with or without the dialog box.


Travis

Message 11 of 13

Removal of the appearance of the dialog during API Export calls is being discussed (here at the Revit R&D) and I hope it will be done. The thing is that the progress dialog has no place to be shown when the Export method is invoked via the API, for it is part of Revit DB functionality by being a method of the DB Document class. I understand the possible need for setting it an option of the Export method, but making that available would mean the Export method would have to be moved to UIDocument. None of the methods of the Document class should have any interaction with the end user via the UI - that comes from the definition and purpose of the Document class.

 

However, just to make things clear, the progress dialog will remain to work as it is now when exporting to Navisworks is initiated via the Export to Navisworks command in Revit UI.

Arnošt Löbel
Message 12 of 13
Anonymous
in reply to: rosalesduquej

Hi rosalesduquej.

 

I am using the  NavisworksExportOptions()  in my exporter, but ind this class i missing 3 options the default export has.

 

Faceting Factor

Convert linked Cad formats

Convert lights

 

Can you explain how I can add these features to my exporter?

 

Best regards
AWPE

Message 13 of 13
jmontesAQHPH
in reply to: Anonymous

Yes the same happens to me.

Did you solve it?

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community