├── .gitignore ├── LICENSE ├── My_CSharp_AddIn ├── My_CSharp_AddIn.sln └── My_CSharp_AddIn │ ├── AssemblyInfo.cs │ ├── Autodesk.My_CSharp_AddIn.Inventor.addin │ ├── ButtonResources │ ├── MyIcon1 │ │ ├── 16x16.png │ │ └── 32x32.png │ ├── MyIcon2 │ │ ├── 16x16.png │ │ └── 32x32.png │ ├── MyIcon3 │ │ ├── 16x16.png │ │ └── 32x32.png │ └── MyIcon4 │ │ ├── 16x16.png │ │ └── 32x32.png │ ├── CommandFunctions.cs │ ├── My Project │ ├── HideModuleName.cs │ ├── Settings.Designer.cs │ └── Settings.settings │ ├── My_CSharp_AddIn.csproj │ ├── My_CSharp_AddIn.manifest │ ├── Readme.txt │ ├── StandardAddInServer.cs │ ├── Utilities.cs │ └── app.config └── README.org /.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 | [Aa][Rr][Mm]/ 27 | [Aa][Rr][Mm]64/ 28 | bld/ 29 | [Bb]in/ 30 | [Oo]bj/ 31 | [Ll]og/ 32 | [Ll]ogs/ 33 | 34 | # Visual Studio 2015/2017 cache/options directory 35 | .vs/ 36 | # Uncomment if you have tasks that create the project's static files in wwwroot 37 | #wwwroot/ 38 | 39 | # Visual Studio 2017 auto generated files 40 | Generated\ Files/ 41 | 42 | # MSTest test Results 43 | [Tt]est[Rr]esult*/ 44 | [Bb]uild[Ll]og.* 45 | 46 | # NUnit 47 | *.VisualState.xml 48 | TestResult.xml 49 | nunit-*.xml 50 | 51 | # Build Results of an ATL Project 52 | [Dd]ebugPS/ 53 | [Rr]eleasePS/ 54 | dlldata.c 55 | 56 | # Benchmark Results 57 | BenchmarkDotNet.Artifacts/ 58 | 59 | # .NET Core 60 | project.lock.json 61 | project.fragment.lock.json 62 | artifacts/ 63 | 64 | # StyleCop 65 | StyleCopReport.xml 66 | 67 | # Files built by Visual Studio 68 | *_i.c 69 | *_p.c 70 | *_h.h 71 | *.ilk 72 | *.meta 73 | *.obj 74 | *.iobj 75 | *.pch 76 | *.pdb 77 | *.ipdb 78 | *.pgc 79 | *.pgd 80 | *.rsp 81 | *.sbr 82 | *.tlb 83 | *.tli 84 | *.tlh 85 | *.tmp 86 | *.tmp_proj 87 | *_wpftmp.csproj 88 | *.log 89 | *.vspscc 90 | *.vssscc 91 | .builds 92 | *.pidb 93 | *.svclog 94 | *.scc 95 | 96 | # Chutzpah Test files 97 | _Chutzpah* 98 | 99 | # Visual C++ cache files 100 | ipch/ 101 | *.aps 102 | *.ncb 103 | *.opendb 104 | *.opensdf 105 | *.sdf 106 | *.cachefile 107 | *.VC.db 108 | *.VC.VC.opendb 109 | 110 | # Visual Studio profiler 111 | *.psess 112 | *.vsp 113 | *.vspx 114 | *.sap 115 | 116 | # Visual Studio Trace Files 117 | *.e2e 118 | 119 | # TFS 2012 Local Workspace 120 | $tf/ 121 | 122 | # Guidance Automation Toolkit 123 | *.gpState 124 | 125 | # ReSharper is a .NET coding add-in 126 | _ReSharper*/ 127 | *.[Rr]e[Ss]harper 128 | *.DotSettings.user 129 | 130 | # TeamCity is a build add-in 131 | _TeamCity* 132 | 133 | # DotCover is a Code Coverage Tool 134 | *.dotCover 135 | 136 | # AxoCover is a Code Coverage Tool 137 | .axoCover/* 138 | !.axoCover/settings.json 139 | 140 | # Coverlet is a free, cross platform Code Coverage Tool 141 | coverage*[.json, .xml, .info] 142 | 143 | # Visual Studio code coverage results 144 | *.coverage 145 | *.coveragexml 146 | 147 | # NCrunch 148 | _NCrunch_* 149 | .*crunch*.local.xml 150 | nCrunchTemp_* 151 | 152 | # MightyMoose 153 | *.mm.* 154 | AutoTest.Net/ 155 | 156 | # Web workbench (sass) 157 | .sass-cache/ 158 | 159 | # Installshield output folder 160 | [Ee]xpress/ 161 | 162 | # DocProject is a documentation generator add-in 163 | DocProject/buildhelp/ 164 | DocProject/Help/*.HxT 165 | DocProject/Help/*.HxC 166 | DocProject/Help/*.hhc 167 | DocProject/Help/*.hhk 168 | DocProject/Help/*.hhp 169 | DocProject/Help/Html2 170 | DocProject/Help/html 171 | 172 | # Click-Once directory 173 | publish/ 174 | 175 | # Publish Web Output 176 | *.[Pp]ublish.xml 177 | *.azurePubxml 178 | # Note: Comment the next line if you want to checkin your web deploy settings, 179 | # but database connection strings (with potential passwords) will be unencrypted 180 | *.pubxml 181 | *.publishproj 182 | 183 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 184 | # checkin your Azure Web App publish settings, but sensitive information contained 185 | # in these scripts will be unencrypted 186 | PublishScripts/ 187 | 188 | # NuGet Packages 189 | *.nupkg 190 | # NuGet Symbol Packages 191 | *.snupkg 192 | # The packages folder can be ignored because of Package Restore 193 | **/[Pp]ackages/* 194 | # except build/, which is used as an MSBuild target. 195 | !**/[Pp]ackages/build/ 196 | # Uncomment if necessary however generally it will be regenerated when needed 197 | #!**/[Pp]ackages/repositories.config 198 | # NuGet v3's project.json files produces more ignorable files 199 | *.nuget.props 200 | *.nuget.targets 201 | 202 | # Microsoft Azure Build Output 203 | csx/ 204 | *.build.csdef 205 | 206 | # Microsoft Azure Emulator 207 | ecf/ 208 | rcf/ 209 | 210 | # Windows Store app package directories and files 211 | AppPackages/ 212 | BundleArtifacts/ 213 | Package.StoreAssociation.xml 214 | _pkginfo.txt 215 | *.appx 216 | *.appxbundle 217 | *.appxupload 218 | 219 | # Visual Studio cache files 220 | # files ending in .cache can be ignored 221 | *.[Cc]ache 222 | # but keep track of directories ending in .cache 223 | !?*.[Cc]ache/ 224 | 225 | # Others 226 | ClientBin/ 227 | ~$* 228 | *~ 229 | *.dbmdl 230 | *.dbproj.schemaview 231 | *.jfm 232 | *.pfx 233 | *.publishsettings 234 | orleans.codegen.cs 235 | 236 | # Including strong name files can present a security risk 237 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 238 | #*.snk 239 | 240 | # Since there are multiple workflows, uncomment next line to ignore bower_components 241 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 242 | #bower_components/ 243 | 244 | # RIA/Silverlight projects 245 | Generated_Code/ 246 | 247 | # Backup & report files from converting an old project file 248 | # to a newer Visual Studio version. Backup files are not needed, 249 | # because we have git ;-) 250 | _UpgradeReport_Files/ 251 | Backup*/ 252 | UpgradeLog*.XML 253 | UpgradeLog*.htm 254 | ServiceFabricBackup/ 255 | *.rptproj.bak 256 | 257 | # SQL Server files 258 | *.mdf 259 | *.ldf 260 | *.ndf 261 | 262 | # Business Intelligence projects 263 | *.rdl.data 264 | *.bim.layout 265 | *.bim_*.settings 266 | *.rptproj.rsuser 267 | *- [Bb]ackup.rdl 268 | *- [Bb]ackup ([0-9]).rdl 269 | *- [Bb]ackup ([0-9][0-9]).rdl 270 | 271 | # Microsoft Fakes 272 | FakesAssemblies/ 273 | 274 | # GhostDoc plugin setting file 275 | *.GhostDoc.xml 276 | 277 | # Node.js Tools for Visual Studio 278 | .ntvs_analysis.dat 279 | node_modules/ 280 | 281 | # Visual Studio 6 build log 282 | *.plg 283 | 284 | # Visual Studio 6 workspace options file 285 | *.opt 286 | 287 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 288 | *.vbw 289 | 290 | # Visual Studio LightSwitch build output 291 | **/*.HTMLClient/GeneratedArtifacts 292 | **/*.DesktopClient/GeneratedArtifacts 293 | **/*.DesktopClient/ModelManifest.xml 294 | **/*.Server/GeneratedArtifacts 295 | **/*.Server/ModelManifest.xml 296 | _Pvt_Extensions 297 | 298 | # Paket dependency manager 299 | .paket/paket.exe 300 | paket-files/ 301 | 302 | # FAKE - F# Make 303 | .fake/ 304 | 305 | # CodeRush personal settings 306 | .cr/personal 307 | 308 | # Python Tools for Visual Studio (PTVS) 309 | __pycache__/ 310 | *.pyc 311 | 312 | # Cake - Uncomment if you are using it 313 | # tools/** 314 | # !tools/packages.config 315 | 316 | # Tabs Studio 317 | *.tss 318 | 319 | # Telerik's JustMock configuration file 320 | *.jmconfig 321 | 322 | # BizTalk build output 323 | *.btp.cs 324 | *.btm.cs 325 | *.odx.cs 326 | *.xsd.cs 327 | 328 | # OpenCover UI analysis results 329 | OpenCover/ 330 | 331 | # Azure Stream Analytics local run output 332 | ASALocalRun/ 333 | 334 | # MSBuild Binary and Structured Log 335 | *.binlog 336 | 337 | # NVidia Nsight GPU debugger configuration file 338 | *.nvuser 339 | 340 | # MFractors (Xamarin productivity tool) working folder 341 | .mfractor/ 342 | 343 | # Local History for Visual Studio 344 | .localhistory/ 345 | 346 | # BeatPulse healthcheck temp database 347 | healthchecksdb 348 | 349 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 350 | MigrationBackup/ 351 | 352 | # Ionide (cross platform F# VS Code tools) working folder 353 | .ionide/ 354 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /My_CSharp_AddIn/My_CSharp_AddIn.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Express 2012 for Windows Desktop 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "My_CSharp_AddIn", "My_CSharp_AddIn\My_CSharp_AddIn.csproj", "{4D2BF693-F832-0B6E-3C86-83FB79B633E3}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Any CPU = Debug|Any CPU 9 | Release|Any CPU = Release|Any CPU 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {4D2BF693-F832-0B6E-3C86-83FB79B633E3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 13 | {4D2BF693-F832-0B6E-3C86-83FB79B633E3}.Debug|Any CPU.Build.0 = Debug|Any CPU 14 | {4D2BF693-F832-0B6E-3C86-83FB79B633E3}.Release|Any CPU.ActiveCfg = Release|Any CPU 15 | {4D2BF693-F832-0B6E-3C86-83FB79B633E3}.Release|Any CPU.Build.0 = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /My_CSharp_AddIn/My_CSharp_AddIn/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.Runtime.InteropServices; 4 | 5 | [assembly: AssemblyTitle("My_CSharp_AddIn")] 6 | [assembly: AssemblyDescription("CSharp Add-in for Autodesk Inventor")] 7 | [assembly: AssemblyCompany("Company")] 8 | [assembly: AssemblyProduct("Product")] 9 | [assembly: AssemblyCopyright("Copyright")] 10 | [assembly: AssemblyTrademark("Trademark")] 11 | [assembly: Guid("5f81e1a7-88bf-4a84-bd80-e639c0f356d3")] 12 | [assembly: AssemblyVersion("1.0.0")] 13 | 14 | 15 | [assembly: ComVisibleAttribute(true)] 16 | -------------------------------------------------------------------------------- /My_CSharp_AddIn/My_CSharp_AddIn/Autodesk.My_CSharp_AddIn.Inventor.addin: -------------------------------------------------------------------------------- 1 | 2 | 3 | {ff0f87f8-457b-449f-bede-49851b210743} 4 | {ff0f87f8-457b-449f-bede-49851b210743} 5 | CSharp_AddIn 6 | CSharp_AddIn 7 | My_CSharp_AddIn.dll 8 | 1 9 | 1 10 | 0 11 | 19.. 12 | 1 13 | 1 14 | -------------------------------------------------------------------------------- /My_CSharp_AddIn/My_CSharp_AddIn/ButtonResources/MyIcon1/16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JHurdle91/CSharp-Inventor-Add-in-Template/35b726e7e3383021047e0a75f7f17df0afa9a14a/My_CSharp_AddIn/My_CSharp_AddIn/ButtonResources/MyIcon1/16x16.png -------------------------------------------------------------------------------- /My_CSharp_AddIn/My_CSharp_AddIn/ButtonResources/MyIcon1/32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JHurdle91/CSharp-Inventor-Add-in-Template/35b726e7e3383021047e0a75f7f17df0afa9a14a/My_CSharp_AddIn/My_CSharp_AddIn/ButtonResources/MyIcon1/32x32.png -------------------------------------------------------------------------------- /My_CSharp_AddIn/My_CSharp_AddIn/ButtonResources/MyIcon2/16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JHurdle91/CSharp-Inventor-Add-in-Template/35b726e7e3383021047e0a75f7f17df0afa9a14a/My_CSharp_AddIn/My_CSharp_AddIn/ButtonResources/MyIcon2/16x16.png -------------------------------------------------------------------------------- /My_CSharp_AddIn/My_CSharp_AddIn/ButtonResources/MyIcon2/32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JHurdle91/CSharp-Inventor-Add-in-Template/35b726e7e3383021047e0a75f7f17df0afa9a14a/My_CSharp_AddIn/My_CSharp_AddIn/ButtonResources/MyIcon2/32x32.png -------------------------------------------------------------------------------- /My_CSharp_AddIn/My_CSharp_AddIn/ButtonResources/MyIcon3/16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JHurdle91/CSharp-Inventor-Add-in-Template/35b726e7e3383021047e0a75f7f17df0afa9a14a/My_CSharp_AddIn/My_CSharp_AddIn/ButtonResources/MyIcon3/16x16.png -------------------------------------------------------------------------------- /My_CSharp_AddIn/My_CSharp_AddIn/ButtonResources/MyIcon3/32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JHurdle91/CSharp-Inventor-Add-in-Template/35b726e7e3383021047e0a75f7f17df0afa9a14a/My_CSharp_AddIn/My_CSharp_AddIn/ButtonResources/MyIcon3/32x32.png -------------------------------------------------------------------------------- /My_CSharp_AddIn/My_CSharp_AddIn/ButtonResources/MyIcon4/16x16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JHurdle91/CSharp-Inventor-Add-in-Template/35b726e7e3383021047e0a75f7f17df0afa9a14a/My_CSharp_AddIn/My_CSharp_AddIn/ButtonResources/MyIcon4/16x16.png -------------------------------------------------------------------------------- /My_CSharp_AddIn/My_CSharp_AddIn/ButtonResources/MyIcon4/32x32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JHurdle91/CSharp-Inventor-Add-in-Template/35b726e7e3383021047e0a75f7f17df0afa9a14a/My_CSharp_AddIn/My_CSharp_AddIn/ButtonResources/MyIcon4/32x32.png -------------------------------------------------------------------------------- /My_CSharp_AddIn/My_CSharp_AddIn/CommandFunctions.cs: -------------------------------------------------------------------------------- 1 | // TODO: This module exists as a convenient location for the code that does the real 2 | // work when a command is executed. If you're converting VBA macros into add-in 3 | // commands you can copy the macros here, convert them to CSharp, 4 | // and change any references to "ThisApplication" to "Globals.invApp". 5 | 6 | using System; 7 | using System.Diagnostics; 8 | using System.Windows.Forms; 9 | using Inventor; 10 | 11 | namespace My_CSharp_AddIn 12 | { 13 | public static class CommandFunctions 14 | { 15 | public static void RunAnExe() 16 | { 17 | Process proc = new Process(); 18 | proc = Process.Start(@"C:\path_to\some_file.exe", ""); 19 | } 20 | 21 | public static void PopupMessage() 22 | { 23 | MessageBox.Show("This is a message box!"); 24 | } 25 | 26 | public static void CloseDocument() 27 | { 28 | Globals.invApp.ActiveDocument.Close(true); 29 | } 30 | 31 | public static void ExportDxf() 32 | { 33 | PartDocument doc = (PartDocument)Globals.invApp.ActiveDocument; 34 | 35 | if (doc.DocumentSubType.DocumentSubTypeID != "{9C464203-9BAE-11D3-8BAD-0060B0CE6BB4}") 36 | { 37 | MessageBox.Show("This can only be run on a Sheet Metal document. Exiting..."); 38 | return; 39 | } 40 | 41 | string DXF_PATH; 42 | FolderBrowserDialog fbd = new FolderBrowserDialog(); 43 | fbd.Description = "Select DXF Folder"; 44 | if (fbd.ShowDialog() == DialogResult.OK) 45 | { 46 | DXF_PATH = fbd.SelectedPath; 47 | } 48 | else 49 | { 50 | MessageBox.Show("Must specify DXF path"); 51 | return; 52 | } 53 | 54 | SheetMetalComponentDefinition smcd; 55 | smcd = (SheetMetalComponentDefinition)doc.ComponentDefinition; 56 | 57 | if (!smcd.HasFlatPattern) 58 | { 59 | try 60 | { 61 | smcd.Unfold(); 62 | smcd.FlatPattern.ExitEdit(); 63 | } 64 | catch (Exception ex) 65 | { 66 | MessageBox.Show("Could not unfold part. Create flat pattern and try again.\n\n" + ex.Message); 67 | } 68 | } 69 | 70 | const string DXF_OPTIONS = "FLAT PATTERN DXF?AcadVersion=2004" + 71 | "&OuterProfileLayer=IV_INTERIOR_PROFILES" + 72 | "&InvisibleLayers=" + 73 | "IV_TANGENT;" + 74 | "IV_FEATURE_PROFILES_DOWN;" + 75 | "IV_BEND;" + 76 | "IV_BEND_DOWN;" + 77 | "IV_TOOL_CENTER;" + 78 | "IV_TOOL_CENTER_DOWN;" + 79 | "IV_ARC_CENTERS;" + 80 | "IV_FEATURE_PROFILES;" + 81 | "IV_FEATURE_PROFILES_DOWN;" + 82 | "IV_ALTREP_FRONT;" + 83 | "IV_ALTREP_BACK;" + 84 | "IV_ROLL_TANGENT;" + 85 | "IV_ROLL" + 86 | "&SimplifySplines=True" + 87 | "&BendLayerColor=255;255;0"; 88 | 89 | string DISPLAY_NAME = doc.DisplayName; 90 | string dxf_filename = string.Format("{0}\\{1}.dxf", DXF_PATH, DISPLAY_NAME); 91 | try 92 | { 93 | smcd.DataIO.WriteDataToFile(DXF_OPTIONS, dxf_filename); 94 | } 95 | catch (Exception ex) 96 | { 97 | MessageBox.Show("Failed to save DXF"); 98 | return; 99 | } 100 | 101 | MessageBox.Show("DXF saved to path:\n\n" + DXF_PATH); 102 | } 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /My_CSharp_AddIn/My_CSharp_AddIn/My Project/HideModuleName.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | 6 | namespace My_CSharp_AddIn.My_Project 7 | { 8 | class HideModuleNameAttribute : Attribute 9 | { 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /My_CSharp_AddIn/My_CSharp_AddIn/My Project/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace My 12 | { 13 | 14 | 15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")] 17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase 18 | { 19 | 20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 21 | 22 | public static Settings Default 23 | { 24 | get 25 | { 26 | return defaultInstance; 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /My_CSharp_AddIn/My_CSharp_AddIn/My Project/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /My_CSharp_AddIn/My_CSharp_AddIn/My_CSharp_AddIn.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | Library 7 | 8 | 9 | 10 | 11 | Windows 12 | 13 | 14 | {4D2BF693-F832-0B6E-3C86-83FB79B633E3} 15 | 3.5 16 | v3.5 17 | http://localhost/AU_EXAM2/ 18 | true 19 | Web 20 | true 21 | Foreground 22 | 7 23 | Days 24 | false 25 | false 26 | true 27 | 0 28 | 1.0.0.%2a 29 | true 30 | false 31 | true 32 | 33 | 34 | $(DefaultItemExcludes);$(ProjectDir)**\*.vb 35 | 36 | 37 | bin\Debug\ 38 | true 39 | true 40 | true 41 | 42016,42017,42018,42019,42032,42353,42354,42355 42 | full 43 | false 44 | AllRules.ruleset 45 | false 46 | AnyCPU 47 | 48 | 49 | bin\Release\ 50 | false 51 | false 52 | true 53 | true 54 | 42016,42017,42018,42019,42032,42353,42354,42355 55 | none 56 | false 57 | AllRules.ruleset 58 | false 59 | 60 | 61 | On 62 | 63 | 64 | Binary 65 | 66 | 67 | Off 68 | 69 | 70 | On 71 | 72 | 73 | My_CSharp_AddIn 74 | 75 | 76 | My_CSharp_AddIn 77 | 78 | 79 | 80 | False 81 | False 82 | False 83 | C:\Program Files\Autodesk\Inventor 2018\Bin\Public Assemblies\Autodesk.Inventor.Interop.dll 84 | False 85 | 86 | 87 | System 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | True 104 | True 105 | Settings.settings 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | Designer 114 | 115 | 116 | 117 | 118 | Designer 119 | 120 | 121 | 122 | 123 | My 124 | SettingsSingleFileGenerator 125 | Settings.Designer.cs 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | False 135 | .NET Framework 3.5 SP1 Client Profile 136 | false 137 | 138 | 139 | False 140 | .NET Framework 3.5 SP1 141 | true 142 | 143 | 144 | False 145 | Windows Installer 3.1 146 | true 147 | 148 | 149 | 150 | 151 | {00020430-0000-0000-C000-000000000046} 152 | 2 153 | 0 154 | 0 155 | primary 156 | False 157 | False 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | REM - Set up the environment. 186 | call "%25VS150COMNTOOLS%25\VsDevCmd" 187 | 188 | REM - Embed the manifest into the dll. 189 | mt.exe -manifest "$(ProjectDir)$(TargetName).X.manifest" -outputresource:"$(TargetPath)";#2 190 | 191 | REM - Copy the .addin file and the ButtonResources folder into the result folder. 192 | XCopy "$(ProjectDir)Autodesk.$(TargetName).Inventor.addin" "$(TargetDir)" /y 193 | XCopy "$(ProjectDir)ButtonResources" "$(TargetDir)ButtonResources" /y /r /i /s /f 194 | 195 | REM - Delete the pdb file because it doesn't need to be delivered. 196 | DEL "$(TargetDir)$(TargetName).pdb" 197 | 198 | REM - Delete the existing add-in folder. 199 | rmdir /q /s "C:\ProgramData\Autodesk\Inventor Addins\$(TargetName)" 200 | 201 | REM - Copy the folder to the Inventor Addins folder so Inventor will see it and run it. 202 | XCopy "$(TargetDir)*" "%25appdata%25\Autodesk\ApplicationPlugins\$(TargetName)\" /y /r /i /s /f 203 | 204 | 205 | -------------------------------------------------------------------------------- /My_CSharp_AddIn/My_CSharp_AddIn/My_CSharp_AddIn.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /My_CSharp_AddIn/My_CSharp_AddIn/Readme.txt: -------------------------------------------------------------------------------- 1 | 2 | CSharp Add-In for Autodesk Inventor 3 | ====================================== 4 | 5 | This is a template for developing add-ins for Autodesk Inventor using CSharp. 6 | 7 | It is derived from Brian Ekins' "Nifty Add-In Template" found here: 8 | https://ekinssolutions.com/nifty_addin_template/ 9 | 10 | I've tweaked the template for my own use and converted it to C# using dotPeek by jetbrains found here: 11 | https://www.jetbrains.com/decompiler/ -------------------------------------------------------------------------------- /My_CSharp_AddIn/My_CSharp_AddIn/StandardAddInServer.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualBasic; 2 | using System; 3 | using Inventor; 4 | using System.Runtime.InteropServices; 5 | using System.Runtime.CompilerServices; 6 | using System.Windows.Forms; 7 | 8 | namespace My_CSharp_AddIn 9 | { 10 | namespace My_CSharp_AddIn 11 | { 12 | [ProgId("My_CSharp_AddIn.StandardAddInServer")] 13 | [Guid(Globals.g_simpleAddInClientID)] 14 | public class StandardAddInServer : ApplicationAddInServer 15 | { 16 | 17 | // ********************************************************************************* 18 | // * The two declarations below are related to adding buttons to Inventor's UI. 19 | // * They can be deleted if this add-in doesn't have a UI and only runs in the 20 | // * background handling events. 21 | // ********************************************************************************* 22 | 23 | // Declaration of the object for the UserInterfaceEvents to be able to handle 24 | // if the user resets the ribbon so the button can be added back in. 25 | private UserInterfaceEvents _m_uiEvents; 26 | 27 | public UserInterfaceEvents m_uiEvents 28 | { 29 | [MethodImpl(MethodImplOptions.Synchronized)] 30 | get 31 | { 32 | return _m_uiEvents; 33 | } 34 | 35 | [MethodImpl(MethodImplOptions.Synchronized)] 36 | set 37 | { 38 | if (_m_uiEvents != null) 39 | { 40 | _m_uiEvents.OnResetRibbonInterface -= m_uiEvents_OnResetRibbonInterface; 41 | } 42 | 43 | _m_uiEvents = value; 44 | if (_m_uiEvents != null) 45 | { 46 | _m_uiEvents.OnResetRibbonInterface += m_uiEvents_OnResetRibbonInterface; 47 | } 48 | } 49 | } 50 | 51 | // Declaration of the button definition with events to handle the click event. 52 | // For additional commands this declaration along with other sections of code 53 | // that apply to the button can be duplicated from this example. 54 | public class UI_Button 55 | { 56 | private ButtonDefinition _bd; 57 | 58 | public ButtonDefinition bd 59 | { 60 | [MethodImpl(MethodImplOptions.Synchronized)] 61 | get 62 | { 63 | return this._bd; 64 | } 65 | 66 | [MethodImpl(MethodImplOptions.Synchronized)] 67 | set 68 | { 69 | if (this._bd != null) 70 | { 71 | this._bd.OnExecute -= bd_OnExecute; 72 | } 73 | 74 | this._bd = value; 75 | if (this._bd != null) 76 | { 77 | this._bd.OnExecute += bd_OnExecute; 78 | } 79 | } 80 | } 81 | 82 | private void bd_OnExecute(NameValueMap Context) 83 | { 84 | // Link button clicks to their respective commands. 85 | switch (bd.InternalName) 86 | { 87 | case "my_first_button": 88 | CommandFunctions.RunAnExe(); 89 | return; 90 | case "my_second_button": 91 | CommandFunctions.PopupMessage(); 92 | return; 93 | case "close_doc_button": 94 | CommandFunctions.CloseDocument(); 95 | return; 96 | case "export_dxf_button": 97 | CommandFunctions.ExportDxf(); 98 | return; 99 | default: 100 | return; 101 | } 102 | } 103 | } 104 | 105 | public delegate ButtonDefinition CreateButton(string display_text, string internal_name, string icon_path); 106 | public ButtonDefinition button_template(string display_text, string internal_name, string icon_path) 107 | { 108 | UI_Button MyButton = new UI_Button(); 109 | MyButton.bd = Utilities.CreateButtonDefinition(display_text, internal_name, "", icon_path); 110 | return MyButton.bd; 111 | } 112 | 113 | // Declare all buttons here 114 | ButtonDefinition MyFirstButton; 115 | ButtonDefinition MySecondButton; 116 | ButtonDefinition CloseDocButton; 117 | ButtonDefinition ExportDxfButton; 118 | 119 | // This method is called by Inventor when it loads the AddIn. The AddInSiteObject provides access 120 | // to the Inventor Application object. The FirstTime flag indicates if the AddIn is loaded for 121 | // the first time. However, with the introduction of the ribbon this argument is always true. 122 | public void Activate(ApplicationAddInSite addInSiteObject, bool firstTime) 123 | { 124 | try 125 | { 126 | // Initialize AddIn members. 127 | Globals.invApp = addInSiteObject.Application; 128 | 129 | // Connect to the user-interface events to handle a ribbon reset. 130 | m_uiEvents = Globals.invApp.UserInterfaceManager.UserInterfaceEvents; 131 | 132 | // ********************************************************************************* 133 | // * The remaining code in this Sub is all for adding the add-in into Inventor's UI. 134 | // * It can be deleted if this add-in doesn't have a UI and only runs in the 135 | // * background handling events. 136 | // ********************************************************************************* 137 | 138 | // ButtonName = create_button(display_text, internal_name, icon_path) 139 | CreateButton create_button = new CreateButton (button_template); 140 | MyFirstButton = create_button(" My First \n Command ", "my_first_button", @"ButtonResources\MyIcon1"); 141 | MySecondButton = create_button(" My Second \n Command ", "my_second_button", @"ButtonResources\MyIcon2"); 142 | CloseDocButton = create_button(" Close \n Document ", "close_doc_button", @"ButtonResources\MyIcon3"); 143 | ExportDxfButton = create_button(" Export \n DXF ", "export_dxf_button", @"ButtonResources\MyIcon4"); 144 | 145 | // Add to the user interface, if it's the first time. 146 | // If this add-in doesn't have a UI but runs in the background listening 147 | // to events, you can delete this. 148 | if (firstTime) 149 | { 150 | AddToUserInterface(); 151 | } 152 | } 153 | catch (Exception ex) 154 | { 155 | MessageBox.Show("Unexpected failure in the activation of the add-in \"My_CSharp_AddIn\"" + System.Environment.NewLine + System.Environment.NewLine + ex.Message); 156 | } 157 | } 158 | 159 | // This method is called by Inventor when the AddIn is unloaded. The AddIn will be 160 | // unloaded either manually by the user or when the Inventor session is terminated. 161 | public void Deactivate() 162 | { 163 | // Release objects. 164 | MyFirstButton = null; 165 | MySecondButton = null; 166 | CloseDocButton = null; 167 | ExportDxfButton = null; 168 | m_uiEvents = null; 169 | Globals.invApp = null; 170 | 171 | GC.Collect(); 172 | GC.WaitForPendingFinalizers(); 173 | } 174 | 175 | // This property is provided to allow the AddIn to expose an API of its own to other 176 | // programs. Typically, this would be done by implementing the AddIn's API 177 | // interface in a class and returning that class object through this property. 178 | // Typically it's not used, like in this case, and returns Nothing. 179 | public object Automation 180 | { 181 | get 182 | { 183 | return null; 184 | } 185 | } 186 | 187 | // Note:this method is now obsolete, you should use the 188 | // ControlDefinition functionality for implementing commands. 189 | public void ExecuteCommand(int commandID) 190 | { 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 | 199 | // Get the ribbon. (more buttons can be added to various ribbons within this single addin) 200 | // Ribbons: 201 | // ZeroDoc 202 | // Part 203 | // Assembly 204 | // Drawing 205 | // Presentation 206 | // iFeatures 207 | // UnknownDocument 208 | Ribbon asmRibbon = Globals.invApp.UserInterfaceManager.Ribbons["Assembly"]; 209 | Ribbon prtRibbon = Globals.invApp.UserInterfaceManager.Ribbons["Part"]; 210 | Ribbon dwgRibbon = Globals.invApp.UserInterfaceManager.Ribbons["Drawing"]; 211 | 212 | 213 | // Set up Tabs. 214 | // tab = setup_panel(display_name, internal_name, inv_ribbon) 215 | RibbonTab MyTab_asm; 216 | MyTab_asm = setup_tab("My Tab", "my_tab_asm", asmRibbon); 217 | 218 | RibbonTab MyTab_prt; 219 | MyTab_prt = setup_tab("My Tab", "my_tab_prt", prtRibbon); 220 | 221 | RibbonTab MyTab_dwg; 222 | MyTab_dwg = setup_tab("My Tab", "my_tab_dwg", dwgRibbon); 223 | 224 | 225 | // Set up Panels. 226 | // panel = setup_panel(display_name, internal_name, ribbon_tab) 227 | RibbonPanel MyPanel_prt; 228 | MyPanel_prt = setup_panel("My Panel", "my_panel_prt", MyTab_prt); 229 | 230 | RibbonPanel ExportPanel_prt; 231 | ExportPanel_prt = setup_panel("Export", "export_panel_prt", MyTab_prt); 232 | 233 | RibbonPanel MyPanel_dwg; 234 | MyPanel_dwg = setup_panel("My Panel", "my_panel_dwg", MyTab_dwg); 235 | 236 | RibbonPanel MyPanel_asm; 237 | MyPanel_asm = setup_panel("My Panel", "my_panel_asm", MyTab_asm); 238 | 239 | 240 | // Set up Buttons. 241 | if (!(MyFirstButton == null)) 242 | { 243 | MyPanel_asm.CommandControls.AddButton(MyFirstButton, true); 244 | MyPanel_dwg.CommandControls.AddButton(MyFirstButton, true); 245 | } 246 | 247 | if (!(MySecondButton == null)) 248 | { 249 | MyPanel_prt.CommandControls.AddButton(MySecondButton, true); 250 | MyPanel_dwg.CommandControls.AddButton(MySecondButton, true); 251 | } 252 | 253 | if (!(CloseDocButton == null)) 254 | { 255 | MyPanel_prt.CommandControls.AddButton(CloseDocButton, true); 256 | MyPanel_dwg.CommandControls.AddButton(CloseDocButton, true); 257 | } 258 | 259 | if (!(ExportDxfButton == null)) 260 | { 261 | ExportPanel_prt.CommandControls.AddButton(ExportDxfButton, true); 262 | } 263 | } 264 | 265 | 266 | private RibbonTab setup_tab(string display_name, string internal_name, Ribbon inv_ribbon) 267 | { 268 | RibbonTab setup_tabRet = default(RibbonTab); 269 | RibbonTab ribbon_tab = null; 270 | try 271 | { 272 | ribbon_tab = inv_ribbon.RibbonTabs[internal_name]; 273 | } 274 | catch (Exception ex) 275 | { 276 | } 277 | 278 | if (ribbon_tab == null) 279 | { 280 | ribbon_tab = inv_ribbon.RibbonTabs.Add(display_name, internal_name, Globals.g_addInClientID); 281 | } 282 | 283 | setup_tabRet = ribbon_tab; 284 | return setup_tabRet; 285 | } 286 | 287 | 288 | private RibbonPanel setup_panel(string display_name, string internal_name, RibbonTab ribbon_tab) 289 | { 290 | RibbonPanel setup_panelRet = default(RibbonPanel); 291 | RibbonPanel ribbon_panel = null; 292 | try 293 | { 294 | ribbon_panel = ribbon_tab.RibbonPanels[internal_name]; 295 | } 296 | catch (Exception ex) 297 | { 298 | } 299 | 300 | if (ribbon_panel == null) 301 | { 302 | ribbon_panel = ribbon_tab.RibbonPanels.Add(display_name, internal_name, Globals.g_addInClientID); 303 | } 304 | 305 | setup_panelRet = ribbon_panel; 306 | return setup_panelRet; 307 | } 308 | 309 | 310 | private void m_uiEvents_OnResetRibbonInterface(NameValueMap Context) 311 | { 312 | // The ribbon was reset, so add back the add-ins user-interface. 313 | AddToUserInterface(); 314 | } 315 | } 316 | } 317 | 318 | 319 | public static class Globals 320 | { 321 | // Inventor application object. 322 | public static Inventor.Application invApp; 323 | 324 | // The unique ID for this add-in. If this add-in is copied to create a new add-in 325 | // you need to update this ID along with the ID in the .manifest file, the .addin file 326 | // and create a new ID for the typelib GUID in AssemblyInfo.vb 327 | public const string g_simpleAddInClientID = "ff0f87f8-457b-449f-bede-49851b210743"; 328 | public const string g_addInClientID = "{" + g_simpleAddInClientID + "}"; 329 | } 330 | } 331 | -------------------------------------------------------------------------------- /My_CSharp_AddIn/My_CSharp_AddIn/Utilities.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.VisualBasic; 2 | using System; 3 | using System.Windows.Forms; 4 | using Inventor; 5 | 6 | namespace My_CSharp_AddIn 7 | { 8 | public static class Utilities 9 | { 10 | 11 | /// 12 | /// Function to simplify the creation of a button definition. The big advantage 13 | /// to using this function is that you don't have to deal with converting images 14 | /// but instead just reference a folder on disk where this routine reads the images. 15 | /// 16 | /// 17 | /// The name of the command as it will be displayed on the button. 18 | /// 19 | /// 20 | /// The internal name of the command. This needs to be unique with respect to ALL other 21 | /// commands. It's best to incorporate a company name to help with uniqueness. 22 | /// 23 | /// 24 | /// The tooltip that will be used for the command. 25 | /// 26 | /// This is optional and the display name will be used as the 27 | /// tooltip if no tooltip is specified. Like in the DisplayName argument, you can use 28 | /// returns to force line breaks. 29 | /// 30 | /// 31 | /// The folder that contains the icon files. This can be a full path or a path that is 32 | /// relative to the location of the add-in dll. The folder should contain the files 33 | /// 16x16.png and 32x32.png. Each command will have its own folder so they can have 34 | /// their own icons. 35 | /// 36 | /// This is optional and if no icon is specified then no icon will be displayed on the 37 | /// button and it will be only text. 38 | /// 39 | /// 40 | /// Returns the newly created button definition or Nothing in case of failure. 41 | /// 42 | public static Inventor.ButtonDefinition CreateButtonDefinition(string DisplayName, 43 | string InternalName, 44 | string ToolTip = "", 45 | string IconFolder = "") 46 | { 47 | 48 | // Check to see if a command already exists is the specified internal name. 49 | Inventor.ButtonDefinition testDef = null; 50 | try 51 | { 52 | testDef = (Inventor.ButtonDefinition)Globals.invApp.CommandManager.ControlDefinitions[InternalName]; 53 | } 54 | catch (Exception ex) 55 | { 56 | } 57 | 58 | if (!(testDef == null)) 59 | { 60 | MessageBox.Show("Error when loading the add-in \"My_CSharp_AddIn\". 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.", "CSharp Inventor Add-In Template"); 61 | return null; 62 | } 63 | 64 | // Check to see if the provided folder is a full or relative path. 65 | if (!string.IsNullOrEmpty(IconFolder)) 66 | { 67 | if (!System.IO.Directory.Exists(IconFolder)) 68 | { 69 | // The folder provided doesn't exist, so assume it is a relative path and 70 | // build up the full path. 71 | string dllPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); 72 | 73 | IconFolder = System.IO.Path.Combine(dllPath, IconFolder); 74 | } 75 | } 76 | 77 | // Get the images from the specified icon folder. 78 | stdole.IPictureDisp iPicDisp16x16 = null; 79 | stdole.IPictureDisp iPicDisp32x32 = null; 80 | if (!string.IsNullOrEmpty(IconFolder)) 81 | { 82 | if (System.IO.Directory.Exists(IconFolder)) 83 | { 84 | string filename16x16 = System.IO.Path.Combine(IconFolder, "16x16.png"); 85 | string filename32x32 = System.IO.Path.Combine(IconFolder, "32x32.png"); 86 | 87 | if (System.IO.File.Exists(filename16x16)) 88 | { 89 | try 90 | { 91 | System.Drawing.Bitmap image16x16 = new System.Drawing.Bitmap(filename16x16); 92 | iPicDisp16x16 = ConvertImage.ConvertImageToIPictureDisp(image16x16); 93 | } 94 | catch (Exception ex) 95 | { 96 | MessageBox.Show("Unable to load the 16x16.png image from \"" + IconFolder + "\"." + System.Environment.NewLine + "No small icon will be used.", "Error Loading Icon"); 97 | } 98 | } 99 | else 100 | MessageBox.Show("The icon for the small button does not exist: \"" + filename16x16 + "\"." + System.Environment.NewLine + "No small icon will be used.", "Error Loading Icon"); 101 | 102 | if (System.IO.File.Exists(filename32x32)) 103 | { 104 | try 105 | { 106 | System.Drawing.Bitmap image32x32 = new System.Drawing.Bitmap(filename32x32); 107 | iPicDisp32x32 = ConvertImage.ConvertImageToIPictureDisp(image32x32); 108 | } 109 | catch (Exception ex) 110 | { 111 | MessageBox.Show("Unable to load the 32x32.png image from \"" + IconFolder + "\"." + System.Environment.NewLine + "No large icon will be used.", "Error Loading Icon"); 112 | } 113 | } 114 | else 115 | MessageBox.Show("The icon for the large button does not exist: \"" + filename32x32 + "\"." + System.Environment.NewLine + "No large icon will be used.", "Error Loading Icon"); 116 | } 117 | } 118 | 119 | try 120 | { 121 | // Get the ControlDefinitions collection. 122 | ControlDefinitions controlDefs = Globals.invApp.CommandManager.ControlDefinitions; 123 | 124 | // Create the command defintion. 125 | ButtonDefinition btnDef = controlDefs.AddButtonDefinition(DisplayName, InternalName, Inventor.CommandTypesEnum.kShapeEditCmdType, Globals.g_addInClientID, "", ToolTip, iPicDisp16x16, iPicDisp32x32); 126 | return btnDef; 127 | } 128 | catch (Exception ex) 129 | { 130 | return null; 131 | } 132 | } 133 | 134 | 135 | // This class is used to wrap a Win32 hWnd as a .Net IWind32Window class. 136 | // This is primarily used for parenting a dialog to the Inventor window. 137 | // This provides the expected behavior when the Inventor window is collapsed 138 | // and activated. 139 | // 140 | // For example: 141 | // myForm.Show(New WindowWrapper(invApp.MainFrameHWND)) 142 | // 143 | public class WindowWrapper : System.Windows.Forms.IWin32Window 144 | { 145 | public WindowWrapper(IntPtr handle) 146 | { 147 | _hwnd = handle; 148 | } 149 | 150 | public IntPtr Handle 151 | { 152 | get 153 | { 154 | return _hwnd; 155 | } 156 | } 157 | 158 | private IntPtr _hwnd; 159 | } 160 | 161 | 162 | // Class used to convert bitmaps and icons between their .Net native types 163 | // and an IPictureDisp object which is what the Inventor API requires. 164 | 165 | [System.Security.Permissions.PermissionSet 166 | (System.Security.Permissions.SecurityAction.Demand, Name = "FullTrust")] 167 | public class ConvertImage : System.Windows.Forms.AxHost 168 | { 169 | public ConvertImage() 170 | : base("59EE46BA-677D-4d20-BF10-8D8067CB8B32") 171 | { 172 | } 173 | 174 | public static stdole.IPictureDisp ConvertImageToIPictureDisp(System.Drawing.Image Image) 175 | { 176 | try 177 | { 178 | return (stdole.IPictureDisp)GetIPictureFromPicture(Image); 179 | } 180 | catch (Exception ex) 181 | { 182 | return null; 183 | } 184 | } 185 | 186 | public static System.Drawing.Image ConvertIPictureDispToImage(stdole.IPictureDisp IPict) 187 | { 188 | try 189 | { 190 | return GetPictureFromIPictureDisp(IPict); 191 | } 192 | catch (Exception ex) 193 | { 194 | return null; 195 | } 196 | } 197 | } 198 | } 199 | } 200 | -------------------------------------------------------------------------------- /My_CSharp_AddIn/My_CSharp_AddIn/app.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /README.org: -------------------------------------------------------------------------------- 1 | 2 | CSharp Add-In for Autodesk Inventor 3 | ====================================== 4 | 5 | This is a template for developing add-ins for Autodesk Inventor using CSharp. 6 | 7 | It is derived from Brian Ekins' "Nifty Add-In Template" found here: 8 | https://ekinssolutions.com/nifty_addin_template/ 9 | 10 | I've tweaked the template for my own use and converted it to C# using dotPeek by jetbrains found here: 11 | https://www.jetbrains.com/decompiler/ 12 | 13 | To use this as a template: 14 | 1. open the .sln in visual studio 15 | 2. file > export template 16 | 3. create new project from the template 17 | 4. See [[https://github.com/JHurdle91/CSharp-Inventor-Add-in-Template/commit/50d61a90ecb66be848e9537d6c7b6c1d830dfe74][this commit]] for an example of what to change if making another add-in 18 | from this template. 19 | - I also added an example button and command to the add-in in this commit. 20 | --------------------------------------------------------------------------------