Hi
I have a plugin which works fine with Revit 2012 and 2013. On Revit 2014, the call to Transaction.Start throws an exception "Starting a transaction from an external application running outside of API context is not allowed.". Has something changed between Revit 2013 and 2014 that does not allows transactions from plugin?
Thanks
Solved! Go to Solution.
Solved by pfk. Go to Solution.
Solved by ollikat. Go to Solution.
Hi
Maybe it's related to this comment in "What's new" section in 2014 API documentation:
No transactions from outside threads
Calling into the Revit API from outside threads and outside modeless dialogs has never been supported, but it was not strictly prohibited, meaning there would be no immediate exceptions when someone tries to modify model from outside of the supported API workflows. That has been changed. It is no longer possible to start a transaction unless the caller is inside a legitimate API call, such as an external command, event, updater, call-back, etc. An exception will be thrown if such attempt is made
Yes - that would appear to be the issue.
Given this new restriction, I do not understand how you could open a transaction whilst a 3d perspective window is open, because the idler event does not get sent when in these views, nor are external commands available. So many plugins which use the 3d perspective view will simply not work anymore.
Paul
It is not a new restriction per se. Calling from an outside thread (including external modeless dialogs) has never been supported in Revit unless the API calls are made from a handler of an Idling event (since 2012) or External Event (since 2013). Both approaches are well documented in SDK samples – Look for ModelessDialog in the Samples Folder. External Events are particularly useful in modeless dialogs. They allow a clean, safe, and easy workflow.
However, you are correct about calling the API while the active view is Perspective. That has never been allowed, and, in fact, most Revit internal commands are disabled in that mode too. There is a task open for enabling the API in Perspective and we hope to make it happen as soon as we figure out a reasonably safe way. It is not as trivial as it may sound. I am sorry for that.
Arnošt Löbel
Autodesk Revit R&D
Thanks Arnošt
I appreciate the detailed reply, and understand the situation. In general I think users do not want to loose functionality when going to the next release of a product, so perhaps this restriction could have be bought in AFTER the API had been enabled in the Perspective view.
Paul
Hello Paul,
While I understand your frustration over the limitation, we did not really have a choice. Like I said, the workflow was never supported nor recommended. It was a bit of an oversight on our side not to put in the restriction a few releases earlier, even though we have always documented and advocated the correct approach. Over the last few years we have found too many a document corrupted and Revit session abruptly terminated, and in most if not all of such cases our investigation lead us to external addins accessing the API when they were not supposed to do so. Such attempts are always risky and down plain dangerous when outside transactions are started. While we understand that our decision might frustrate a few developers, we honestly believe it was a decision for the better and that most end-users will benefit from it rather than suffer.
Thank you for your understanding
Arnošt Löbel
Autodesk Revit R&D
Can't find what you're looking for? Ask the community or share your knowledge.