You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
An external event created outside an add-in callback runs its handler with no active add-in #134
A Toolkit external event runs its handler as the add-in that uses it, wherever the event is first created.
ExternalEventHandler creates the Revit ExternalEvent inside RevitContext.BeginApiContextScope(), which opens the call depth scope and no add-in data scope.
Revit records the active add-in when ExternalEvent.Create runs, and runs the handler as that add-in.
Outside an add-in callback, such as in a WPF event handler of a modeless window, in a dispatcher callback, or on a thread-pool thread, no add-in is active.
A generated [ExternalEvent] property creates its event on the first access, so the first caller decides the add-in of every later raise.
Steps to reproduce
Create a schema with SetVendorId("Contoso"), public read access, and vendor write access.
In a session whose add-in has the vendor Contoso, create an AsyncRequestExternalEvent<string> whose handler reads UIApplication.ActiveAddInId and writes an entity of the schema to a new document.
Create the event in four places and raise it.
✔️ Expected Behavior
The handler runs as the add-in in every case, and the write succeeds.
❌ Actual Behavior
The event is created
Raised from
ActiveAddInId in the handler
Write
Inside an add-in callback on the Revit thread
The same callback
The add-in
Written
Inside an add-in callback on the Revit thread
A thread-pool thread
The add-in
Written
On a thread-pool thread
The same thread
null
InvalidOperationException: "Writing of Entities of this Schema is not allowed to the current add-in."
In a Dispatcher.InvokeAsync callback on the Revit thread
The same callback
null
The same exception
Environment
Revit 2025, Nice3point.Revit.Toolkit 2025.2.3, Nice3point.TUnit.Revit 2025.1.8 with RevitClient(VendorId = "Contoso"), a RevitApiUiTest.
Activity