Skip to main content

revit-context-access

Access the Autodesk Revit database application through RevitApiContext or an active UI session through RevitContext from Nice3point.Revit.Toolkit, and suppress dialogs. USE FOR: reading Application, the current UiApplication/ActiveDocument/ActiveView without a commandData, or suppressing TaskDialog and message boxes with BeginDialogSuppressionScope. DO NOT USE FOR: suppressing expected Revit warnings and failures during a transaction.

설치로 이동

소스 정보

저장소
Nice3point/revit-skills
최근 소스 활동
2026년 7월 23일 12:21
감지된 SKILL.md 언어
영어
스타
13
포크
3

설치 방법

기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.

소스 파일 검토

설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.

SKILL.md 표시 중

SKILL.md
소스 지침 · 읽기 전용 미리보기
name
revit-context-access
description
Access the Autodesk Revit database application through RevitApiContext or an active UI session through RevitContext from Nice3point.Revit.Toolkit, and suppress dialogs. USE FOR: reading Application, the current UiApplication/ActiveDocument/ActiveView without a commandData, or suppressing TaskDialog and message boxes with BeginDialogSuppressionScope. DO NOT USE FOR: suppressing expected Revit warnings and failures during a transaction.
license
MIT
# Revit Context Access ## When to use - Reading the database-level `Application`. - Reading the active document, UI application, or view from a service, helper, or window in a UI session. - Suppressing predictable dialogs for a bounded operation. ## When not to use - Inside an external command or application, where the base class already exposes the context — use `revit-command-and-application`. - Suppressing failures or warnings during a transaction — use `RevitApiContext.BeginFailureSuppressionScope`. ## Workflow ### Step 1: Read database-level context without a UI session Use `RevitApiContext` for database-level access. ```csharp var application = RevitApiContext.Application; ``` ### Step 2: Read UI-session context Use `RevitContext` for UIApplication, document, and view access only when a UI session is available. ```csharp var uiApplication = RevitContext.UiApplication; var document = RevitContext.ActiveDocument; var view = RevitContext.ActiveView; ``` ### Step 3: Suppress dialogs for a bounded operation ```csharp using (RevitContext.BeginDialogSuppressionScope(TaskDialogResult.Ok)) { LoadFamilies(); } ``` Overloads accept a result code, a `TaskDialogResult`, a `MessageBoxResult`, or a custom handler that overrides the result. ### Step 4: Verify Confirm database-only code accesses `RevitApiContext` without calling the `RevitContext`. ## Validation - [ ] Tests and Design Automation access the database-level application through `RevitApiContext.Application`. - [ ] UI-session access uses `RevitContext`, and nullable reads (`ActiveDocument`, `ActiveView`) are guarded. - [ ] Dialog suppression is scoped to the operation that raises the dialog. ## Common Pitfalls | Pitfall | Correct approach | |-------------------------------------------------------|-----------------------------------------------------------| | Using `RevitContext` in a test or Design Automation | Use `RevitApiContext`; it does not require a UI session. | | Assuming `RevitContext.ActiveDocument` is non-null | It is nullable; guard when no document is open. | | Suppressing a transaction failure with a dialog scope | Use `RevitApiContext.BeginFailureSuppressionScope`. | | `RevitContext` not found | The `Nice3point.Revit.Toolkit` package is not referenced. |
GitHub에서 보기