Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.

Revit API Forum

Reply
Enthusiast pfk
Post 1 of 8
Accepted Solution

Start transaction not working with Revit 2014

2766 Views, 7 Replies
04-21-2013 10:26 PM

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

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

Post 2 of 8

Re: Start transaction not working with Revit 2014

04-22-2013 04:41 AM in reply to: pfk

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

Enthusiast pfk
Post 3 of 8

Re: Start transaction not working with Revit 2014

04-22-2013 05:49 AM in reply to: ollikat

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

Post 4 of 8

Re: Start transaction not working with Revit 2014

04-22-2013 08:25 AM in reply to: pfk

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

Arnošt Löbel
Enthusiast pfk
Post 5 of 8

Re: Start transaction not working with Revit 2014

04-22-2013 03:39 PM in reply to: arnostlobel

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

Post 6 of 8

Re: Start transaction not working with Revit 2014

04-23-2013 07:49 AM in reply to: pfk

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

Arnošt Löbel
Post 7 of 8

Re: Start transaction not working with Revit 2014

05-23-2013 01:07 PM in reply to: arnostlobel

So how do we fix this problem?  I have the same issue

Post 8 of 8

Re: Start transaction not working with Revit 2014

05-24-2013 12:33 PM in reply to: J.Bish
I am afraid you cannot. Since the Revit API cannot be used in a perspective views (it never been able to, and it is documented), and since the API cannot be invoked outside of the main thread in Revit (has always been this limited, and it is documented), the scenarios mentioned above are not technically supported. We have may be able to allow the API in perspective views in the future; unfortunately it is not as simple as turning On a flag somewhere, so I cannot give any time estimates.

Thank you

Arnošt Löbel
Autodesk Revit R&D
Arnošt Löbel
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post

Revit Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Revit helps you achieve greater speed, accuracy, and automation from concept to manufacturing.