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: 

Help: Navisworks Export and transaction manual started.

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Anonymous
745 Views, 3 Replies

Help: Navisworks Export and transaction manual started.

Hello all,

 

I am writting a addin that would export a NWC File, i using the the NavisworksExportOptions() class and the Document.Export Method (String, String, NavisworksExportOptions) to make my export.

 
In my code I start a transaction manually, because I am making some changes in the Revit database before export. These changes should not be saved to the Revit database after the NWC Export.
 
When I make the NWC export, with a manually started transaction nothing happens :-(. no error code.....only nothing happens.
 
Is there someone who can fix the problem????
 
NB: Can see there are others with the same problem. http://forums.autodesk.com/t5/revit-api/navisworks-export/td-p/5345767
 
3 REPLIES 3
Message 2 of 4
rosalesduquej
in reply to: Anonymous

Hi,

 

Could you provide a minimum sample of your code. It will be easier to test it and find what is happening with your code. 

Also recalling the post you mentioned. Check again the solution that is marked on that post. Also if you are making changes in the Revit DB try to commit your transaction and then do the export. As Arnost mentioned "I believe transaction should not be needed. I am basing this on the fact that that underlying export code does not need one.

 

Try it and get back to me. 

Cheers,



Jaime Rosales D.
Sr. Developer Consultant
Twitter | AEC ADN DevBlog
Message 3 of 4
arnostlobel
in reply to: Anonymous

hi awpe,

 

I do not know why the Navisworks export hangs; that exporter was not written by us Revit folks; we only incorporated it with the API. By the way, I have already reported the problems regarding this exporter. It will be looked at in due time.

 

That being said, though, I can still help you with your case, I think. Obviously, the Navisworks exporter does not work with an open transaction (and in fact it should not work - that part is correct - but it should not hang, of course.) Fortunately, is is perfectly possible to make your changes before exporting the model, and roll them back after you finish the export. It is when transaction groups come handy. I'll outline the concept in the following pseudo-code:

 

using (TransactionGroup tg = new TransactionGroup(doc))
{
   tg.Start();

   using (Transaction tr = new Transaction(doc, "temporary"))
   {
       tr.Start();
       changeModelPriorExporting(doc);   // here you make your changes
       tr.Commit();

   }

   doc.Export(folder, file, options);

   tg.RollBack();    // this undoes the already committed transaction 
}

I left out error handling to make the snippet as simple as possible. I hope the sample makes sense.

Arnošt Löbel
Message 4 of 4
jeremytammik
in reply to: Anonymous

Dear Awpe,

 

Thank you for your query, and thanks to Jaime and Arnost for their contributions.

 

As far as I can tell from the previous thread that you point to, the NavisWorks export must be launched with no active transaction.

 

Having an open transaction causes problems, so you definitely should avoid that situation.

 

You say that you need to apply certain modifications to the project before exporting, though, and you wish to cancel these without saving.

 

This obviously requires a transaction after all.

 

So how can you open a transaction to make the required modifications and still run the export with no open transaction?

 

I see two possibilities to achieve what you need and still run the export method after the transaction has been closed.

 

  1. Start a transaction, apply your changes, commit and close the transaction, export to NavisWorks, and then close the project document without saving.

 

  1. Start a transaction group, start a transaction, apply your changes, commit and close the transaction, export to NavisWorks, and then cancel the transaction group.

 

The latter is cleaner and more elegant.

 

That is exactly what Arnošt is suggesting as well.

 

I hope this helps.

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

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

Post to forums  

Autodesk Customer Advisory Groups


Rail Community