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
- New **RevitContext** class for UI-level application context access
6
-
- New **RevitApiContext** class for database-level application context access
7
-
- New **AsyncExternalCommand** class for async/await support in external commands
8
-
- New **BeginDialogSuppressionScope()** method with disposable pattern for dialog suppression
9
-
- New **BeginFailureSuppressionScope()** method with disposable pattern for failure handling
10
-
- New **BeginAssemblyResolveScope()** method with disposable pattern for dependency resolution
11
-
- New **BeginAssemblyResolveScope(string directory)** overload for explicit path specification
12
-
- New **SetExceptionHandler()** method for `ActionEventHandler` and `IdlingEventHandler`
13
-
- New **CancellationToken** support for `AsyncEventHandler` and `AsyncEventHandler<T>`
14
-
- New overloads for `BeginDialogSuppressionScope()`: `MessageBoxResult`, `TaskDialogResult`, custom handler
5
+
New family of external event types replacing legacy `ActionEventHandler`, `AsyncEventHandler`:
6
+
7
+
-**ExternalEvent** — synchronous external event that queues the handler via the Revit external event mechanism.
8
+
-**ExternalEvent\<T>** — generic synchronous external event that accepts an argument of type `T`.
9
+
-**AsyncExternalEvent** — asynchronous external event with `RaiseAsync()` that returns a `Task`.
10
+
-**AsyncExternalEvent\<T>** — generic asynchronous external event with argument support.
11
+
-**AsyncRequestExternalEvent\<TResult>** — asynchronous external event that returns a result via `RaiseAsync()`.
12
+
-**AsyncRequestExternalEvent\<T, TResult>** — generic asynchronous external event with argument and result support.
13
+
-**ExternalEventOptions** — configuration flags for event behavior, including `AllowDirectInvocation` for direct execution in API context.
14
+
15
+
Events do not need to be created inside the Revit API context — the Toolkit handles initialization automatically, so you can create them anywhere in your code and on any thread.
16
+
17
+
### ExternalEvent Source Generator
18
+
19
+
New `[ExternalEvent]` attribute with incremental source generator that eliminates boilerplate for defining external events.
20
+
Annotate a method in a partial type and the generator produces typed event properties automatically:
// public IExternalEvent DeleteWindowsEvent => field ??= new ExternalEvent(DeleteWindows);
44
+
// public IAsyncExternalEvent DeleteWindowsAsyncEvent => field ??= new AsyncExternalEvent(DeleteWindows);
45
+
```
46
+
47
+
Source generator supports multiple parameters, methods with extra parameters like `private void DeleteWindows(string arg1, int arg2, bool arg3)` also work.
48
+
49
+
**Generator capabilities:**
50
+
51
+
-`void` methods → generates both `IExternalEvent` and `IAsyncExternalEvent` properties.
52
+
- Methods returning a value → generates `IAsyncRequestExternalEvent<TResult>` property.
53
+
- Methods with extra parameters → generates typed `IExternalEvent<T>` / `IAsyncExternalEvent<T>` properties.
54
+
- Methods with 2+ extra parameters → generates a `sealed record` for argument bundling with convenience extension methods.
0 commit comments