C# libraries for building Autodesk Inventor add-ins (2024-2027): the plugin and ribbon plumbing, an isolated add-in loader, a WPF shell, logging and typed iProperties. They are the foundation of the commercial add-ins by Bas Automation Services, published here as open source under the MIT licence.
Starting a new add-in? Use the Inventor add-in template. It sets up a solution on these libraries with the layering, tests, installer files and instructions for AI coding agents already in place.
Writing an Inventor add-in means solving the same problems every time:
- Dependency clashes. Inventor loads every add-in into one process. Two add-ins that ship
different versions of the same library (Newtonsoft.Json, Serilog, a WPF control library)
break each other. The Loader gives each add-in its own
AssemblyLoadContext. - Ribbon boilerplate. Button definitions per environment, tabs and panels that may already
exist, icons converted to
IPictureDisp, cleanup on unload. Here you declare aCommandDefinitionand the base class does the rest. - No host. An add-in has no
Program.Main, so no dependency injection, configuration or logging.PluginBasebuilds a .NET Generic Host when Inventor activates the add-in. - Untyped iProperties.
"Design Tracking Properties","Part Number": strings everywhere.InventorPropertyName.PartNumberinstead.
| Project | What it is | References Inventor |
|---|---|---|
BasAutomation.Inventor.Core |
Plugin and ribbon base classes, commands, InventorClient, transactions, progress bars, typed iProperties |
Yes |
BasAutomation.Inventor.Loader |
The COM shim base class and the build targets that load an add-in in its own AssemblyLoadContext |
Yes |
BasAutomation.UI |
WPF: a shell window with page navigation, window/dialog/file services, ViewModelBase, converters, styles |
No |
BasAutomation.Logging |
Serilog setup: one log folder per add-in under %APPDATA% |
No |
BasAutomation.Core |
The few contracts and helpers the others need | No |
Inventor.Core depends on Core, Logging and UI; UI on Core; Core on Logging.
The Loader has no dependencies.
The Inventor add-in template
does all of this for you. By hand: add this repo to your add-in as a git submodule in
Inventor\, and the add-in builds the libraries from source.
git submodule add https://github.com/Bas-Automation-Services/BasAutomation.Inventor Inventor
Directory.Build.propsof the add-in setsInventorRootto$(MSBuildThisFileDirectory)Inventor\andInventorVersion(2024-2027). The libraries import that file when they sit in<add-in>\Inventor\, so they build for the same Inventor.Directory.Packages.propsof the add-in imports$(InventorRoot)Build\Packages.Shared.props, the versions of every package the libraries use, and adds only the add-in's own packages.- Projects that use the Inventor API reference
$(InventorRoot)src\BasAutomation.Inventor.Core\BasAutomation.Inventor.Core.csprojand import$(InventorRoot)Build\Inventor.targets, which adds the interop of the installed Inventor. - The shim references the Loader project and imports
$(InventorRoot)src\BasAutomation.Inventor.Loader\build\Shim.targets; the implementation importsImplementation.targetsfrom the same folder.
To update, move the submodule: git submodule update --remote Inventor.
An add-in is two projects: a tiny COM shim that Inventor loads, and the add-in itself.
The shim (MyAddin.Addin, references BasAutomation.Inventor.Loader):
[ComVisible(true)]
[Guid("A35BF192-8E9E-4596-AEA6-54F645056AE6")] // your add-in's own GUID
public class Plugin : RibbonPluginShim
{
protected override string ImplementationAssemblyName => "MyAddin.Implementation";
protected override string ImplementationTypeName => "MyAddin.Implementation.Plugin";
}The plugin (MyAddin.Implementation, references BasAutomation.Inventor.Core):
public class Plugin : RibbonPluginBase
{
public override string AddInClientId => "A35BF192-8E9E-4596-AEA6-54F645056AE6";
protected override Type GetAppConfigType() => typeof(AppConfig);
// Every CommandDefinition in this assembly goes on the ribbon.
protected override void LoadCommandDefinitions() =>
CommandDefinitions.AddRange(new CommandDefinitionFactory(typeof(Plugin).Assembly).GetCommandDefinitions());
public override void ConfigureServices(HostBuilderContext context, IServiceCollection services)
{
LoggingHelpers.AddLoggingInSubDirectory(services, "MyAddin"); // %APPDATA%\MyAddin\logs
services.AddSingleton<IPartNumberReader, PartNumberReader>();
}
}A command: where it goes on the ribbon, and what it does.
public class PartNumberCommandDefinition : CommandDefinition
{
private static readonly RibbonTabDefinition Tab = new("My Tools");
private static readonly RibbonPanelDefinition Panel = new("Info");
public PartNumberCommandDefinition()
{
RibbonLocations.Add(new RibbonLocation(RibbonEnvironment.Part, Tab, Panel));
RibbonLocations.Add(new RibbonLocation(RibbonEnvironment.Assembly, Tab, Panel));
Command = new PartNumberCommand();
}
public override IInventorButtonCommand Command { get; }
}
public class PartNumberCommand : ServiceAwareButtonCommandBase
{
public override string DisplayName => "Part number";
public override Icon Icon => Resources.PartNumber;
public override bool CanExecute() => InventorClient.HasActiveDocument;
public override void Execute()
{
var doc = InventorClient.GetActiveEditDocument();
MessageBox.Show(doc.GetPropertyValue(InventorPropertyName.PartNumber)?.ToString(), DisplayName);
}
}The template wires all of this up, including the .addin manifests, the app bundle and the
build targets that deploy it to ApplicationPlugins.
Plugin and ribbon
PluginBase: implementsApplicationAddInServer; on activation builds the Generic Host (configuration, DI, logging), callsConfigureServices, and writes an error log if activation fails.RibbonPluginBase: creates tabs, panels and buttons from yourCommandDefinitions, in the environments you list (ZeroDoc,Part,Assembly,Drawing), reusing tabs and panels that already exist, and removes them again on unload.IRibbonPanelOverridetakes over the layout of a single panel.CommandDefinitionFactory: finds everyCommandDefinitionin an assembly.
Commands
ServiceAwareButtonCommandBase: a ribbon button withGetService<T>()andCreateScope()into the add-in's container,CanExecute(),DisplayName,Description,ToolTipandIcon. Exceptions fromExecute()are caught and logged by the ribbon.PictureDispConverter: .NETIcon/Bitmapto theIPictureDispInventor wants.
Talking to Inventor
InventorClient: theApplication, plus helpers:GetActiveEditDocument<T>()(the part being edited in place, not just the active assembly),CreatePart/Assembly/Drawing,OpenModel, default templates,TransientGeometry/TransientObjects,RunRulefor iLogic.- Outside Inventor (console apps, tests):
InventorClient.Connect()attaches to a running Inventor,ConnectOrStart()starts one if needed,ConnectDedicated()starts a private, optionally headless instance so parallel runs don't share a session. InventorTransaction.Wrap(() => ..., doc, "Name"): one undo step for many changes.SilentOperation.Wrap(...): no dialogs during batch work.InventorStatusBarProgressBar,InventorModalProgressBar: Inventor's own progress bars.
iProperties
InventorPropertySetName,InventorPropertyNameand the typedDesignProperties,SummaryProperties,DocumentSummaryProperties.doc.GetPropertyValue(...),doc.SetProperty(...),GetOrCreateCustomProperty,GetCustomPropertyValue.
WPF inside Inventor
InventorWindowIntegrationHelper: host a WPF window in an Inventor dockable window.InventorShellStatusBridge: status and progress from your WPF window also show in Inventor's status bar.
RibbonPluginShim: the COM-visible entry point. It loads the implementation assembly and its dependencies from aruntimefolder into a privateAssemblyLoadContextand forwards everyApplicationAddInServercall to it.- WPF control libraries that can only exist once per process are shared with the copy that is already loaded, if its major version matches.
build/Shim.targetsandbuild/Implementation.targets: the COM host, the per-Inventor-version output, the.NET 8(2024-2026) /.NET 10(2027) runtime folders, and the deploy toC:\ProgramData\Autodesk\ApplicationPlugins\<Bundle>on every local build (skip it with-p:DevDeployBundle=false).Manifest2024Base...Manifest2027Base: the.addinmanifest per Inventor version.- A loader log in the add-in's log folder, for when the add-in fails before its own logging starts.
ShellWindowBase+ShellViewModelBase: a window with a navigation frame and a footer for status and progress (IShellStatusService).INavigationService+IPageService(services.AddPage<TViewModel, TPage>()): navigate by view model; pages implementINavigationAwareto load their data.IWindowService: opens windows from the container and remembers their position and size.IDialogService(confirm, info, error, open/save file),IFileService(JSON read/write).ViewModelBase(CommunityToolkit.Mvvm), converters (TrueToVisibility,EnumToDescription,RadiansToDegrees,CentimetersToMillimeters, ...) and base styles.
LoggingHelpers.AddLoggingInSubDirectory(services, "MyAddin"): Serilog to%APPDATA%\MyAddin\logs, wired intoILogger<T>.LoggableBase: aloggerfor classes that aren't created by the container.
- Autodesk Inventor 2024, 2025, 2026 or 2027, installed. The projects compile against the
interop in
C:\Program Files\Autodesk\Inventor <version>\Bin\Public Assemblies; Autodesk's interop is not redistributable, so it is not in this repo. - .NET 8 SDK (and the .NET 10 SDK for Inventor 2027).
dotnet build BasAutomation.sln -c Release
On its own this repo builds against Inventor 2024; use -p:InventorVersion=2026 (or another
version) to build against that version instead. As a submodule it builds for the add-in's
InventorVersion.
AGENTS.md (and CLAUDE.md for Claude Code) gives an agent the layout of this repo, the rules
and the Inventor API traps: database units (cm, kg, radians), 1-based collections, the edit
document vs. the active document, transactions for undo, Inventor's thread. Add-ins made from
the template get their own agent guide and skills.
These libraries are the foundation of the Inventor add-ins by Bas Automation Services. Need a custom add-in, or help with your own? Get in touch.
More: other open-source projects · articles on the Inventor API · LinkedIn
This is a mirror of the libraries Bas Automation Services develops and uses in its own add-ins. Each release is one commit. Issues are welcome; pull requests are applied by hand in the source repo and come back with the next release.
MIT, see LICENSE.
