Skip to main content

revit-api-option-handlers

Supply small Autodesk Revit API callback interfaces with Nice3point.Revit.Toolkit ready-made handlers, not hand-rolled classes. USE FOR: passing IFamilyLoadOptions, IDuplicateTypeNamesHandler, or ISaveSharedCoordinatesCallback to a Revit API call. DO NOT USE FOR: constraining what a user can pick in an interactive selection, or building a dockable pane's UI element.

설치로 이동

소스 정보

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

설치 방법

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

소스 파일 검토

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

SKILL.md 표시 중

SKILL.md
소스 지침 · 읽기 전용 미리보기
name
revit-api-option-handlers
description
Supply small Autodesk Revit API callback interfaces with Nice3point.Revit.Toolkit ready-made handlers, not hand-rolled classes. USE FOR: passing IFamilyLoadOptions, IDuplicateTypeNamesHandler, or ISaveSharedCoordinatesCallback to a Revit API call. DO NOT USE FOR: constraining what a user can pick in an interactive selection, or building a dockable pane's UI element.
license
MIT
# Revit API Option Handlers Several Revit API calls demand a small callback interface. `Nice3point.Revit.Toolkit` ships ready implementations with a default behavior and lambda or enum customization. A hand-rolled implementation of the interface is unnecessary. ## When to use - A Revit API call requires `IFamilyLoadOptions`, `IDuplicateTypeNamesHandler`, or `ISaveSharedCoordinatesCallback`. ## Workflow ### Step 1: Family load options ```csharp document.LoadFamily(fileName, new FamilyLoadOptions(), out var family); //overwrite existing types, load from the family document.LoadFamily(fileName, new FamilyLoadOptions(false, FamilySource.Project), out var family); // keep values, load from the project document.LoadFamily(fileName, UIDocument.GetRevitUIFamilyLoadOptions(), out var family); //reuse Revit's interactive prompt ``` The default constructor overwrites the parameter values of existing types; the `(overwrite, FamilySource)` constructor sets those explicitly, and `UIDocument.GetRevitUIFamilyLoadOptions()` defers to Revit's own dialog. ### Step 2: Duplicate type names handler ```csharp var options = new CopyPasteOptions(); options.SetDuplicateTypeNamesHandler(new DuplicateTypeNamesHandler()); //default: UseDestinationTypes options.SetDuplicateTypeNamesHandler(new DuplicateTypeNamesHandler(DuplicateTypeAction.Abort)); //fixed action options.SetDuplicateTypeNamesHandler(new DuplicateTypeNamesHandler(args => DuplicateTypeAction.Abort)); // decide per call ``` The default constructor keeps the destination types; pass a `DuplicateTypeAction` for a fixed action, or a lambda that returns the action per call from the `args`. ### Step 3: Save shared coordinates callback ```csharp linkType.Unload(new SaveSharedCoordinatesCallback()); //default: SaveLinks linkType.Unload(new SaveSharedCoordinatesCallback(SaveModifiedLinksOptions.DoNotSaveLinks)); //fixed option linkType.Unload(new SaveSharedCoordinatesCallback(link => //decide per link { if (link.AttachmentType == AttachmentType.Overlay) return SaveModifiedLinksOptions.SaveLinks; return SaveModifiedLinksOptions.DoNotSaveLinks; })); ``` The default constructor saves the links; pass a `SaveModifiedLinksOptions` value for a fixed choice, or a lambda that returns the option per link. ### Step 4: Verify Call the API with the handler and confirm the intended behavior applies — the family loads with the chosen source, the duplicate resolves as selected, or the link unloads with the chosen coordinate option. ## Validation - [ ] The callback uses the Toolkit handler, not a hand-rolled interface implementation. - [ ] Customization is expressed with the lambda or enum overload, not a new class. - [ ] The selected default behavior matches the operation's requirement. ## Common Pitfalls | Pitfall | Correct approach | |--------------------------------------------------------------|---------------------------------------------------------------------| | Writing a class that implements `IDuplicateTypeNamesHandler` | Use `DuplicateTypeNamesHandler` with a lambda returning the action. | | `FamilyLoadOptions` not found | The `Nice3point.Revit.Toolkit` package is not referenced. |
GitHub에서 보기