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.
Solved! Go to Solution.
Solved by jeremytammik. Go to Solution.
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,
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.
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.
The latter is cleaner and more elegant.
That is exactly what Arnošt is suggesting as well.
I hope this helps.
Best regards,
Jeremy
Can't find what you're looking for? Ask the community or share your knowledge.