├── .github
└── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
├── .gitignore
├── CHANGELOG.md
├── GitVersion.yml
├── InventorAddinSdk.nuspec
├── README.md
├── build.ps1
├── icon.png
├── inventor-addin-templates.sln
├── nuget-push-script.ps1
└── templates
├── empty-addin-sdk
├── .template.config
│ ├── icon.png
│ ├── ide.host.json
│ └── template.json
├── Properties
│ └── launchSettings.json
├── StandardAddInServer.cs
├── addin.manifest
├── empty-addin-sdk.addin
└── empty-addin-sdk.csproj
├── inv-plugin-host
├── .template.config
│ ├── icon.png
│ ├── ide.host.json
│ └── template.json
├── Properties
│ └── launchSettings.json
├── StandardAddInServer.cs
├── addin.manifest
├── inv-plugin-host.addin
└── inv-plugin-host.csproj
├── inv-plugin
├── .template.config
│ ├── icon.png
│ ├── ide.host.json
│ └── template.json
├── Main.cs
├── Properties
│ └── launchSettings.json
└── inv-plugin.csproj
├── nifty-addin-sdk
├── .template.config
│ ├── icon.png
│ ├── ide.host.json
│ └── template.json
├── AddinUtilities.cs
├── Attribution.md
├── Globals.cs
├── Properties
│ └── launchSettings.json
├── Resources
│ └── Buttons
│ │ └── SampleIcon
│ │ ├── 16x16.png
│ │ └── 32x32.png
├── StandardAddInServer.cs
├── addin.manifest
├── nifty-addin-sdk.addin
└── nifty-addin-sdk.csproj
└── wpf-window-addin
├── .template.config
├── Globals.cs
├── icon.png
├── ide.host.json
└── template.json
├── Addin
├── AddinUtilities.cs
└── Globals.cs
├── Properties
└── launchSettings.json
├── Resources
└── Buttons
│ └── SampleIcon
│ ├── 16x16.png
│ └── 32x32.png
├── StandardAddInServer.cs
├── ViewModels
├── BaseViewModel.cs
├── MainWindowViewModel.cs
└── RelayCommand.cs
├── Views
├── MainWindow.xaml
└── MainWindow.xaml.cs
├── addin.manifest
├── wpf-window-addin.addin
└── wpf-window-addin.csproj
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: "[BUG]"
5 | labels: bug
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Describe the bug**
11 | A clear and concise description of what the bug is.
12 |
13 | **Area of Concern**
14 | - Template functionality, or
15 | - Template generation
16 |
17 | **To Reproduce**
18 | Steps to reproduce the behavior:
19 | 1. Go to '...'
20 | 2. Click on '....'
21 | 3. Scroll down to '....'
22 | 4. See error
23 |
24 | **Expected behavior**
25 | A clear and concise description of what you expected to happen.
26 |
27 | **Screenshots**
28 | If applicable, add screenshots to help explain your problem.
29 |
30 | **System Info (please complete the following information):**
31 | - OS: [e.g. Windows 10]
32 | - Inventor Version [e.g. 2022.01.02]
33 | - dotnet version
34 |
35 | **Additional context**
36 | Add any other context about the problem here.
37 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: "[FEAT]"
5 | labels: enhancement
6 | assignees: ''
7 |
8 | ---
9 |
10 | **Is your feature request related to a problem? Please describe.**
11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12 |
13 | **Describe the solution you'd like**
14 | A clear and concise description of what you want to happen.
15 |
16 | **Describe alternatives you've considered**
17 | A clear and concise description of any alternative solutions or features you've considered.
18 |
19 | **Additional context**
20 | Add any other context or screenshots about the feature request here.
21 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.rsuser
8 | *.suo
9 | *.user
10 | *.userosscache
11 | *.sln.docstates
12 |
13 | # User-specific files (MonoDevelop/Xamarin Studio)
14 | *.userprefs
15 |
16 | # Mono auto generated files
17 | mono_crash.*
18 |
19 | # Build results
20 | [Dd]ebug/
21 | [Dd]ebugPublic/
22 | [Rr]elease/
23 | [Rr]eleases/
24 | x64/
25 | x86/
26 | [Ww][Ii][Nn]32/
27 | [Aa][Rr][Mm]/
28 | [Aa][Rr][Mm]64/
29 | bld/
30 | [Bb]in/
31 | [Oo]bj/
32 | [Ll]og/
33 | [Ll]ogs/
34 |
35 | # Visual Studio 2015/2017 cache/options directory
36 | .vs/
37 | # Uncomment if you have tasks that create the project's static files in wwwroot
38 | #wwwroot/
39 |
40 | # Visual Studio 2017 auto generated files
41 | Generated\ Files/
42 |
43 | # MSTest test Results
44 | [Tt]est[Rr]esult*/
45 | [Bb]uild[Ll]og.*
46 |
47 | # NUnit
48 | *.VisualState.xml
49 | TestResult.xml
50 | nunit-*.xml
51 |
52 | # Build Results of an ATL Project
53 | [Dd]ebugPS/
54 | [Rr]eleasePS/
55 | dlldata.c
56 |
57 | # Benchmark Results
58 | BenchmarkDotNet.Artifacts/
59 |
60 | # .NET Core
61 | project.lock.json
62 | project.fragment.lock.json
63 | artifacts/
64 |
65 | # ASP.NET Scaffolding
66 | ScaffoldingReadMe.txt
67 |
68 | # StyleCop
69 | StyleCopReport.xml
70 |
71 | # Files built by Visual Studio
72 | *_i.c
73 | *_p.c
74 | *_h.h
75 | *.ilk
76 | *.meta
77 | *.obj
78 | *.iobj
79 | *.pch
80 | *.pdb
81 | *.ipdb
82 | *.pgc
83 | *.pgd
84 | *.rsp
85 | *.sbr
86 | *.tlb
87 | *.tli
88 | *.tlh
89 | *.tmp
90 | *.tmp_proj
91 | *_wpftmp.csproj
92 | *.log
93 | *.tlog
94 | *.vspscc
95 | *.vssscc
96 | .builds
97 | *.pidb
98 | *.svclog
99 | *.scc
100 |
101 | # Chutzpah Test files
102 | _Chutzpah*
103 |
104 | # Visual C++ cache files
105 | ipch/
106 | *.aps
107 | *.ncb
108 | *.opendb
109 | *.opensdf
110 | *.sdf
111 | *.cachefile
112 | *.VC.db
113 | *.VC.VC.opendb
114 |
115 | # Visual Studio profiler
116 | *.psess
117 | *.vsp
118 | *.vspx
119 | *.sap
120 |
121 | # Visual Studio Trace Files
122 | *.e2e
123 |
124 | # TFS 2012 Local Workspace
125 | $tf/
126 |
127 | # Guidance Automation Toolkit
128 | *.gpState
129 |
130 | # ReSharper is a .NET coding add-in
131 | _ReSharper*/
132 | *.[Rr]e[Ss]harper
133 | *.DotSettings.user
134 |
135 | # TeamCity is a build add-in
136 | _TeamCity*
137 |
138 | # DotCover is a Code Coverage Tool
139 | *.dotCover
140 |
141 | # AxoCover is a Code Coverage Tool
142 | .axoCover/*
143 | !.axoCover/settings.json
144 |
145 | # Coverlet is a free, cross platform Code Coverage Tool
146 | coverage*.json
147 | coverage*.xml
148 | coverage*.info
149 |
150 | # Visual Studio code coverage results
151 | *.coverage
152 | *.coveragexml
153 |
154 | # NCrunch
155 | _NCrunch_*
156 | .*crunch*.local.xml
157 | nCrunchTemp_*
158 |
159 | # MightyMoose
160 | *.mm.*
161 | AutoTest.Net/
162 |
163 | # Web workbench (sass)
164 | .sass-cache/
165 |
166 | # Installshield output folder
167 | [Ee]xpress/
168 |
169 | # DocProject is a documentation generator add-in
170 | DocProject/buildhelp/
171 | DocProject/Help/*.HxT
172 | DocProject/Help/*.HxC
173 | DocProject/Help/*.hhc
174 | DocProject/Help/*.hhk
175 | DocProject/Help/*.hhp
176 | DocProject/Help/Html2
177 | DocProject/Help/html
178 |
179 | # Click-Once directory
180 | publish/
181 |
182 | # Publish Web Output
183 | *.[Pp]ublish.xml
184 | *.azurePubxml
185 | # Note: Comment the next line if you want to checkin your web deploy settings,
186 | # but database connection strings (with potential passwords) will be unencrypted
187 | *.pubxml
188 | *.publishproj
189 |
190 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
191 | # checkin your Azure Web App publish settings, but sensitive information contained
192 | # in these scripts will be unencrypted
193 | PublishScripts/
194 |
195 | # NuGet Packages
196 | *.nupkg
197 | # NuGet Symbol Packages
198 | *.snupkg
199 | # The packages folder can be ignored because of Package Restore
200 | **/[Pp]ackages/*
201 | # except build/, which is used as an MSBuild target.
202 | !**/[Pp]ackages/build/
203 | # Uncomment if necessary however generally it will be regenerated when needed
204 | #!**/[Pp]ackages/repositories.config
205 | # NuGet v3's project.json files produces more ignorable files
206 | *.nuget.props
207 | *.nuget.targets
208 |
209 | # Nuget personal access tokens and Credentials
210 | nuget.config
211 |
212 | # Microsoft Azure Build Output
213 | csx/
214 | *.build.csdef
215 |
216 | # Microsoft Azure Emulator
217 | ecf/
218 | rcf/
219 |
220 | # Windows Store app package directories and files
221 | AppPackages/
222 | BundleArtifacts/
223 | Package.StoreAssociation.xml
224 | _pkginfo.txt
225 | *.appx
226 | *.appxbundle
227 | *.appxupload
228 |
229 | # Visual Studio cache files
230 | # files ending in .cache can be ignored
231 | *.[Cc]ache
232 | # but keep track of directories ending in .cache
233 | !?*.[Cc]ache/
234 |
235 | # Others
236 | ClientBin/
237 | ~$*
238 | *~
239 | *.dbmdl
240 | *.dbproj.schemaview
241 | *.jfm
242 | *.pfx
243 | *.publishsettings
244 | orleans.codegen.cs
245 |
246 | # Including strong name files can present a security risk
247 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
248 | #*.snk
249 |
250 | # Since there are multiple workflows, uncomment next line to ignore bower_components
251 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
252 | #bower_components/
253 |
254 | # RIA/Silverlight projects
255 | Generated_Code/
256 |
257 | # Backup & report files from converting an old project file
258 | # to a newer Visual Studio version. Backup files are not needed,
259 | # because we have git ;-)
260 | _UpgradeReport_Files/
261 | Backup*/
262 | UpgradeLog*.XML
263 | UpgradeLog*.htm
264 | ServiceFabricBackup/
265 | *.rptproj.bak
266 |
267 | # SQL Server files
268 | *.mdf
269 | *.ldf
270 | *.ndf
271 |
272 | # Business Intelligence projects
273 | *.rdl.data
274 | *.bim.layout
275 | *.bim_*.settings
276 | *.rptproj.rsuser
277 | *- [Bb]ackup.rdl
278 | *- [Bb]ackup ([0-9]).rdl
279 | *- [Bb]ackup ([0-9][0-9]).rdl
280 |
281 | # Microsoft Fakes
282 | FakesAssemblies/
283 |
284 | # GhostDoc plugin setting file
285 | *.GhostDoc.xml
286 |
287 | # Node.js Tools for Visual Studio
288 | .ntvs_analysis.dat
289 | node_modules/
290 |
291 | # Visual Studio 6 build log
292 | *.plg
293 |
294 | # Visual Studio 6 workspace options file
295 | *.opt
296 |
297 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
298 | *.vbw
299 |
300 | # Visual Studio LightSwitch build output
301 | **/*.HTMLClient/GeneratedArtifacts
302 | **/*.DesktopClient/GeneratedArtifacts
303 | **/*.DesktopClient/ModelManifest.xml
304 | **/*.Server/GeneratedArtifacts
305 | **/*.Server/ModelManifest.xml
306 | _Pvt_Extensions
307 |
308 | # Paket dependency manager
309 | .paket/paket.exe
310 | paket-files/
311 |
312 | # FAKE - F# Make
313 | .fake/
314 |
315 | # CodeRush personal settings
316 | .cr/personal
317 |
318 | # Python Tools for Visual Studio (PTVS)
319 | __pycache__/
320 | *.pyc
321 |
322 | # Cake - Uncomment if you are using it
323 | # tools/**
324 | # !tools/packages.config
325 |
326 | # Tabs Studio
327 | *.tss
328 |
329 | # Telerik's JustMock configuration file
330 | *.jmconfig
331 |
332 | # BizTalk build output
333 | *.btp.cs
334 | *.btm.cs
335 | *.odx.cs
336 | *.xsd.cs
337 |
338 | # OpenCover UI analysis results
339 | OpenCover/
340 |
341 | # Azure Stream Analytics local run output
342 | ASALocalRun/
343 |
344 | # MSBuild Binary and Structured Log
345 | *.binlog
346 |
347 | # NVidia Nsight GPU debugger configuration file
348 | *.nvuser
349 |
350 | # MFractors (Xamarin productivity tool) working folder
351 | .mfractor/
352 |
353 | # Local History for Visual Studio
354 | .localhistory/
355 |
356 | # BeatPulse healthcheck temp database
357 | healthchecksdb
358 |
359 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
360 | MigrationBackup/
361 |
362 | # Ionide (cross platform F# VS Code tools) working folder
363 | .ionide/
364 |
365 | # Fody - auto-generated XML schema
366 | FodyWeavers.xsd
367 |
368 | # VS Code files for those working on multiple tools
369 | .vscode/*
370 | !.vscode/settings.json
371 | !.vscode/tasks.json
372 | !.vscode/launch.json
373 | !.vscode/extensions.json
374 | *.code-workspace
375 |
376 | # Local History for Visual Studio Code
377 | .history/
378 |
379 | # Windows Installer files from build outputs
380 | *.cab
381 | *.msi
382 | *.msix
383 | *.msm
384 | *.msp
385 |
386 | # JetBrains Rider
387 | .idea/
388 | *.sln.iml
389 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # InventorCode.AddinTemplates Changelog
2 | All notable changes to this project will be documented in this file.
3 |
4 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6 |
7 | ## [0.4.1](https://www.nuget.org/packages/InventorCode.AddinTemplates/)
8 |
9 | ### Added
10 |
11 | - `inv-pluginhost` and `inv-plugin` now use InventorCode.Plugin 0.6.0
12 |
13 | ## [0.4.0](https://www.nuget.org/packages/InventorCode.AddinTemplates/)
14 |
15 | ### Added
16 |
17 | - `inv-pluginhost` template
18 | - `inv-plugin` template
19 |
20 | ## [0.3.0](https://www.nuget.org/packages/InventorCode.AddinTemplates/)
21 |
22 | ### Added
23 |
24 | - CHANGELOG.md
25 | - WPF window addin template `inv-wpf`
26 | - Inventor (2021) set as Debug executable for all templates.
27 |
28 | ### Fixed
29 |
30 | - nifty-addin-sdk build event copies the Resources folder into the user's Autodesk Addins directory during Debug builds.
31 | - nifty-addin-sdk was added to the inventor-addin-templates VS solution.
32 |
33 | ### Removed
34 |
35 | ## [0.2.0](https://www.nuget.org/packages/InventorCode.AddinTemplates/)
36 |
37 | ### Added
38 |
39 | - Initial Release
40 | - Added templates:
41 | - `inv-empty`
42 | - `inv-nifty`
43 | - Created nuget package [InventorCode.AddinTemplates](https://www.nuget.org/packages/InventorCode.AddinTemplates/)
--------------------------------------------------------------------------------
/GitVersion.yml:
--------------------------------------------------------------------------------
1 | branches: {}
2 | ignore:
3 | sha: []
4 | merge-message-formats: {}
5 | major-version-bump-message: "^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\\([\\w\\s]*\\))?(!:|:.*\\n\\n((.+\\n)+\\n)?BREAKING CHANGE:\\s.+)"
6 | minor-version-bump-message: "^(feat)(\\([\\w\\s]*\\))?:"
7 | patch-version-bump-message: "^(build|chore|ci|docs|fix|perf|refactor|revert|style|test)(\\([\\w\\s]*\\))?:"
--------------------------------------------------------------------------------
/InventorAddinSdk.nuspec:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | InventorCode.AddinTemplates
5 | 0.4.1
6 |
7 | Customizable Autodesk Inventor add-in templates for the dotnet new templating engine.
8 |
9 | InventorCode
10 | Apache-2.0
11 |
12 |
13 |
14 | icon.png
15 | https://github.com/InventorCode/inventor-addin-templates
16 |
17 | ## [0.4.1](https://www.nuget.org/packages/InventorCode.AddinTemplates/)
18 |
19 | ### Fix
20 |
21 | - inv-plugin and inv-pluginhost updated to use InventorCode.Plugin 0.6.0
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## inventor-addin-templates
2 |
3 | A collection of Autodesk Inventor addin templates that use the dotnet new templating engine. This means the templates are always ready to build, and are simpler to configure and create than the older visual studio style templates. Despite using the dotnet new templating engine, the addins are targeted towards .Net Framework 4.7 & 4.8, though that can be further configured after creation.
4 |
5 | ### Installation
6 |
7 | Install the nuget template package by running the simple command [here](https://www.nuget.org/packages/InventorCode.AddinTemplates/)
8 |
9 | ### Creation
10 |
11 | To create a new empty addin, enter the following command in a command line terminal:
12 | ```dotnet new inv-empty -n NewAddinName```
13 |
14 | - The new addin will be created in the current directory.
15 | - type ```dotnet new inv-empty -h``` for a list of options.
16 | - list of templates
17 | - `inv-empty` Empty Inventor addin template.
18 | - `inv-nifty` A port of Brian Ekin's VB.net Nifty Addin template.
19 | - `inv-wpf` A simple [MVVM] WPF addin template.
20 | - `inv-pluginhost` A PluginHost addin using MEF; this is the "main" addin for the plugin type.
21 | - `inv-plugin` A Plugin for use in with the PluginHost addin; this is loaded into the PluginHost addin dynamically.
22 |
23 | - You can enable these templates in Visual Studio 2019 if you have "Show All .NET CLI templates" enabled in Options > General > Preview Features.
24 |
25 | ### Dependencies
26 |
27 | - nuget.exe >= 5.2
28 | - tested with dotnet 5, Inventor 2021
29 |
--------------------------------------------------------------------------------
/build.ps1:
--------------------------------------------------------------------------------
1 | reset-templates
2 | nuget pack -OutputDirectory nupkg/
3 |
4 | $files = Get-ChildItem nupkg/
5 | foreach ($file in $files) {dotnet new -i $file.FullName}
6 |
7 | pause
--------------------------------------------------------------------------------
/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/InventorCode/inventor-addin-templates/ba0c87ae38aa55077b89613302936b964fe85ccd/icon.png
--------------------------------------------------------------------------------
/inventor-addin-templates.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.31205.134
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "empty-addin-sdk", "templates\empty-addin-sdk\empty-addin-sdk.csproj", "{FFAF333D-1803-433E-84D9-095D6998BA58}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nifty-addin-sdk", "templates\nifty-addin-sdk\nifty-addin-sdk.csproj", "{EA0563A3-9787-4DD0-9240-BF0B19364129}"
9 | EndProject
10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "wpf-window-addin", "templates\wpf-window-addin\wpf-window-addin.csproj", "{6ACE9F63-7424-47C8-9724-C5DB14489DFD}"
11 | EndProject
12 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5CDC7AC7-72AF-4459-B221-316BC2ED3401}"
13 | ProjectSection(SolutionItems) = preProject
14 | CHANGELOG.md = CHANGELOG.md
15 | InventorAddinSdk.nuspec = InventorAddinSdk.nuspec
16 | README.md = README.md
17 | EndProjectSection
18 | EndProject
19 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "inv-plugin", "templates\inv-plugin\inv-plugin.csproj", "{1C0D6291-4855-456C-BAE5-55BD16E19B14}"
20 | EndProject
21 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "inv-plugin-host", "templates\inv-plugin-host\inv-plugin-host.csproj", "{A3831727-1FC0-47E5-B8E0-3DA383AC066D}"
22 | EndProject
23 | Global
24 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
25 | Debug|Any CPU = Debug|Any CPU
26 | Release|Any CPU = Release|Any CPU
27 | EndGlobalSection
28 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
29 | {FFAF333D-1803-433E-84D9-095D6998BA58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
30 | {FFAF333D-1803-433E-84D9-095D6998BA58}.Debug|Any CPU.Build.0 = Debug|Any CPU
31 | {FFAF333D-1803-433E-84D9-095D6998BA58}.Release|Any CPU.ActiveCfg = Release|Any CPU
32 | {FFAF333D-1803-433E-84D9-095D6998BA58}.Release|Any CPU.Build.0 = Release|Any CPU
33 | {EA0563A3-9787-4DD0-9240-BF0B19364129}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
34 | {EA0563A3-9787-4DD0-9240-BF0B19364129}.Debug|Any CPU.Build.0 = Debug|Any CPU
35 | {EA0563A3-9787-4DD0-9240-BF0B19364129}.Release|Any CPU.ActiveCfg = Release|Any CPU
36 | {EA0563A3-9787-4DD0-9240-BF0B19364129}.Release|Any CPU.Build.0 = Release|Any CPU
37 | {6ACE9F63-7424-47C8-9724-C5DB14489DFD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
38 | {6ACE9F63-7424-47C8-9724-C5DB14489DFD}.Debug|Any CPU.Build.0 = Debug|Any CPU
39 | {6ACE9F63-7424-47C8-9724-C5DB14489DFD}.Release|Any CPU.ActiveCfg = Release|Any CPU
40 | {6ACE9F63-7424-47C8-9724-C5DB14489DFD}.Release|Any CPU.Build.0 = Release|Any CPU
41 | {1C0D6291-4855-456C-BAE5-55BD16E19B14}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
42 | {1C0D6291-4855-456C-BAE5-55BD16E19B14}.Debug|Any CPU.Build.0 = Debug|Any CPU
43 | {1C0D6291-4855-456C-BAE5-55BD16E19B14}.Release|Any CPU.ActiveCfg = Release|Any CPU
44 | {1C0D6291-4855-456C-BAE5-55BD16E19B14}.Release|Any CPU.Build.0 = Release|Any CPU
45 | {A3831727-1FC0-47E5-B8E0-3DA383AC066D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
46 | {A3831727-1FC0-47E5-B8E0-3DA383AC066D}.Debug|Any CPU.Build.0 = Debug|Any CPU
47 | {A3831727-1FC0-47E5-B8E0-3DA383AC066D}.Release|Any CPU.ActiveCfg = Release|Any CPU
48 | {A3831727-1FC0-47E5-B8E0-3DA383AC066D}.Release|Any CPU.Build.0 = Release|Any CPU
49 | EndGlobalSection
50 | GlobalSection(SolutionProperties) = preSolution
51 | HideSolutionNode = FALSE
52 | EndGlobalSection
53 | GlobalSection(ExtensibilityGlobals) = postSolution
54 | SolutionGuid = {B0FCDDAF-7930-432C-9B05-7E2F92A81F08}
55 | EndGlobalSection
56 | EndGlobal
57 |
--------------------------------------------------------------------------------
/nuget-push-script.ps1:
--------------------------------------------------------------------------------
1 | nuget push nupkg/InventorCode.AddinTemplates.0.4.1.nupkg -Source https://api.nuget.org/v3/index.json
--------------------------------------------------------------------------------
/templates/empty-addin-sdk/.template.config/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/InventorCode/inventor-addin-templates/ba0c87ae38aa55077b89613302936b964fe85ccd/templates/empty-addin-sdk/.template.config/icon.png
--------------------------------------------------------------------------------
/templates/empty-addin-sdk/.template.config/ide.host.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/vs-2017.3.host",
3 | "icon":"icon.png",
4 | "symbolInfo": [
5 | {
6 | "id": "namespace",
7 | "name": {
8 | "text": "Default namespace"
9 | },
10 | "isVisible": "true"
11 | },
12 | {
13 | "id": "product",
14 | "name": {
15 | "text": "Product Name"
16 | },
17 | "isVisible": "true"
18 | },
19 | {
20 | "id": "description",
21 | "name": {
22 | "text": "Addin description"
23 | },
24 | "isVisible": "true"
25 | },
26 | {
27 | "id": "author",
28 | "name": {
29 | "text": "Author"
30 | },
31 | "isVisible": "true"
32 | },
33 | {
34 | "id": "company",
35 | "name": {
36 | "text": "Company Name"
37 | },
38 | "isVisible": "true"
39 | }
40 | ]
41 | }
--------------------------------------------------------------------------------
/templates/empty-addin-sdk/.template.config/template.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/template",
3 | "author": "Matthew D. Jordan",
4 | "classifications": ["Desktop"],
5 | "name": "Inventor Addin SDK",
6 | "shortName": "inv-empty",
7 | "default": "InventorAddin",
8 | "identity": "InventorCode.addin.empty.csharp01",
9 | "tags": {
10 | "language": "C#",
11 | "type": "project"
12 | },
13 | "sourceName":"empty-addin-sdk",
14 | "defaultName":"EmptyInventorAddin",
15 | "preferNameDirectory": true,
16 | "guids": [
17 | "3287C9F4-44ED-4D40-81C9-B86AC28F7603"
18 | ],
19 | "symbols": {
20 | "Framework": {
21 | "type": "parameter",
22 | "description": "The target framework for the project.",
23 | "datatype": "choice",
24 | "choices": [
25 | {
26 | "choice": "net48",
27 | "description": "Target .NET Framework 4.8"
28 | },
29 | {
30 | "choice": "net47",
31 | "description": "Target .NET Framework 4.7"
32 | }
33 | ],
34 | "replaces": "net48",
35 | "defaultValue": "net48"
36 | },
37 | "namespace": {
38 | "type": "parameter",
39 | "datatype": "text",
40 | "description": "Namespace",
41 | "replaces": "InvAddin",
42 | "defaultValue": "InvAddin"
43 | },
44 | "product": {
45 | "type": "parameter",
46 | "datatype": "text",
47 | "description": "Product Name",
48 | "replaces": "product name",
49 | "defaultValue": ""
50 | },
51 | "description": {
52 | "type": "parameter",
53 | "datatype": "text",
54 | "description": "Addin Description",
55 | "replaces": "addin description",
56 | "defaultValue": ""
57 | },
58 | "company": {
59 | "type": "parameter",
60 | "datatype": "text",
61 | "description": "Company Name",
62 | "replaces": "company name",
63 | "defaultValue": ""
64 | },
65 | "author": {
66 | "type": "parameter",
67 | "datatype": "text",
68 | "description": "Author",
69 | "replaces": "author name",
70 | "defaultValue": ""
71 | },
72 | "copyright": {
73 | "type": "parameter",
74 | "datatype": "text",
75 | "description": "Copyright",
76 | "replaces": "copyright text",
77 | "defaultValue": ""
78 | }
79 | }
80 | }
--------------------------------------------------------------------------------
/templates/empty-addin-sdk/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "empty-addin-sdk": {
4 | "commandName": "Executable",
5 | "executablePath": "C:\\Program Files\\Autodesk\\Inventor 2021\\Bin\\Inventor.exe"
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/templates/empty-addin-sdk/StandardAddInServer.cs:
--------------------------------------------------------------------------------
1 | using Inventor;
2 | using Microsoft.Win32;
3 | using System;
4 | using System.Runtime.InteropServices;
5 | using System.Windows.Forms;
6 |
7 | namespace InvAddin
8 | {
9 | ///
10 | /// This is the primary AddIn Server class that implements the ApplicationAddInServer interface
11 | /// that all Inventor AddIns are required to implement. The communication between Inventor and
12 | /// the AddIn is via the methods on this interface.
13 | ///
14 | [ProgId("InvAddin.StandardAddinServer")]
15 | [GuidAttribute("3287C9F4-44ED-4D40-81C9-B86AC28F7603")]
16 | public class StandardAddInServer : Inventor.ApplicationAddInServer
17 | {
18 |
19 | // Inventor application object.
20 | private Inventor.Application m_inventorApplication;
21 |
22 | public StandardAddInServer()
23 | {
24 | }
25 |
26 | #region ApplicationAddInServer Members
27 |
28 | public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
29 | {
30 | // This method is called by Inventor when it loads the addin.
31 | // The AddInSiteObject provides access to the Inventor Application object.
32 | // The FirstTime flag indicates if the addin is loaded for the first time.
33 |
34 | // Initialize AddIn members.
35 | m_inventorApplication = addInSiteObject.Application;
36 |
37 | // MessageBox.Show("Hello!");
38 | // TODO: Add ApplicationAddInServer.Activate implementation.
39 | // e.g. event initialization, command creation etc.
40 | }
41 |
42 | public void Deactivate()
43 | {
44 | // This method is called by Inventor when the AddIn is unloaded.
45 | // The AddIn will be unloaded either manually by the user or
46 | // when the Inventor session is terminated
47 |
48 | // TODO: Add ApplicationAddInServer.Deactivate implementation
49 |
50 | // Release objects.
51 | m_inventorApplication = null;
52 |
53 | GC.Collect();
54 | GC.WaitForPendingFinalizers();
55 | }
56 |
57 | public void ExecuteCommand(int commandID)
58 | {
59 | // Note:this method is now obsolete, you should use the
60 | // ControlDefinition functionality for implementing commands.
61 | }
62 |
63 | public object Automation
64 | {
65 | // This property is provided to allow the AddIn to expose an API
66 | // of its own to other programs. Typically, this would be done by
67 | // implementing the AddIn's API interface in a class and returning
68 | // that class object through this property.
69 |
70 | get
71 | {
72 | // TODO: Add ApplicationAddInServer.Automation getter implementation
73 | return null;
74 | }
75 | }
76 |
77 | #endregion
78 |
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/templates/empty-addin-sdk/addin.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/templates/empty-addin-sdk/empty-addin-sdk.addin:
--------------------------------------------------------------------------------
1 |
2 |
3 | {3287C9F4-44ED-4D40-81C9-B86AC28F7603}
4 | {3287C9F4-44ED-4D40-81C9-B86AC28F7603}
5 | empty-addin-sdk
6 | Addin description
7 | empty-addin-sdk.dll
8 | 1
9 | 1
10 | 0
11 | 15..
12 | 1
13 | 1
14 |
--------------------------------------------------------------------------------
/templates/empty-addin-sdk/empty-addin-sdk.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net48
5 | InvAddin
6 | addin.manifest
7 |
8 |
9 |
10 | empty-addin-sdk
11 | false
12 | addin author
13 | company name
14 | product name
15 | addin description
16 | copyright text
17 |
18 |
19 |
20 |
21 | ..\..\..\..\..\..\..\..\Program Files\Autodesk\Inventor 2021\Bin\Public Assemblies\Autodesk.Inventor.Interop.dll
22 |
23 |
24 |
25 |
26 |
27 |
28 | PreserveNewest
29 |
30 |
31 | PreserveNewest
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/templates/inv-plugin-host/.template.config/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/InventorCode/inventor-addin-templates/ba0c87ae38aa55077b89613302936b964fe85ccd/templates/inv-plugin-host/.template.config/icon.png
--------------------------------------------------------------------------------
/templates/inv-plugin-host/.template.config/ide.host.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/vs-2017.3.host",
3 | "icon":"icon.png",
4 | "symbolInfo": [
5 | {
6 | "id": "namespace",
7 | "name": {
8 | "text": "Default namespace"
9 | },
10 | "isVisible": "true"
11 | },
12 | {
13 | "id": "product",
14 | "name": {
15 | "text": "Product Name"
16 | },
17 | "isVisible": "true"
18 | },
19 | {
20 | "id": "description",
21 | "name": {
22 | "text": "Addin description"
23 | },
24 | "isVisible": "true"
25 | },
26 | {
27 | "id": "author",
28 | "name": {
29 | "text": "Author"
30 | },
31 | "isVisible": "true"
32 | },
33 | {
34 | "id": "company",
35 | "name": {
36 | "text": "Company Name"
37 | },
38 | "isVisible": "true"
39 | }
40 | ]
41 | }
--------------------------------------------------------------------------------
/templates/inv-plugin-host/.template.config/template.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/template",
3 | "author": "Matthew D. Jordan",
4 | "classifications": ["Desktop"],
5 | "name": "Inventor Addin PluginHost",
6 | "shortName": "inv-pluginhost",
7 | "default": "InventorAddin",
8 | "identity": "InventorCode.addin.pluginhost.cs",
9 | "tags": {
10 | "language": "C#",
11 | "type": "project"
12 | },
13 | "sourceName":"inv-plugin-host",
14 | "defaultName":"AddinPluginHost",
15 | "preferNameDirectory": true,
16 | "guids": [
17 | "B76D3C5A-C5BD-4560-A532-5E047C84E596"
18 | ],
19 | "symbols": {
20 | "namespace": {
21 | "type": "parameter",
22 | "datatype": "text",
23 | "description": "Namespace",
24 | "replaces": "InvAddin",
25 | "defaultValue": "InvAddin"
26 | },
27 | "product": {
28 | "type": "parameter",
29 | "datatype": "text",
30 | "description": "Product Name",
31 | "replaces": "product name",
32 | "defaultValue": ""
33 | },
34 | "description": {
35 | "type": "parameter",
36 | "datatype": "text",
37 | "description": "Addin Description",
38 | "replaces": "addin description",
39 | "defaultValue": ""
40 | },
41 | "company": {
42 | "type": "parameter",
43 | "datatype": "text",
44 | "description": "Company Name",
45 | "replaces": "company name",
46 | "defaultValue": ""
47 | },
48 | "author": {
49 | "type": "parameter",
50 | "datatype": "text",
51 | "description": "Author",
52 | "replaces": "author name",
53 | "defaultValue": ""
54 | },
55 | "copyright": {
56 | "type": "parameter",
57 | "datatype": "text",
58 | "description": "Copyright",
59 | "replaces": "copyright text",
60 | "defaultValue": ""
61 | }
62 | }
63 | }
--------------------------------------------------------------------------------
/templates/inv-plugin-host/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "inv-plugin-host": {
4 | "commandName": "Executable",
5 | "executablePath": "C:\\Program Files\\Autodesk\\Inventor 2021\\Bin\\Inventor.exe"
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/templates/inv-plugin-host/StandardAddInServer.cs:
--------------------------------------------------------------------------------
1 | using Inventor;
2 | using Microsoft.Win32;
3 | using System;
4 | using System.Runtime.InteropServices;
5 | using System.Windows.Forms;
6 | using InventorCode.Plugin;
7 | using System.Collections.Generic;
8 |
9 |
10 | namespace InvAddin
11 | {
12 | ///
13 | /// This is the primary AddIn Server class that implements the ApplicationAddInServer interface
14 | /// that all Inventor AddIns are required to implement. The communication between Inventor and
15 | /// the AddIn is via the methods on this interface.
16 | ///
17 | [ProgId("InvAddin.StandardAddinServer")]
18 | [GuidAttribute("B76D3C5A-C5BD-4560-A532-5E047C84E596")]
19 | public class StandardAddInServer : Inventor.ApplicationAddInServer
20 | {
21 |
22 | // Inventor application object.
23 | private Inventor.Application m_inventorApplication;
24 |
25 | // Create an instance of the PluginHost class in the package. This contains
26 | // the code to wire up the plugins dynamically.
27 | private PluginHost pluginHost = new PluginHost();
28 |
29 | public StandardAddInServer()
30 | {
31 | // Here we will actually wire up the plugins by collecting classes with advertised
32 | // IPlugin interfaces into our PluginHost object. If you need granular control, you
33 | // can manually compose these using MEF. See the IPluginHost class to get you started.
34 | pluginHost.ComposePlugins();
35 | }
36 |
37 | #region ApplicationAddInServer Members
38 |
39 | public void Activate(Inventor.ApplicationAddInSite addInSiteObject, bool firstTime)
40 | {
41 | // This method is called by Inventor when it loads the addin.
42 | // The AddInSiteObject provides access to the Inventor Application object.
43 | // The FirstTime flag indicates if the addin is loaded for the first time.
44 |
45 | // Initialize AddIn members.
46 | m_inventorApplication = addInSiteObject.Application;
47 |
48 | // Here we'll activate the individual plugins...
49 | pluginHost.ActivateAll(m_inventorApplication, "B76D3C5A-C5BD-4560-A532-5E047C84E596");
50 | }
51 |
52 | public void Deactivate()
53 | {
54 | // And here we'll deactivate the individual plugins...
55 | pluginHost.DeactivateAll();
56 |
57 | // Release objects.
58 | m_inventorApplication = null;
59 |
60 | GC.Collect();
61 | GC.WaitForPendingFinalizers();
62 | }
63 |
64 | public void ExecuteCommand(int commandID) { }
65 | public object Automation { get => null; }
66 |
67 | #endregion
68 |
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/templates/inv-plugin-host/addin.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/templates/inv-plugin-host/inv-plugin-host.addin:
--------------------------------------------------------------------------------
1 |
2 |
3 | {B76D3C5A-C5BD-4560-A532-5E047C84E596}
4 | {B76D3C5A-C5BD-4560-A532-5E047C84E596}
5 | inv-plugin-host
6 | Addin description
7 | inv-plugin-host.dll
8 | 1
9 | 1
10 | 0
11 | 15..
12 | 1
13 | 1
14 |
--------------------------------------------------------------------------------
/templates/inv-plugin-host/inv-plugin-host.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net48
5 | InvAddin
6 | addin.manifest
7 |
8 |
9 |
10 | inv-plugin-host
11 | false
12 | addin author
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 | ../../artifacts
21 |
22 |
23 |
24 | ../../artifacts
25 | Off
26 |
27 |
28 |
29 | false
30 | true
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 | ..\..\..\..\..\..\..\..\Program Files\Autodesk\Inventor 2021\Bin\Public Assemblies\Autodesk.Inventor.Interop.dll
40 | False
41 | False
42 |
43 |
44 |
45 | True
46 | true
47 |
48 |
49 |
50 |
51 |
52 |
53 | PreserveNewest
54 |
55 |
56 | PreserveNewest
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
--------------------------------------------------------------------------------
/templates/inv-plugin/.template.config/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/InventorCode/inventor-addin-templates/ba0c87ae38aa55077b89613302936b964fe85ccd/templates/inv-plugin/.template.config/icon.png
--------------------------------------------------------------------------------
/templates/inv-plugin/.template.config/ide.host.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/vs-2017.3.host",
3 | "icon": "icon.png",
4 | "symbolInfo": [
5 | {
6 | "id": "namespace",
7 | "name": {
8 | "text": "Default namespace"
9 | },
10 | "isVisible": "true"
11 | },
12 | {
13 | "id": "host-name",
14 | "name": {
15 | "text": "inv-plugin-host"
16 | },
17 | "isVisible": "true"
18 | },
19 | {
20 | "id": "product",
21 | "name": {
22 | "text": "Product Name"
23 | },
24 | "isVisible": "true"
25 | },
26 | {
27 | "id": "description",
28 | "name": {
29 | "text": "Addin description"
30 | },
31 | "isVisible": "true"
32 | },
33 | {
34 | "id": "author",
35 | "name": {
36 | "text": "Author Name"
37 | },
38 | "isVisible": "true"
39 | },
40 | {
41 | "id": "company",
42 | "name": {
43 | "text": "Company Name"
44 | },
45 | "isVisible": "true"
46 | }
47 | ]
48 | }
--------------------------------------------------------------------------------
/templates/inv-plugin/.template.config/template.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/template",
3 | "author": "Matthew D. Jordan",
4 | "classifications": ["Desktop"],
5 | "name": "Inventor Addin Plugin",
6 | "shortName": "inv-plugin",
7 | "default": "InventorAddinPlugin",
8 | "identity": "InventorCode.addin.plugin.cs",
9 | "tags": {
10 | "language": "C#",
11 | "type": "project"
12 | },
13 | "sourceName":"inv-plugin",
14 | "defaultName":"InventorAddinPlugin",
15 | "preferNameDirectory": true,
16 | "symbols": {
17 | "host-name":{
18 | "type": "parameter",
19 | "datatype": "text",
20 | "description": "PluginHost name (used to place assemblies in the correct directory for debug testing).",
21 | "replaces": "inv-plugin-host",
22 | "defaultValue": "inv-plugin-host"
23 | },
24 | "namespace": {
25 | "type": "parameter",
26 | "datatype": "text",
27 | "description": "Namespace",
28 | "replaces": "InvAddinPlugin",
29 | "defaultValue": "InvAddinPlugin"
30 | },
31 | "product": {
32 | "type": "parameter",
33 | "datatype": "text",
34 | "description": "Product Name",
35 | "replaces": "Product Name",
36 | "defaultValue": ""
37 | },
38 | "description": {
39 | "type": "parameter",
40 | "datatype": "text",
41 | "description": "Plugin Description",
42 | "replaces": "Plugin description",
43 | "defaultValue": ""
44 | },
45 | "company": {
46 | "type": "parameter",
47 | "datatype": "text",
48 | "description": "Company Name",
49 | "replaces": "Company Name",
50 | "defaultValue": ""
51 | },
52 | "author": {
53 | "type": "parameter",
54 | "datatype": "text",
55 | "description": "Author Name",
56 | "replaces": "Author Name",
57 | "defaultValue": ""
58 | },
59 | "copyright": {
60 | "type": "parameter",
61 | "datatype": "text",
62 | "description": "Copyright",
63 | "replaces": "copyright text",
64 | "defaultValue": ""
65 | }
66 | }
67 | }
--------------------------------------------------------------------------------
/templates/inv-plugin/Main.cs:
--------------------------------------------------------------------------------
1 | using Inventor;
2 | using InventorCode.Plugin;
3 | using System.ComponentModel.Composition;
4 | using System.Reflection;
5 | using System.Windows.Forms;
6 |
7 | namespace InvAddinPlugin
8 | {
9 | ///
10 | /// This is a plugin that we'll create to work with the IPlugin Demo. This is effectively
11 | /// a mini-addin that knows nothing about the "host-addin" that will be loading it.
12 | /// All button creation, command creation, etc relevant to this mini-addin will be contained
13 | /// here.
14 | ///
15 |
16 | //This attribute is required! It is what PluginHost uses to find this plugin.
17 | [Export(typeof(IPlugin))]
18 | public class Main : IPlugin
19 | {
20 | // Implement the IPlugin Interface
21 |
22 | private Inventor.Application _inventorApplication;
23 | private string _clientId;
24 |
25 | #region IPlugin Members
26 |
27 | public void Activate(Inventor.Application InventorApplication, string ClientId, bool firstTime = true)
28 | {
29 | _inventorApplication = InventorApplication;
30 | _clientId = ClientId;
31 | MessageBox.Show("Empty Plugin Demo Loaded.");
32 | }
33 |
34 | public void Deactivate()
35 | {
36 | _inventorApplication = null;
37 | }
38 |
39 | public void Execute()
40 | {
41 | }
42 |
43 | public CommandControl ExecuteSettings { get; set; }
44 |
45 | public string Name { get => Assembly.GetExecutingAssembly().GetName().Name; }
46 |
47 | public string Version { get => Assembly.GetExecutingAssembly().GetName().Version.ToString(); }
48 |
49 | #endregion IPlugin Members
50 | }
51 | }
--------------------------------------------------------------------------------
/templates/inv-plugin/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "inv-plugin": {
4 | "commandName": "Executable",
5 | "executablePath": "C:\\Program Files\\Autodesk\\Inventor 2021\\Bin\\Inventor.exe"
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/templates/inv-plugin/inv-plugin.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | net48
5 | InvAddinPlugin
6 |
7 |
8 |
9 | inv-plugin
10 | false
11 | Author Name
12 | Company Name
13 | Product Name
14 | Plugin description
15 | copyright text
16 |
17 |
18 |
19 | ../../artifacts/Plugins
20 |
21 |
22 |
23 | ../../artifacts/Plugins
24 |
25 |
26 |
27 | false
28 | true
29 | True
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 | ..\..\..\..\..\..\..\..\Program Files\Autodesk\Inventor 2021\Bin\Public Assemblies\Autodesk.Inventor.Interop.dll
39 | False
40 | False
41 |
42 |
43 | False
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/templates/nifty-addin-sdk/.template.config/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/InventorCode/inventor-addin-templates/ba0c87ae38aa55077b89613302936b964fe85ccd/templates/nifty-addin-sdk/.template.config/icon.png
--------------------------------------------------------------------------------
/templates/nifty-addin-sdk/.template.config/ide.host.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/vs-2017.3.host",
3 | "icon":"icon.png",
4 | "symbolInfo": [
5 | {
6 | "id": "namespace",
7 | "name": {
8 | "text": "Default namespace"
9 | },
10 | "isVisible": "true"
11 | },
12 | {
13 | "id": "product",
14 | "name": {
15 | "text": "Product Name"
16 | },
17 | "isVisible": "true"
18 | },
19 | {
20 | "id": "description",
21 | "name": {
22 | "text": "Addin description"
23 | },
24 | "isVisible": "true"
25 | },
26 | {
27 | "id": "author",
28 | "name": {
29 | "text": "Author"
30 | },
31 | "isVisible": "true"
32 | },
33 | {
34 | "id": "company",
35 | "name": {
36 | "text": "Company Name"
37 | },
38 | "isVisible": "true"
39 | }
40 | ]
41 | }
--------------------------------------------------------------------------------
/templates/nifty-addin-sdk/.template.config/template.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/template",
3 | "author": "Matthew D. Jordan",
4 | "classifications": ["Desktop"],
5 | "name": "Inventor NiftyPort Addin (SDK)",
6 | "shortName": "inv-nifty",
7 | "default": "InventorAddin",
8 | "identity": "InventorCode.addin.niftyport.csharp01",
9 | "tags": {
10 | "language": "C#",
11 | "type": "project"
12 | },
13 | "sourceName":"nifty-addin-sdk",
14 | "defaultName":"NiftyInventorAddin",
15 | "preferNameDirectory": true,
16 | "guids": [
17 | "97335E20-6FC6-4BA9-8862-441B9376CB0C"
18 | ],
19 | "symbols": {
20 | "Framework": {
21 | "type": "parameter",
22 | "description": "The target framework for the project.",
23 | "datatype": "choice",
24 | "choices": [
25 | {
26 | "choice": "net48",
27 | "description": "Target .NET Framework 4.8"
28 | },
29 | {
30 | "choice": "net47",
31 | "description": "Target .NET Framework 4.7"
32 | }
33 | ],
34 | "replaces": "net48",
35 | "defaultValue": "net48"
36 | },
37 | "namespace": {
38 | "type": "parameter",
39 | "datatype": "text",
40 | "description": "Namespace",
41 | "replaces": "InvAddin",
42 | "defaultValue": "InvAddin"
43 | },
44 | "product": {
45 | "type": "parameter",
46 | "datatype": "text",
47 | "description": "Product Name",
48 | "replaces": "product name",
49 | "defaultValue": ""
50 | },
51 | "description": {
52 | "type": "parameter",
53 | "datatype": "text",
54 | "description": "Addin Description",
55 | "replaces": "addin description",
56 | "defaultValue": ""
57 | },
58 | "company": {
59 | "type": "parameter",
60 | "datatype": "text",
61 | "description": "Company Name",
62 | "replaces": "company name",
63 | "defaultValue": ""
64 | },
65 | "author": {
66 | "type": "parameter",
67 | "datatype": "text",
68 | "description": "Author",
69 | "replaces": "author name",
70 | "defaultValue": ""
71 | },
72 | "copyright": {
73 | "type": "parameter",
74 | "datatype": "text",
75 | "description": "Copyright",
76 | "replaces": "copyright text",
77 | "defaultValue": ""
78 | }
79 | }
80 | }
--------------------------------------------------------------------------------
/templates/nifty-addin-sdk/AddinUtilities.cs:
--------------------------------------------------------------------------------
1 | using Inventor;
2 | using System;
3 | using System.Windows.Forms;
4 |
5 | namespace InvAddin
6 | {
7 | public static class AddinUtilities
8 | {
9 | ///
10 | /// Function to simplify the creation of a button definition. The big advantage
11 | /// to using this function is that you don't have to deal with converting images
12 | /// but instead just reference a folder on disk where this routine reads the images.
13 | ///
14 | ///
15 | /// The name of the command as it will be displayed on the button.
16 | ///
17 | ///
18 | /// The internal name of the command. This needs to be unique with respect to ALL other
19 | /// commands. It's best to incorporate a company name to help with uniqueness.
20 | ///
21 | ///
22 | /// The tooltip that will be used for the command.
23 | ///
24 | /// This is optional and the display name will be used as the
25 | /// tooltip if no tooltip is specified. Like in the DisplayName argument, you can use
26 | /// returns to force line breaks.
27 | ///
28 | ///
29 | /// The folder that contains the icon files. This can be a full path or a path that is
30 | /// relative to the location of the add-in dll. The folder should contain the files
31 | /// 16x16.png and 32x32.png. Each command will have its own folder so they can have
32 | /// their own icons.
33 | ///
34 | /// This is optional and if no icon is specified then no icon will be displayed on the
35 | /// button and it will be only text.
36 | ///
37 | ///
38 | /// Returns the newly created button definition or Nothing in case of failure.
39 | ///
40 | public static Inventor.ButtonDefinition CreateButtonDefinition(string DisplayName,
41 | string InternalName,
42 | string ToolTip = "",
43 | string IconFolder = "")
44 | {
45 | // Check to see if a command already exists is the specified internal name.
46 | Inventor.ButtonDefinition testDef = null;
47 | try
48 | {
49 | testDef = (Inventor.ButtonDefinition)Globals.invApp.CommandManager.ControlDefinitions[InternalName];
50 | }
51 | catch
52 | {
53 | // This needs to fail silently.
54 | }
55 |
56 | if (!(testDef == null))
57 | {
58 | MessageBox.Show("Error when loading the add-in \"INVENTOR_DrawingFiller\". A command already exists with the same internal name. Each add-in must have a unique internal name. Change the internal name in the call to CreateButtonDefinition.", "Title Block Filler Inventor Add-In");
59 | return null;
60 | }
61 |
62 | // Check to see if the provided folder is a full or relative path.
63 | if (!string.IsNullOrEmpty(IconFolder))
64 | {
65 | if (!System.IO.Directory.Exists(IconFolder))
66 | {
67 | // The folder provided doesn't exist, so assume it is a relative path and
68 | // build up the full path.
69 | string dllPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
70 |
71 | IconFolder = System.IO.Path.Combine(dllPath, IconFolder);
72 | }
73 | }
74 |
75 | // Get the images from the specified icon folder.
76 | stdole.IPictureDisp iPicDisp16x16 = null;
77 | stdole.IPictureDisp iPicDisp32x32 = null;
78 | if (!string.IsNullOrEmpty(IconFolder))
79 | {
80 | if (System.IO.Directory.Exists(IconFolder))
81 | {
82 | string filename16x16 = System.IO.Path.Combine(IconFolder, "16x16.png");
83 | string filename32x32 = System.IO.Path.Combine(IconFolder, "32x32.png");
84 |
85 | if (System.IO.File.Exists(filename16x16))
86 | {
87 | try
88 | {
89 | System.Drawing.Bitmap image16x16 = new System.Drawing.Bitmap(filename16x16);
90 | iPicDisp16x16 = ConvertImage.ConvertImageToIPictureDisp(image16x16);
91 | }
92 | catch (Exception ex)
93 | {
94 | MessageBox.Show("Unable to load the 16x16.png image from \"" + IconFolder + "\"." + System.Environment.NewLine + "No small icon will be used.", "Error Loading Icon" + ex.Message);
95 | }
96 | }
97 | else
98 | MessageBox.Show("The icon for the small button does not exist: \"" + filename16x16 + "\"." + System.Environment.NewLine + "No small icon will be used.", "Error Loading Icon");
99 |
100 | if (System.IO.File.Exists(filename32x32))
101 | {
102 | try
103 | {
104 | System.Drawing.Bitmap image32x32 = new System.Drawing.Bitmap(filename32x32);
105 | iPicDisp32x32 = ConvertImage.ConvertImageToIPictureDisp(image32x32);
106 | }
107 | catch (Exception ex)
108 | {
109 | MessageBox.Show("Unable to load the 32x32.png image from \"" + IconFolder + "\"." + System.Environment.NewLine + "No large icon will be used.", "Error Loading Icon" + ex.Message);
110 | }
111 | }
112 | else
113 | MessageBox.Show("The icon for the large button does not exist: \"" + filename32x32 + "\"." + System.Environment.NewLine + "No large icon will be used.", "Error Loading Icon");
114 | }
115 | }
116 |
117 | try
118 | {
119 | // Get the ControlDefinitions collection.
120 | ControlDefinitions controlDefs = Globals.invApp.CommandManager.ControlDefinitions;
121 |
122 | // Create the command defintion.
123 | ButtonDefinition btnDef = controlDefs.AddButtonDefinition(DisplayName, InternalName, Inventor.CommandTypesEnum.kShapeEditCmdType, Globals.g_addInClientID, "", ToolTip, iPicDisp16x16, iPicDisp32x32);
124 |
125 | return btnDef;
126 | }
127 | catch (Exception ex)
128 | {
129 | MessageBox.Show("Couldn't set up btnDef: " + ex.Message);
130 | return null;
131 | }
132 | }
133 |
134 | public static Inventor.ComboBoxDefinition CreateComboBoxDefinition(string DisplayName,
135 | string InternalName,
136 | int comboWidth = 100,
137 | string ToolTip = "",
138 | string IconFolder = "")
139 | {
140 | // Check to see if a command already exists is the specified internal name.
141 | Inventor.ButtonDefinition testDef = null;
142 | try
143 | {
144 | testDef = (Inventor.ButtonDefinition)Globals.invApp.CommandManager.ControlDefinitions[InternalName];
145 | }
146 | catch
147 | {
148 | // This needs to fail silently.
149 | }
150 |
151 | if (!(testDef == null))
152 | {
153 | MessageBox.Show("Error when loading the add-in \"INVENTOR_DrawingFiller\". A command already exists with the same internal name. Each add-in must have a unique internal name. Change the internal name in the call to CreateButtonDefinition.", "Title Block Filler Inventor Add-In");
154 | return null;
155 | }
156 |
157 | // Check to see if the provided folder is a full or relative path.
158 | if (!string.IsNullOrEmpty(IconFolder))
159 | {
160 | if (!System.IO.Directory.Exists(IconFolder))
161 | {
162 | // The folder provided doesn't exist, so assume it is a relative path and
163 | // build up the full path.
164 | string dllPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
165 |
166 | IconFolder = System.IO.Path.Combine(dllPath, IconFolder);
167 | }
168 | }
169 |
170 | // Get the images from the specified icon folder.
171 | stdole.IPictureDisp iPicDisp16x16 = null;
172 | stdole.IPictureDisp iPicDisp32x32 = null;
173 | if (!string.IsNullOrEmpty(IconFolder))
174 | {
175 | if (System.IO.Directory.Exists(IconFolder))
176 | {
177 | string filename16x16 = System.IO.Path.Combine(IconFolder, "16x16.png");
178 | string filename32x32 = System.IO.Path.Combine(IconFolder, "32x32.png");
179 |
180 | if (System.IO.File.Exists(filename16x16))
181 | {
182 | try
183 | {
184 | System.Drawing.Bitmap image16x16 = new System.Drawing.Bitmap(filename16x16);
185 | iPicDisp16x16 = ConvertImage.ConvertImageToIPictureDisp(image16x16);
186 | }
187 | catch (Exception ex)
188 | {
189 | MessageBox.Show("Unable to load the 16x16.png image from \"" + IconFolder + "\"." + System.Environment.NewLine + "No small icon will be used.", "Error Loading Icon" + ex.Message);
190 | }
191 | }
192 | else
193 | MessageBox.Show("The icon for the small button does not exist: \"" + filename16x16 + "\"." + System.Environment.NewLine + "No small icon will be used.", "Error Loading Icon");
194 |
195 | if (System.IO.File.Exists(filename32x32))
196 | {
197 | try
198 | {
199 | System.Drawing.Bitmap image32x32 = new System.Drawing.Bitmap(filename32x32);
200 | iPicDisp32x32 = ConvertImage.ConvertImageToIPictureDisp(image32x32);
201 | }
202 | catch (Exception ex)
203 | {
204 | MessageBox.Show("Unable to load the 32x32.png image from \"" + IconFolder + "\"." + System.Environment.NewLine + "No large icon will be used.", "Error Loading Icon" + ex.Message);
205 | }
206 | }
207 | else
208 | MessageBox.Show("The icon for the large button does not exist: \"" + filename32x32 + "\"." + System.Environment.NewLine + "No large icon will be used.", "Error Loading Icon");
209 | }
210 | }
211 |
212 | try
213 | {
214 | // Get the ControlDefinitions collection.
215 | ControlDefinitions controlDefs = Globals.invApp.CommandManager.ControlDefinitions;
216 |
217 | // Create the command defintion.
218 | ComboBoxDefinition comboDef = controlDefs.AddComboBoxDefinition(DisplayName,
219 | InternalName,
220 | Inventor.CommandTypesEnum.kShapeEditCmdType,
221 | comboWidth,
222 | Globals.g_addInClientID,
223 | "",
224 | ToolTip,
225 | iPicDisp16x16,
226 | iPicDisp32x32);
227 |
228 | return comboDef;
229 | }
230 | catch (Exception ex)
231 | {
232 | MessageBox.Show("Couldn't set up combodef: " + ex.Message);
233 | return null;
234 | }
235 | }
236 |
237 | // This class is used to wrap a Win32 hWnd as a .Net IWind32Window class.
238 | // This is primarily used for parenting a dialog to the Inventor window.
239 | // This provides the expected behavior when the Inventor window is collapsed
240 | // and activated.
241 | //
242 | // For example:
243 | // myForm.Show(New WindowWrapper(invApp.MainFrameHWND))
244 | //
245 | public class WindowWrapper : System.Windows.Forms.IWin32Window
246 | {
247 | public WindowWrapper(IntPtr handle)
248 | {
249 | _hwnd = handle;
250 | }
251 |
252 | public IntPtr Handle
253 | {
254 | get
255 | {
256 | return _hwnd;
257 | }
258 | }
259 |
260 | private IntPtr _hwnd;
261 | }
262 |
263 | // Class used to convert bitmaps and icons between their .Net native types
264 | // and an IPictureDisp object which is what the Inventor API requires.
265 |
266 | [System.Security.Permissions.PermissionSet
267 | (System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")]
268 | public class ConvertImage : System.Windows.Forms.AxHost
269 | {
270 | public ConvertImage()
271 | : base("59EE46BA-677D-4d20-BF10-8D8067CB8B32")
272 | {
273 | }
274 |
275 | public static stdole.IPictureDisp ConvertImageToIPictureDisp(System.Drawing.Image Image)
276 | {
277 | try
278 | {
279 | return (stdole.IPictureDisp)GetIPictureFromPicture(Image);
280 | }
281 | catch (Exception ex)
282 | {
283 | MessageBox.Show("Couldn't ConvertImageToIPictureDisp: " + ex.Message);
284 | return null;
285 | }
286 | }
287 |
288 | public static System.Drawing.Image ConvertIPictureDispToImage(stdole.IPictureDisp IPict)
289 | {
290 | try
291 | {
292 | return GetPictureFromIPictureDisp(IPict);
293 | }
294 | catch (Exception ex)
295 | {
296 | MessageBox.Show("Couldn't set up ConvertIPictureDispToImage: " + ex.Message);
297 | return null;
298 | }
299 | }
300 | }
301 | }
302 | }
--------------------------------------------------------------------------------
/templates/nifty-addin-sdk/Attribution.md:
--------------------------------------------------------------------------------
1 | This is a port of [Brian Ekin's](https://github.com/brianekins?tab=repositories) VB.Net Nifty Inventor Add-in template. You can read more about it at his [site](https://ekinssolutions.com/nifty_addin_template/).
--------------------------------------------------------------------------------
/templates/nifty-addin-sdk/Globals.cs:
--------------------------------------------------------------------------------
1 | public static class Globals
2 | {
3 | // Inventor application object.
4 | public static Inventor.Application invApp;
5 |
6 | // The unique ID for this add-in. If this add-in is copied to create a new add-in
7 | // you need to update this ID along with the ID in the .manifest file, the .addin file
8 | // and create a new ID for the typelib GUID in AssemblyInfo.vb
9 | public const string g_simpleAddInClientID = "97335E20-6FC6-4BA9-8862-441B9376CB0C";
10 |
11 | public const string g_addInClientID = "{" + g_simpleAddInClientID + "}";
12 | }
--------------------------------------------------------------------------------
/templates/nifty-addin-sdk/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "nifty-addin-sdk": {
4 | "commandName": "Executable",
5 | "executablePath": "C:\\Program Files\\Autodesk\\Inventor 2021\\Bin\\Inventor.exe"
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/templates/nifty-addin-sdk/Resources/Buttons/SampleIcon/16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/InventorCode/inventor-addin-templates/ba0c87ae38aa55077b89613302936b964fe85ccd/templates/nifty-addin-sdk/Resources/Buttons/SampleIcon/16x16.png
--------------------------------------------------------------------------------
/templates/nifty-addin-sdk/Resources/Buttons/SampleIcon/32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/InventorCode/inventor-addin-templates/ba0c87ae38aa55077b89613302936b964fe85ccd/templates/nifty-addin-sdk/Resources/Buttons/SampleIcon/32x32.png
--------------------------------------------------------------------------------
/templates/nifty-addin-sdk/StandardAddInServer.cs:
--------------------------------------------------------------------------------
1 | using Inventor;
2 | using System;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows.Forms;
6 |
7 | namespace InvAddin
8 | {
9 | ///
10 | /// This is the primary AddIn Server class that implements the ApplicationAddInServer interface
11 | /// that all Inventor AddIns are required to implement. The communication between Inventor and
12 | /// the AddIn is via the methods on this interface.
13 | ///
14 | [ProgId("InvAddin.StandardAddinServer")]
15 | [GuidAttribute(Globals.g_simpleAddInClientID)]
16 | public class StandardAddInServer : Inventor.ApplicationAddInServer
17 | {
18 | // *********************************************************************************
19 | // * The two declarations below are related to adding buttons to Inventor's UI.
20 | // * They can be deleted if this add-in doesn't have a UI and only runs in the
21 | // * background handling events.
22 | // *********************************************************************************
23 |
24 | // Declaration of the object for the UserInterfaceEvents to be able to handle
25 | // if the user resets the ribbon so the button can be added back in.
26 | private UserInterfaceEvents _m_uiEvents;
27 |
28 | public UserInterfaceEvents m_uiEvents
29 | {
30 | [MethodImpl(MethodImplOptions.Synchronized)]
31 | get
32 | {
33 | return _m_uiEvents;
34 | }
35 |
36 | [MethodImpl(MethodImplOptions.Synchronized)]
37 | set
38 | {
39 | if (_m_uiEvents != null)
40 | {
41 | _m_uiEvents.OnResetRibbonInterface -= m_uiEvents_OnResetRibbonInterface;
42 | }
43 |
44 | _m_uiEvents = value;
45 | if (_m_uiEvents != null)
46 | {
47 | _m_uiEvents.OnResetRibbonInterface += m_uiEvents_OnResetRibbonInterface;
48 | }
49 | }
50 | }
51 |
52 | // Declaration of the button definition with events to handle the click event.
53 | // For additional commands this declaration along with other sections of code
54 | // that apply to the button can be duplicated from this example.
55 | public class UI_Button
56 | {
57 | private ButtonDefinition _bd;
58 |
59 | public ButtonDefinition bd
60 | {
61 | [MethodImpl(MethodImplOptions.Synchronized)]
62 | get
63 | {
64 | return this._bd;
65 | }
66 |
67 | [MethodImpl(MethodImplOptions.Synchronized)]
68 | set
69 | {
70 | if (this._bd != null)
71 | {
72 | this._bd.OnExecute -= bd_OnExecute;
73 | }
74 |
75 | this._bd = value;
76 | if (this._bd != null)
77 | {
78 | this._bd.OnExecute += bd_OnExecute;
79 | }
80 | }
81 | }
82 |
83 | private void bd_OnExecute(NameValueMap Context)
84 | {
85 | // Link button clicks to their respective commands.
86 | switch (bd.InternalName)
87 | {
88 | case "dw_NewWithPathFromPart":
89 | MessageBox.Show(Globals.invApp.ActiveDocument.DisplayName);
90 | return;
91 |
92 | default:
93 | return;
94 | }
95 | }
96 | }
97 |
98 | public delegate ButtonDefinition CreateButton(string display_text, string internal_name, string icon_path);
99 |
100 | public ButtonDefinition button_template(string display_text, string internal_name, string icon_path)
101 | {
102 | UI_Button MyButton = new UI_Button();
103 | MyButton.bd = AddinUtilities.CreateButtonDefinition(display_text, internal_name, "", icon_path);
104 | return MyButton.bd;
105 | }
106 |
107 | // Declare all buttons here
108 | private ButtonDefinition Button01;
109 |
110 | // This method is called by Inventor when it loads the AddIn. The AddInSiteObject provides access
111 | // to the Inventor Application object. The FirstTime flag indicates if the AddIn is loaded for
112 | // the first time. However, with the introduction of the ribbon this argument is always true.
113 | public void Activate(ApplicationAddInSite addInSiteObject, bool firstTime)
114 | {
115 | try
116 | {
117 | // Initialize AddIn members.
118 | Globals.invApp = addInSiteObject.Application;
119 |
120 | // Connect to the user-interface events to handle a ribbon reset.
121 | m_uiEvents = Globals.invApp.UserInterfaceManager.UserInterfaceEvents;
122 |
123 | // *********************************************************************************
124 | // * The remaining code in this Sub is all for adding the add-in into Inventor's UI.
125 | // * It can be deleted if this add-in doesn't have a UI and only runs in the
126 | // * background handling events.
127 | // *********************************************************************************
128 |
129 | // ButtonName = create_button(display_text, internal_name, icon_path)
130 | CreateButton create_button = new CreateButton(button_template);
131 |
132 | Button01 = create_button("This is Display Text", "internal_name", @"Resources\Buttons\SampleIcon");
133 |
134 | // Add to the user interface, if it's the first time.
135 | // If this add-in doesn't have a UI but runs in the background listening
136 | // to events, you can delete this.
137 | if (firstTime)
138 | {
139 | AddToUserInterface();
140 | }
141 | }
142 | catch (Exception ex)
143 | {
144 | MessageBox.Show("Unexpected failure in the activation of the add-in... " + System.Environment.NewLine + System.Environment.NewLine + ex.Message);
145 | }
146 | }
147 |
148 | // This method is called by Inventor when the AddIn is unloaded. The AddIn will be
149 | // unloaded either manually by the user or when the Inventor session is terminated.
150 | public void Deactivate()
151 | {
152 | // Release objects.
153 | Button01 = null;
154 |
155 | m_uiEvents = null;
156 | Globals.invApp = null;
157 |
158 | //MessageBox.Show("Addin unloaded");
159 |
160 | GC.Collect();
161 | GC.WaitForPendingFinalizers();
162 | }
163 |
164 | // This property is provided to allow the AddIn to expose an API of its own to other
165 | // programs. Typically, this would be done by implementing the AddIn's API
166 | // interface in a class and returning that class object through this property.
167 | // Typically it's not used, like in this case, and returns Nothing.
168 | public object Automation
169 | {
170 | get
171 | {
172 | return null;
173 | }
174 | }
175 |
176 | // Note:this method is now obsolete, you should use the
177 | // ControlDefinition functionality for implementing commands.
178 | public void ExecuteCommand(int commandID)
179 | {
180 | }
181 |
182 | // Adds whatever is needed by this add-in to the user-interface. This is
183 | // called when the add-in loaded and also if the user interface is reset.
184 | private void AddToUserInterface()
185 | {
186 | #region Ribbon, Tabs, Panel setup
187 |
188 | // Get the ribbon. (more buttons can be added to various ribbons within this single addin)
189 | // Ribbons:
190 | // ZeroDoc
191 | // Part
192 | // Assembly
193 | // Drawing
194 | // Presentation
195 | // iFeatures
196 | // UnknownDocument
197 | //Ribbon asmRibbon = Globals.invApp.UserInterfaceManager.Ribbons["Assembly"];
198 | Ribbon partRibbon = Globals.invApp.UserInterfaceManager.Ribbons["Part"];
199 |
200 | // Set up Tabs.
201 | // tab = setup_panel(display_name, internal_name, inv_ribbon)
202 | RibbonTab MyTab_part;
203 | MyTab_part = setup_tab("Tools", "id_TabTools", partRibbon);
204 |
205 | // Set up Panels.
206 | // panel = setup_panel(display_name, internal_name, ribbon_tab)
207 |
208 | RibbonPanel MyPanel_part;
209 | MyPanel_part = setup_panel("Sample AddIn", "id_TabTools", MyTab_part);
210 |
211 | #endregion Ribbon, Tabs, Panel setup
212 |
213 | // Part panel buttons
214 | if (!(Button01 == null))
215 | {
216 | MyPanel_part.CommandControls.AddButton(Button01, false);
217 | }
218 | }
219 |
220 | private RibbonTab setup_tab(string display_name, string internal_name, Ribbon inv_ribbon)
221 | {
222 | RibbonTab setup_tabRet = default(RibbonTab);
223 | RibbonTab ribbon_tab = null;
224 | try
225 | {
226 | ribbon_tab = inv_ribbon.RibbonTabs[internal_name];
227 | }
228 | catch (Exception)
229 | {
230 | //MessageBox.Show("Couldn't set up tab: " + ex.Message);
231 | }
232 |
233 | if (ribbon_tab == null)
234 | {
235 | ribbon_tab = inv_ribbon.RibbonTabs.Add(display_name, internal_name, Globals.g_addInClientID);
236 | }
237 |
238 | setup_tabRet = ribbon_tab;
239 | return setup_tabRet;
240 | }
241 |
242 | private RibbonPanel setup_panel(string display_name, string internal_name, RibbonTab ribbon_tab)
243 | {
244 | RibbonPanel setup_panelRet = default(RibbonPanel);
245 | RibbonPanel ribbon_panel = null;
246 | try
247 | {
248 | ribbon_panel = ribbon_tab.RibbonPanels[internal_name];
249 | }
250 | catch (Exception)
251 | {
252 | //MessageBox.Show("Couldn't set up panel: " + ex.Message);
253 | }
254 |
255 | if (ribbon_panel == null)
256 | {
257 | ribbon_panel = ribbon_tab.RibbonPanels.Add(display_name, internal_name, Globals.g_addInClientID);
258 | }
259 |
260 | setup_panelRet = ribbon_panel;
261 | return setup_panelRet;
262 | }
263 |
264 | private void m_uiEvents_OnResetRibbonInterface(NameValueMap Context)
265 | {
266 | // The ribbon was reset, so add back the add-ins user-interface.
267 | AddToUserInterface();
268 | }
269 | }
270 | }
--------------------------------------------------------------------------------
/templates/nifty-addin-sdk/addin.manifest:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/templates/nifty-addin-sdk/nifty-addin-sdk.addin:
--------------------------------------------------------------------------------
1 |
2 |
3 | {97335E20-6FC6-4BA9-8862-441B9376CB0C}
4 | {97335E20-6FC6-4BA9-8862-441B9376CB0C}
5 | nifty-addin-sdk
6 | Addin description
7 | nifty-addin-sdk.dll
8 | 1
9 | 1
10 | 0
11 | 15..
12 | 1
13 | 1
14 |
--------------------------------------------------------------------------------
/templates/nifty-addin-sdk/nifty-addin-sdk.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net48
4 | InvAddin
5 | addin.manifest
6 | 0.2.0.0
7 | 0.2.0.0
8 | 0.2.0+23.Branch.master.Sha.b53ea4a54bba15afa4798c9baf6b116cf497226f
9 | 0.2.0
10 |
11 |
12 | nifty-addin-sdk
13 | false
14 | addin author
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | ..\..\..\..\..\..\..\..\Program Files\Autodesk\Inventor 2021\Bin\Public Assemblies\Autodesk.Inventor.Interop.dll
23 |
24 |
25 | ..\..\..\..\..\..\..\..\Windows\assembly\GAC\stdole\7.0.3300.0__b03f5f7f11d50a3a\stdole.dll
26 |
27 |
28 |
29 |
30 |
31 | PreserveNewest
32 |
33 |
34 | PreserveNewest
35 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/templates/wpf-window-addin/.template.config/Globals.cs:
--------------------------------------------------------------------------------
1 | public static class Globals
2 | {
3 | // Inventor application object.
4 | public static Inventor.Application invApp;
5 |
6 | // The unique ID for this add-in. If this add-in is copied to create a new add-in
7 | // you need to update this ID along with the ID in the .manifest file, the .addin file
8 | // and create a new ID for the typelib GUID in AssemblyInfo.vb
9 | public const string g_simpleAddInClientID = "05D13420-B80E-4021-97B8-A3A8934A5731";
10 |
11 | public const string g_addInClientID = "{" + g_simpleAddInClientID + "}";
12 | }
--------------------------------------------------------------------------------
/templates/wpf-window-addin/.template.config/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/InventorCode/inventor-addin-templates/ba0c87ae38aa55077b89613302936b964fe85ccd/templates/wpf-window-addin/.template.config/icon.png
--------------------------------------------------------------------------------
/templates/wpf-window-addin/.template.config/ide.host.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/vs-2017.3.host",
3 | "icon":"icon.png",
4 | "symbolInfo": [
5 | {
6 | "id": "namespace",
7 | "name": {
8 | "text": "Default namespace"
9 | },
10 | "isVisible": "true"
11 | },
12 | {
13 | "id": "product",
14 | "name": {
15 | "text": "Product Name"
16 | },
17 | "isVisible": "true"
18 | },
19 | {
20 | "id": "description",
21 | "name": {
22 | "text": "Addin description"
23 | },
24 | "isVisible": "true"
25 | },
26 | {
27 | "id": "author",
28 | "name": {
29 | "text": "Author"
30 | },
31 | "isVisible": "true"
32 | },
33 | {
34 | "id": "company",
35 | "name": {
36 | "text": "Company Name"
37 | },
38 | "isVisible": "true"
39 | }
40 | ]
41 | }
--------------------------------------------------------------------------------
/templates/wpf-window-addin/.template.config/template.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "http://json.schemastore.org/template",
3 | "author": "Matthew D. Jordan",
4 | "classifications": ["Desktop"],
5 | "name": "Inventor WPF window Addin (SDK)",
6 | "shortName": "inv-wpf",
7 | "default": "InventorAddin",
8 | "identity": "InventorCode.addin.wpf.csharp01",
9 | "tags": {
10 | "language": "C#",
11 | "type": "project"
12 | },
13 | "sourceName":"wpf-window-addin",
14 | "defaultName":"WpfWindowAddin",
15 | "preferNameDirectory": true,
16 | "guids": [
17 | "05D13420-B80E-4021-97B8-A3A8934A5731"
18 | ],
19 | "symbols": {
20 | "Framework": {
21 | "type": "parameter",
22 | "description": "The target framework for the project.",
23 | "datatype": "choice",
24 | "choices": [
25 | {
26 | "choice": "net48",
27 | "description": "Target .NET Framework 4.8"
28 | },
29 | {
30 | "choice": "net47",
31 | "description": "Target .NET Framework 4.7"
32 | }
33 | ],
34 | "replaces": "net48",
35 | "defaultValue": "net48"
36 | },
37 | "namespace": {
38 | "type": "parameter",
39 | "datatype": "text",
40 | "description": "Namespace",
41 | "replaces": "InvAddin",
42 | "defaultValue": "InvAddin"
43 | },
44 | "product": {
45 | "type": "parameter",
46 | "datatype": "text",
47 | "description": "Product Name",
48 | "replaces": "product name",
49 | "defaultValue": ""
50 | },
51 | "description": {
52 | "type": "parameter",
53 | "datatype": "text",
54 | "description": "Addin Description",
55 | "replaces": "addin description",
56 | "defaultValue": ""
57 | },
58 | "company": {
59 | "type": "parameter",
60 | "datatype": "text",
61 | "description": "Company Name",
62 | "replaces": "company name",
63 | "defaultValue": ""
64 | },
65 | "author": {
66 | "type": "parameter",
67 | "datatype": "text",
68 | "description": "Author",
69 | "replaces": "author name",
70 | "defaultValue": ""
71 | },
72 | "copyright": {
73 | "type": "parameter",
74 | "datatype": "text",
75 | "description": "Copyright",
76 | "replaces": "copyright text",
77 | "defaultValue": ""
78 | }
79 | }
80 | }
--------------------------------------------------------------------------------
/templates/wpf-window-addin/Addin/AddinUtilities.cs:
--------------------------------------------------------------------------------
1 | using Inventor;
2 | using System;
3 | using System.Windows.Forms;
4 |
5 | namespace InvAddin.Addin
6 | {
7 | public static class AddinUtilities
8 | {
9 | ///
10 | /// Function to simplify the creation of a button definition. The big advantage
11 | /// to using this function is that you don't have to deal with converting images
12 | /// but instead just reference a folder on disk where this routine reads the images.
13 | ///
14 | ///
15 | /// The name of the command as it will be displayed on the button.
16 | ///
17 | ///
18 | /// The internal name of the command. This needs to be unique with respect to ALL other
19 | /// commands. It's best to incorporate a to help with uniqueness.
20 | ///
21 | ///
22 | /// The tooltip that will be used for the command.
23 | ///
24 | /// This is optional and the display name will be used as the
25 | /// tooltip if no tooltip is specified. Like in the DisplayName argument, you can use
26 | /// returns to force line breaks.
27 | ///
28 | ///
29 | /// The folder that contains the icon files. This can be a full path or a path that is
30 | /// relative to the location of the add-in dll. The folder should contain the files
31 | /// 16x16.png and 32x32.png. Each command will have its own folder so they can have
32 | /// their own icons.
33 | ///
34 | /// This is optional and if no icon is specified then no icon will be displayed on the
35 | /// button and it will be only text.
36 | ///
37 | ///
38 | /// Returns the newly created button definition or Nothing in case of failure.
39 | ///
40 | public static Inventor.ButtonDefinition CreateButtonDefinition(string DisplayName,
41 | string InternalName,
42 | string ToolTip = "",
43 | string IconFolder = "")
44 | {
45 | // Check to see if a command already exists is the specified internal name.
46 | Inventor.ButtonDefinition testDef = null;
47 | try
48 | {
49 | testDef = (Inventor.ButtonDefinition)Globals.invApp.CommandManager.ControlDefinitions[InternalName];
50 | }
51 | catch
52 | {
53 | // This needs to fail silently.
54 | }
55 |
56 | if (!(testDef == null))
57 | {
58 | MessageBox.Show("Error when loading the add-in \"INVENTOR_DrawingFiller\". A command already exists with the same internal name. Each add-in must have a unique internal name. Change the internal name in the call to CreateButtonDefinition.", "Title Block Filler Inventor Add-In");
59 | return null;
60 | }
61 |
62 | // Check to see if the provided folder is a full or relative path.
63 | if (!string.IsNullOrEmpty(IconFolder))
64 | {
65 | if (!System.IO.Directory.Exists(IconFolder))
66 | {
67 | // The folder provided doesn't exist, so assume it is a relative path and
68 | // build up the full path.
69 | string dllPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
70 |
71 | IconFolder = System.IO.Path.Combine(dllPath, IconFolder);
72 | }
73 | }
74 |
75 | // Get the images from the specified icon folder.
76 | stdole.IPictureDisp iPicDisp16x16 = null;
77 | stdole.IPictureDisp iPicDisp32x32 = null;
78 | if (!string.IsNullOrEmpty(IconFolder))
79 | {
80 | if (System.IO.Directory.Exists(IconFolder))
81 | {
82 | string filename16x16 = System.IO.Path.Combine(IconFolder, "16x16.png");
83 | string filename32x32 = System.IO.Path.Combine(IconFolder, "32x32.png");
84 |
85 | if (System.IO.File.Exists(filename16x16))
86 | {
87 | try
88 | {
89 | System.Drawing.Bitmap image16x16 = new System.Drawing.Bitmap(filename16x16);
90 | iPicDisp16x16 = ConvertImage.ConvertImageToIPictureDisp(image16x16);
91 | }
92 | catch (Exception ex)
93 | {
94 | MessageBox.Show("Unable to load the 16x16.png image from \"" + IconFolder + "\"." + System.Environment.NewLine + "No small icon will be used.", "Error Loading Icon" + ex.Message);
95 | }
96 | }
97 | else
98 | MessageBox.Show("The icon for the small button does not exist: \"" + filename16x16 + "\"." + System.Environment.NewLine + "No small icon will be used.", "Error Loading Icon");
99 |
100 | if (System.IO.File.Exists(filename32x32))
101 | {
102 | try
103 | {
104 | System.Drawing.Bitmap image32x32 = new System.Drawing.Bitmap(filename32x32);
105 | iPicDisp32x32 = ConvertImage.ConvertImageToIPictureDisp(image32x32);
106 | }
107 | catch (Exception ex)
108 | {
109 | MessageBox.Show("Unable to load the 32x32.png image from \"" + IconFolder + "\"." + System.Environment.NewLine + "No large icon will be used.", "Error Loading Icon" + ex.Message);
110 | }
111 | }
112 | else
113 | MessageBox.Show("The icon for the large button does not exist: \"" + filename32x32 + "\"." + System.Environment.NewLine + "No large icon will be used.", "Error Loading Icon");
114 | }
115 | }
116 |
117 | try
118 | {
119 | // Get the ControlDefinitions collection.
120 | ControlDefinitions controlDefs = Globals.invApp.CommandManager.ControlDefinitions;
121 |
122 | // Create the command defintion.
123 | ButtonDefinition btnDef = controlDefs.AddButtonDefinition(DisplayName, InternalName, Inventor.CommandTypesEnum.kShapeEditCmdType, Globals.g_addInClientID, "", ToolTip, iPicDisp16x16, iPicDisp32x32);
124 |
125 | return btnDef;
126 | }
127 | catch (Exception ex)
128 | {
129 | MessageBox.Show("Couldn't set up btnDef: " + ex.Message);
130 | return null;
131 | }
132 | }
133 |
134 | public static Inventor.ComboBoxDefinition CreateComboBoxDefinition(string DisplayName,
135 | string InternalName,
136 | int comboWidth = 100,
137 | string ToolTip = "",
138 | string IconFolder = "")
139 | {
140 | // Check to see if a command already exists is the specified internal name.
141 | Inventor.ButtonDefinition testDef = null;
142 | try
143 | {
144 | testDef = (Inventor.ButtonDefinition)Globals.invApp.CommandManager.ControlDefinitions[InternalName];
145 | }
146 | catch
147 | {
148 | // This needs to fail silently.
149 | }
150 |
151 | if (!(testDef == null))
152 | {
153 | MessageBox.Show("Error when loading the add-in \"INVENTOR_DrawingFiller\". A command already exists with the same internal name. Each add-in must have a unique internal name. Change the internal name in the call to CreateButtonDefinition.", "Title Block Filler Inventor Add-In");
154 | return null;
155 | }
156 |
157 | // Check to see if the provided folder is a full or relative path.
158 | if (!string.IsNullOrEmpty(IconFolder))
159 | {
160 | if (!System.IO.Directory.Exists(IconFolder))
161 | {
162 | // The folder provided doesn't exist, so assume it is a relative path and
163 | // build up the full path.
164 | string dllPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
165 |
166 | IconFolder = System.IO.Path.Combine(dllPath, IconFolder);
167 | }
168 | }
169 |
170 | // Get the images from the specified icon folder.
171 | stdole.IPictureDisp iPicDisp16x16 = null;
172 | stdole.IPictureDisp iPicDisp32x32 = null;
173 | if (!string.IsNullOrEmpty(IconFolder))
174 | {
175 | if (System.IO.Directory.Exists(IconFolder))
176 | {
177 | string filename16x16 = System.IO.Path.Combine(IconFolder, "16x16.png");
178 | string filename32x32 = System.IO.Path.Combine(IconFolder, "32x32.png");
179 |
180 | if (System.IO.File.Exists(filename16x16))
181 | {
182 | try
183 | {
184 | System.Drawing.Bitmap image16x16 = new System.Drawing.Bitmap(filename16x16);
185 | iPicDisp16x16 = ConvertImage.ConvertImageToIPictureDisp(image16x16);
186 | }
187 | catch (Exception ex)
188 | {
189 | MessageBox.Show("Unable to load the 16x16.png image from \"" + IconFolder + "\"." + System.Environment.NewLine + "No small icon will be used.", "Error Loading Icon" + ex.Message);
190 | }
191 | }
192 | else
193 | MessageBox.Show("The icon for the small button does not exist: \"" + filename16x16 + "\"." + System.Environment.NewLine + "No small icon will be used.", "Error Loading Icon");
194 |
195 | if (System.IO.File.Exists(filename32x32))
196 | {
197 | try
198 | {
199 | System.Drawing.Bitmap image32x32 = new System.Drawing.Bitmap(filename32x32);
200 | iPicDisp32x32 = ConvertImage.ConvertImageToIPictureDisp(image32x32);
201 | }
202 | catch (Exception ex)
203 | {
204 | MessageBox.Show("Unable to load the 32x32.png image from \"" + IconFolder + "\"." + System.Environment.NewLine + "No large icon will be used.", "Error Loading Icon" + ex.Message);
205 | }
206 | }
207 | else
208 | MessageBox.Show("The icon for the large button does not exist: \"" + filename32x32 + "\"." + System.Environment.NewLine + "No large icon will be used.", "Error Loading Icon");
209 | }
210 | }
211 |
212 | try
213 | {
214 | // Get the ControlDefinitions collection.
215 | ControlDefinitions controlDefs = Globals.invApp.CommandManager.ControlDefinitions;
216 |
217 | // Create the command defintion.
218 | ComboBoxDefinition comboDef = controlDefs.AddComboBoxDefinition(DisplayName,
219 | InternalName,
220 | Inventor.CommandTypesEnum.kShapeEditCmdType,
221 | comboWidth,
222 | Globals.g_addInClientID,
223 | "",
224 | ToolTip,
225 | iPicDisp16x16,
226 | iPicDisp32x32);
227 |
228 | return comboDef;
229 | }
230 | catch (Exception ex)
231 | {
232 | MessageBox.Show("Couldn't set up combodef: " + ex.Message);
233 | return null;
234 | }
235 | }
236 |
237 | // This class is used to wrap a Win32 hWnd as a .Net IWind32Window class.
238 | // This is primarily used for parenting a dialog to the Inventor window.
239 | // This provides the expected behavior when the Inventor window is collapsed
240 | // and activated.
241 | //
242 | // For example:
243 | // myForm.Show(New WindowWrapper(invApp.MainFrameHWND))
244 | //
245 | public class WindowWrapper : System.Windows.Forms.IWin32Window
246 | {
247 | public WindowWrapper(IntPtr handle)
248 | {
249 | _hwnd = handle;
250 | }
251 |
252 | public IntPtr Handle
253 | {
254 | get
255 | {
256 | return _hwnd;
257 | }
258 | }
259 |
260 | private IntPtr _hwnd;
261 | }
262 |
263 | // Class used to convert bitmaps and icons between their .Net native types
264 | // and an IPictureDisp object which is what the Inventor API requires.
265 |
266 | [System.Security.Permissions.PermissionSet
267 | (System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")]
268 | public class ConvertImage : System.Windows.Forms.AxHost
269 | {
270 | public ConvertImage()
271 | : base("59EE46BA-677D-4d20-BF10-8D8067CB8B32")
272 | {
273 | }
274 |
275 | public static stdole.IPictureDisp ConvertImageToIPictureDisp(System.Drawing.Image Image)
276 | {
277 | try
278 | {
279 | return (stdole.IPictureDisp)GetIPictureFromPicture(Image);
280 | }
281 | catch (Exception ex)
282 | {
283 | MessageBox.Show("Couldn't ConvertImageToIPictureDisp: " + ex.Message);
284 | return null;
285 | }
286 | }
287 |
288 | public static System.Drawing.Image ConvertIPictureDispToImage(stdole.IPictureDisp IPict)
289 | {
290 | try
291 | {
292 | return GetPictureFromIPictureDisp(IPict);
293 | }
294 | catch (Exception ex)
295 | {
296 | MessageBox.Show("Couldn't set up ConvertIPictureDispToImage: " + ex.Message);
297 | return null;
298 | }
299 | }
300 | }
301 | }
302 | }
--------------------------------------------------------------------------------
/templates/wpf-window-addin/Addin/Globals.cs:
--------------------------------------------------------------------------------
1 | namespace InvAddin.Addin
2 | {
3 | public static class Globals
4 | {
5 | // Inventor application object.
6 | public static Inventor.Application invApp;
7 |
8 | // The unique ID for this add-in. If this add-in is copied to create a new add-in
9 | // you need to update this ID along with the ID in the .manifest file, the .addin file
10 | // and create a new ID for the typelib GUID in AssemblyInfo.vb
11 | public const string g_simpleAddInClientID = "05D13420-B80E-4021-97B8-A3A8934A5731";
12 |
13 | public const string g_addInClientID = "{" + g_simpleAddInClientID + "}";
14 | }
15 | }
--------------------------------------------------------------------------------
/templates/wpf-window-addin/Properties/launchSettings.json:
--------------------------------------------------------------------------------
1 | {
2 | "profiles": {
3 | "wpf-window-addin": {
4 | "commandName": "Executable",
5 | "executablePath": "C:\\Program Files\\Autodesk\\Inventor 2021\\Bin\\Inventor.exe"
6 | }
7 | }
8 | }
--------------------------------------------------------------------------------
/templates/wpf-window-addin/Resources/Buttons/SampleIcon/16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/InventorCode/inventor-addin-templates/ba0c87ae38aa55077b89613302936b964fe85ccd/templates/wpf-window-addin/Resources/Buttons/SampleIcon/16x16.png
--------------------------------------------------------------------------------
/templates/wpf-window-addin/Resources/Buttons/SampleIcon/32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/InventorCode/inventor-addin-templates/ba0c87ae38aa55077b89613302936b964fe85ccd/templates/wpf-window-addin/Resources/Buttons/SampleIcon/32x32.png
--------------------------------------------------------------------------------
/templates/wpf-window-addin/StandardAddInServer.cs:
--------------------------------------------------------------------------------
1 | using InvAddin.Addin;
2 | using Inventor;
3 | using System;
4 | using System.Runtime.CompilerServices;
5 | using System.Runtime.InteropServices;
6 | using System.Windows.Interop;
7 |
8 | namespace InvAddin
9 | {
10 | ///
11 | /// This is the primary AddIn Server class that implements the ApplicationAddInServer interface
12 | /// that all Inventor AddIns are required to implement. The communication between Inventor and
13 | /// the AddIn is via the methods on this interface.
14 | ///
15 | [ProgId("InvAddin.StandardAddinServer")]
16 | [GuidAttribute(Globals.g_simpleAddInClientID)]
17 | public class StandardAddInServer : Inventor.ApplicationAddInServer
18 | {
19 | // *********************************************************************************
20 | // * The two declarations below are related to adding buttons to Inventor's UI.
21 | // * They can be deleted if this add-in doesn't have a UI and only runs in the
22 | // * background handling events.
23 | // *********************************************************************************
24 |
25 | // Declaration of the object for the UserInterfaceEvents to be able to handle
26 | // if the user resets the ribbon so the button can be added back in.
27 | private UserInterfaceEvents _m_uiEvents;
28 |
29 | public UserInterfaceEvents m_uiEvents
30 | {
31 | [MethodImpl(MethodImplOptions.Synchronized)]
32 | get
33 | {
34 | return _m_uiEvents;
35 | }
36 |
37 | [MethodImpl(MethodImplOptions.Synchronized)]
38 | set
39 | {
40 | if (_m_uiEvents != null)
41 | {
42 | _m_uiEvents.OnResetRibbonInterface -= m_uiEvents_OnResetRibbonInterface;
43 | }
44 |
45 | _m_uiEvents = value;
46 | if (_m_uiEvents != null)
47 | {
48 | _m_uiEvents.OnResetRibbonInterface += m_uiEvents_OnResetRibbonInterface;
49 | }
50 | }
51 | }
52 |
53 | // Declaration of the button definition with events to handle the click event.
54 | // For additional commands this declaration along with other sections of code
55 | // that apply to the button can be duplicated from this example.
56 | public class UI_Button
57 | {
58 | private ButtonDefinition _bd;
59 |
60 | public ButtonDefinition bd
61 | {
62 | [MethodImpl(MethodImplOptions.Synchronized)]
63 | get
64 | {
65 | return this._bd;
66 | }
67 |
68 | [MethodImpl(MethodImplOptions.Synchronized)]
69 | set
70 | {
71 | if (this._bd != null)
72 | {
73 | this._bd.OnExecute -= bd_OnExecute;
74 | }
75 |
76 | this._bd = value;
77 | if (this._bd != null)
78 | {
79 | this._bd.OnExecute += bd_OnExecute;
80 | }
81 | }
82 | }
83 |
84 | private void bd_OnExecute(NameValueMap Context)
85 | {
86 | // Link button clicks to their respective commands.
87 | switch (bd.InternalName)
88 | {
89 | case "hello-world-button":
90 | ShowMainWindow();
91 | return;
92 |
93 | default:
94 | return;
95 | }
96 | }
97 |
98 | private void ShowMainWindow()
99 | {
100 | var mainWindow = new Views.MainWindow();
101 |
102 | //could be a good idea to set the owner for this window, esp. if it's used in a modeless way...
103 | var helper = new WindowInteropHelper(mainWindow);
104 | helper.Owner = new IntPtr(Globals.invApp.MainFrameHWND);
105 |
106 | mainWindow.ShowDialog();
107 | }
108 | }
109 |
110 | public delegate ButtonDefinition CreateButton(string display_text, string internal_name, string icon_path);
111 |
112 | public ButtonDefinition button_template(string display_text, string internal_name, string icon_path)
113 | {
114 | UI_Button MyButton = new UI_Button();
115 | MyButton.bd = AddinUtilities.CreateButtonDefinition(display_text, internal_name, "", icon_path);
116 | return MyButton.bd;
117 | }
118 |
119 | // Declare all buttons here
120 | private ButtonDefinition Button01;
121 |
122 | // This method is called by Inventor when it loads the AddIn. The AddInSiteObject provides access
123 | // to the Inventor Application object. The FirstTime flag indicates if the AddIn is loaded for
124 | // the first time. However, with the introduction of the ribbon this argument is always true.
125 | public void Activate(ApplicationAddInSite addInSiteObject, bool firstTime)
126 | {
127 | try
128 | {
129 | // Initialize AddIn members.
130 | Globals.invApp = addInSiteObject.Application;
131 |
132 | // Connect to the user-interface events to handle a ribbon reset.
133 | m_uiEvents = Globals.invApp.UserInterfaceManager.UserInterfaceEvents;
134 |
135 | // *********************************************************************************
136 | // * The remaining code in this Sub is all for adding the add-in into Inventor's UI.
137 | // * It can be deleted if this add-in doesn't have a UI and only runs in the
138 | // * background handling events.
139 | // *********************************************************************************
140 |
141 | // ButtonName = create_button(display_text, internal_name, icon_path)
142 | CreateButton create_button = new CreateButton(button_template);
143 |
144 | Button01 = create_button("Hello World", "hello-world-button", @"Resources\Buttons\SampleIcon");
145 |
146 | // Add to the user interface, if it's the first time.
147 | // If this add-in doesn't have a UI but runs in the background listening
148 | // to events, you can delete this.
149 | if (firstTime)
150 | {
151 | AddToUserInterface();
152 | }
153 | }
154 | catch (Exception ex)
155 | {
156 | throw new SystemException("Unexpected failure in the activation of the add-in... " + System.Environment.NewLine + System.Environment.NewLine + ex.Message);
157 | }
158 | }
159 |
160 | // This method is called by Inventor when the AddIn is unloaded. The AddIn will be
161 | // unloaded either manually by the user or when the Inventor session is terminated.
162 | public void Deactivate()
163 | {
164 | // Release objects.
165 | Button01 = null;
166 |
167 | m_uiEvents = null;
168 | Globals.invApp = null;
169 |
170 | //MessageBox.Show("Addin unloaded");
171 |
172 | GC.Collect();
173 | GC.WaitForPendingFinalizers();
174 | }
175 |
176 | // This property is provided to allow the AddIn to expose an API of its own to other
177 | // programs. Typically, this would be done by implementing the AddIn's API
178 | // interface in a class and returning that class object through this property.
179 | // Typically it's not used, like in this case, and returns Nothing.
180 | public object Automation
181 | {
182 | get
183 | {
184 | return null;
185 | }
186 | }
187 |
188 | // Note:this method is now obsolete, you should use the
189 | // ControlDefinition functionality for implementing commands.
190 | public void ExecuteCommand(int commandID)
191 | {
192 | }
193 |
194 | // Adds whatever is needed by this add-in to the user-interface. This is
195 | // called when the add-in loaded and also if the user interface is reset.
196 | private void AddToUserInterface()
197 | {
198 | #region Ribbon, Tabs, Panel setup
199 |
200 | // Get the ribbon. (more buttons can be added to various ribbons within this single addin)
201 | // Ribbons:
202 | // ZeroDoc
203 | // Part
204 | // Assembly
205 | // Drawing
206 | // Presentation
207 | // iFeatures
208 | // UnknownDocument
209 | //Ribbon asmRibbon = Globals.invApp.UserInterfaceManager.Ribbons["Assembly"];
210 | Ribbon partRibbon = Globals.invApp.UserInterfaceManager.Ribbons["Part"];
211 |
212 | // Set up Tabs.
213 | // tab = setup_panel(display_name, internal_name, inv_ribbon)
214 | RibbonTab MyTab_part;
215 | MyTab_part = setup_tab("Tools", "id_TabTools", partRibbon);
216 |
217 | // Set up Panels.
218 | // panel = setup_panel(display_name, internal_name, ribbon_tab)
219 |
220 | RibbonPanel MyPanel_part;
221 | MyPanel_part = setup_panel("Sample AddIn", "id_TabTools", MyTab_part);
222 |
223 | #endregion Ribbon, Tabs, Panel setup
224 |
225 | // Part panel buttons
226 | if (!(Button01 == null))
227 | {
228 | MyPanel_part.CommandControls.AddButton(Button01, false);
229 | }
230 | }
231 |
232 | private RibbonTab setup_tab(string display_name, string internal_name, Ribbon inv_ribbon)
233 | {
234 | RibbonTab setup_tabRet = default(RibbonTab);
235 | RibbonTab ribbon_tab = null;
236 | try
237 | {
238 | ribbon_tab = inv_ribbon.RibbonTabs[internal_name];
239 | }
240 | catch (Exception)
241 | {
242 | //MessageBox.Show("Couldn't set up tab: " + ex.Message);
243 | }
244 |
245 | if (ribbon_tab == null)
246 | {
247 | ribbon_tab = inv_ribbon.RibbonTabs.Add(display_name, internal_name, Globals.g_addInClientID);
248 | }
249 |
250 | setup_tabRet = ribbon_tab;
251 | return setup_tabRet;
252 | }
253 |
254 | private RibbonPanel setup_panel(string display_name, string internal_name, RibbonTab ribbon_tab)
255 | {
256 | RibbonPanel setup_panelRet = default(RibbonPanel);
257 | RibbonPanel ribbon_panel = null;
258 | try
259 | {
260 | ribbon_panel = ribbon_tab.RibbonPanels[internal_name];
261 | }
262 | catch (Exception)
263 | {
264 | //MessageBox.Show("Couldn't set up panel: " + ex.Message);
265 | }
266 |
267 | if (ribbon_panel == null)
268 | {
269 | ribbon_panel = ribbon_tab.RibbonPanels.Add(display_name, internal_name, Globals.g_addInClientID);
270 | }
271 |
272 | setup_panelRet = ribbon_panel;
273 | return setup_panelRet;
274 | }
275 |
276 | private void m_uiEvents_OnResetRibbonInterface(NameValueMap Context)
277 | {
278 | // The ribbon was reset, so add back the add-ins user-interface.
279 | AddToUserInterface();
280 | }
281 | }
282 | }
--------------------------------------------------------------------------------
/templates/wpf-window-addin/ViewModels/BaseViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.ComponentModel;
3 |
4 | namespace InvAddin.ViewModels
5 | {
6 | public class BaseViewModel : INotifyPropertyChanged
7 | {
8 | public event PropertyChangedEventHandler PropertyChanged;
9 |
10 | protected void NotifyPropertyChanged(String info)
11 | {
12 | if (PropertyChanged != null)
13 | {
14 | PropertyChanged(this, new PropertyChangedEventArgs(info));
15 | }
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/templates/wpf-window-addin/ViewModels/MainWindowViewModel.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Input;
3 |
4 | namespace InvAddin.ViewModels
5 | {
6 | public class MainWindowViewModel : BaseViewModel
7 | {
8 | public ICommand CustomCommand { get; set; }
9 | public ICommand CloseCommand { get; set; }
10 | public Action CloseAction { get; set; } //assign Window.Close() to this Action in the View
11 |
12 | public MainWindowViewModel()
13 | {
14 | CustomCommand = new RelayCommand(o => GreetingText = "Goodbye!", o => true);
15 | CloseCommand = new RelayCommand(o => CloseAction(), o => true);
16 | }
17 |
18 | private string _greetingText = "Hello World!";
19 | public string GreetingText
20 | {
21 | get { return _greetingText; }
22 | set
23 | {
24 | _greetingText = value;
25 | NotifyPropertyChanged("GreetingText");
26 | }
27 | }
28 | }
29 | }
--------------------------------------------------------------------------------
/templates/wpf-window-addin/ViewModels/RelayCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Input;
3 |
4 | namespace InvAddin.ViewModels
5 | {
6 | public class RelayCommand : ICommand
7 | {
8 | private Action