{"id":23,"date":"2008-09-01T06:30:32","date_gmt":"2008-09-01T01:00:32","guid":{"rendered":"http:\/\/www.smallguru.com\/?p=22"},"modified":"2008-09-01T06:30:32","modified_gmt":"2008-09-01T01:00:32","slug":"develop-autodesk-inventor-addin-using-csharp-part2","status":"publish","type":"post","link":"https:\/\/www.ar-cad.com\/smallguru\/2008\/09\/develop-autodesk-inventor-addin-using-csharp-part2\/","title":{"rendered":"Develop Autodesk Inventor Addin using C# &#8211; Part 2"},"content":{"rendered":"<p><strong>Part 2a:<\/strong> <a href=\"http:\/\/www.ar-cad.com\/videos\/InventorAddin2a\/InventorAddin2a.html\" target=\"_blank\"><\/a><br \/>\n<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" width=\"500\" height=\"404\" codebase=\"http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=6,0,40,0\"><param name=\"allowFullScreen\" value=\"true\" \/><param name=\"src\" value=\"http:\/\/www.youtube.com\/v\/2R4aaiYa68c&amp;hl=en&amp;fs=1\" \/><embed type=\"application\/x-shockwave-flash\" width=\"500\" height=\"404\" src=\"http:\/\/www.youtube.com\/v\/2R4aaiYa68c&amp;hl=en&amp;fs=1\" allowfullscreen=\"true\"><\/embed><\/object><\/p>\n<p><a href=\"http:\/\/www.ar-cad.com\/videos\/InventorAddin2a\/InventorAddin2a.html\" target=\"_blank\">Watch High Resolution video of Part2a videos on AR-CAD<\/a><\/p>\n<hr style=\"display:block;\" \/><strong>Part 2b:<\/strong><a href=\"http:\/\/www.ar-cad.com\/videos\/InventorAddin2b\/InventorAddin2b.html\" target=\"_blank\"><\/a><br \/>\n<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" width=\"500\" height=\"404\" codebase=\"http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=6,0,40,0\"><param name=\"allowFullScreen\" value=\"true\" \/><param name=\"src\" value=\"http:\/\/www.youtube.com\/v\/Purc9aTf3lA&amp;hl=en&amp;fs=1\" \/><embed type=\"application\/x-shockwave-flash\" width=\"500\" height=\"404\" src=\"http:\/\/www.youtube.com\/v\/Purc9aTf3lA&amp;hl=en&amp;fs=1\" allowfullscreen=\"true\"><\/embed><\/object><\/p>\n<p>\u00a0<\/p>\n<p><a href=\"http:\/\/www.ar-cad.com\/videos\/InventorAddin2b\/InventorAddin2b.html\" target=\"_blank\">Watch High Resolution video of Part2b videos on AR-CAD<\/a><\/p>\n<hr style=\"display:block;\" \/><strong>Part 2c: <\/strong><br \/>\n<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" width=\"500\" height=\"404\" codebase=\"http:\/\/download.macromedia.com\/pub\/shockwave\/cabs\/flash\/swflash.cab#version=6,0,40,0\"><param name=\"allowFullScreen\" value=\"true\" \/><param name=\"src\" value=\"http:\/\/www.youtube.com\/v\/klmZ1CtEIqs&amp;hl=en&amp;fs=1\" \/><embed type=\"application\/x-shockwave-flash\" width=\"500\" height=\"404\" src=\"http:\/\/www.youtube.com\/v\/klmZ1CtEIqs&amp;hl=en&amp;fs=1\" allowfullscreen=\"true\"><\/embed><\/object><\/p>\n<p>\u00a0<\/p>\n<p><a href=\"http:\/\/www.ar-cad.com\/videos\/InventorAddin2c\/InventorAddin2c.html\" target=\"_blank\">Watch High Resolution video of Part2c videos on AR-CAD<\/a><\/p>\n<hr style=\"display:block;\" \/>This video tutorial is in continuation of my earlier post on <a href=\"http:\/\/www.smallguru.com\/2008\/08\/develop-autodesk-inventor-addin-using-csharp-part-1\/\" target=\"_blank\">Developing Autodesk Inventor Addin using C# &#8211; part 1<\/a>. In this session, we go a step further and create Command Button(s), that is added into a Custom Command Bar, which in turn gets added into Panel Bar of Assembly Files.<\/p>\n<p>\u00a0<\/p>\n<p>We start with a project that gets formed when we use  Inventor Addins Template for C# language. We then add a couple of references and use most of the code from SimpleAddin that gets shipped along with Inventor in its SDK kit. We use the Button class from SimpleAddin as it is, and then append code to StandardAddInServer.cs file as explained in the video.<\/p>\n<p>Some of the main points discussed in the video are as follows:<\/p>\n<ol>\n<li> How to deal with User Interface Event<\/li>\n<li> How to deal with Event Handler for Command Bars and Environments on Reset<\/li>\n<li> How to use &#8216;try &amp; catch&#8217; loop to handle errors effectively<\/li>\n<li> How to extend Button base class. Each ButtonCommand (AssemblyTreeButton) will have a Class which implements Button class<\/li>\n<li> How to load Image icons (.ico) for User Interface items<\/li>\n<li> How to create Buttons (CommandButtons)<\/li>\n<li> How to create Command Category<\/li>\n<li> How to add Button to Command Category<\/li>\n<li> How to create a custom command bar (toolbar), only the first time the addin loads up<\/li>\n<li> How to add a custom command bar to an available Environment (again only first time)<\/li>\n<li> How to Restore CommandBars and Environments and clean up the custom CommandBars and Environment changes done by activate method<\/li>\n<li> How to run a command when a button is clicked<\/li>\n<li> How to Build a Solution from Visual Studio 2005<\/li>\n<li> How to register and unregister an Addin using RegAsm.exe (easier way)<\/li>\n<li> How to check whether you addin has been loaded in the Inventor when it is started<\/li>\n<\/ol>\n<p>I hope a lot of basics of a Command Button are covered in this video tutorial. In the coming ones, I would try to work on &#8220;Debugging an Addin from Visual Studio&#8221; and more complex addins which actually do something other than just showing some messages.<\/p>\n<p>Please comment below if there is anything that is not clear. To view high resolution Videos of the above screencasts, check them out at AR-CAD at <a href=\"http:\/\/www.ar-cad.com\/videos\/InventorAddin2a\/InventorAddin2a.html\" target=\"_blank\">part2a<\/a>,<a href=\"http:\/\/www.ar-cad.com\/videos\/InventorAddin2b\/InventorAddin2b.html\" target=\"_blank\"> part2b<\/a>, <a href=\"http:\/\/www.ar-cad.com\/videos\/InventorAddin2c\/InventorAddin2c.html\" target=\"_blank\">part2c<\/a>.<\/p>\n<p><strong>U<\/strong><strong>pdate:<\/strong> Looks like the install.bat and uninstall.bat files content are not very clear in the video, here are they in text<\/p>\n<p>Install.bat<\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0.0001pt; background: #f2f2f2 none repeat scroll 0%; text-indent: 0in; line-height: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;\"><span style=\"font-size: 13pt; font-family: \">@echo off<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0.0001pt; background: #f2f2f2 none repeat scroll 0%; text-indent: 0in; line-height: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;\"><span style=\"font-size: 13pt; font-family: \">C:WINDOWSMicrosoft.NETFrameworkv2.0.50727RegAsm.exe \/codebase AR-CADInventorAddIn4.dll<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0.0001pt; background: #f2f2f2 none repeat scroll 0%; text-indent: 0in; line-height: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;\"><span style=\"font-size: 13pt; font-family: \">PAUSE<\/span><strong><\/strong><\/p>\n<p>Uninstall.bat<\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0.0001pt; background: #f2f2f2 none repeat scroll 0%; text-indent: 0in; line-height: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;\"><span style=\"font-size: 13pt; font-family: \">@echo off<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0.0001pt; background: #f2f2f2 none repeat scroll 0%; text-indent: 0in; line-height: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;\"><span style=\"font-size: 13pt; font-family: \">C:WINDOWSMicrosoft.NETFrameworkv2.0.50727RegAsm.exe \/unregister <\/span><span style=\"font-size: 13pt; font-family: \">AR-CADInventorAddIn4<\/span><span style=\"font-size: 13pt; font-family: \">.dll<\/span><\/p>\n<p class=\"MsoNormal\" style=\"margin: 0in 0in 0.0001pt; background: #f2f2f2 none repeat scroll 0%; text-indent: 0in; line-height: normal; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;\"><span style=\"font-size: 13pt; font-family: \">PAUSE<\/span><strong><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Part 2a: Watch High Resolution video of Part2a videos on AR-CAD Part 2b: \u00a0 Watch High Resolution video of Part2b videos on AR-CAD Part 2c: \u00a0 Watch High Resolution video of Part2c videos on AR-CAD This video tutorial is in &hellip; <a href=\"https:\/\/www.ar-cad.com\/smallguru\/2008\/09\/develop-autodesk-inventor-addin-using-csharp-part2\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"nf_dc_page":"","footnotes":""},"categories":[9,2,5],"tags":[11,12,32,20,35,37],"class_list":["post-23","post","type-post","status-publish","format-standard","hentry","category-autodesk-inventor","category-cad","category-inventor-customization","tag-add-ons","tag-api-customization","tag-autodesk-inventor","tag-cad-customization","tag-inventor-customization","tag-visual-c"],"_links":{"self":[{"href":"https:\/\/www.ar-cad.com\/smallguru\/wp-json\/wp\/v2\/posts\/23","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.ar-cad.com\/smallguru\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ar-cad.com\/smallguru\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ar-cad.com\/smallguru\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ar-cad.com\/smallguru\/wp-json\/wp\/v2\/comments?post=23"}],"version-history":[{"count":0,"href":"https:\/\/www.ar-cad.com\/smallguru\/wp-json\/wp\/v2\/posts\/23\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.ar-cad.com\/smallguru\/wp-json\/wp\/v2\/media?parent=23"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ar-cad.com\/smallguru\/wp-json\/wp\/v2\/categories?post=23"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ar-cad.com\/smallguru\/wp-json\/wp\/v2\/tags?post=23"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}