revit-wpf-template icon indicating copy to clipboard operation
revit-wpf-template copied to clipboard

Transactions Impossible?

Open RyanDaley opened this issue 1 year ago • 2 comments

I am writing new methods in the Methods.cs class. Everything works fine until I try to use a transaction to make a change to the active document. I can't get transactions to work at all. Are transactions not possible from a plugin?

RyanDaley avatar Oct 23 '22 18:10 RyanDaley

image

RyanDaley avatar Oct 23 '22 18:10 RyanDaley

Transactions are possible from a plugin, but they have to happen in a valid Revit API context.

Here is an example method using a transaction in this template

And here is how that same method is invoked from the WPF UI.

Most of the work is done by the RevitEventWrapper which basically just ensures the transaction happens in a "valid Revit API context".

mitevpi avatar Oct 24 '22 07:10 mitevpi