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.

Informações da origem

Repositório
Nice3point/revit-skills
Última atividade na origem
7 de outubro de 2026 às 21:21
Idioma detectado do SKILL.md
inglês
Estrelas
16
Forks
3

Opções de instalação

Por padrão, está selecionado o prompt que primeiro revisa a origem. Você pode mudar para um comando direto ou baixar uma cópia local.

Revise os arquivos de origem

Leia o SKILL.md e os arquivos complementares exibidos pelo SkillsMP antes de decidir se vai instalar.

Exibindo SKILL.md

SKILL.md
Instruções da origem · Visualização somente leitura
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` provides 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); // preserve 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 both options explicitly, and `UIDocument.GetRevitUIFamilyLoadOptions()` shows 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)); // select the action per call ``` The default constructor uses 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 => //select the option 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 option, 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. |
Ver no GitHub