{"id":20,"date":"2008-08-18T05:09:27","date_gmt":"2008-08-17T23:39:27","guid":{"rendered":"http:\/\/www.smallguru.com\/?p=19"},"modified":"2008-08-18T05:09:27","modified_gmt":"2008-08-17T23:39:27","slug":"customize-autodesk-inventor-api-using-csharp-part2","status":"publish","type":"post","link":"https:\/\/www.ar-cad.com\/smallguru\/2008\/08\/customize-autodesk-inventor-api-using-csharp-part2\/","title":{"rendered":"Customize Autodesk Inventor API using C# &#8211; Part 2"},"content":{"rendered":"<p style=\"text-align: center;\"><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\/v9cM56pR6cs&amp;hl=en&amp;fs=1\" \/><embed type=\"application\/x-shockwave-flash\" width=\"500\" height=\"404\" src=\"http:\/\/www.youtube.com\/v\/v9cM56pR6cs&amp;hl=en&amp;fs=1\" allowfullscreen=\"true\"><\/embed><\/object><br \/>\n<strong><a href=\"http:\/\/www.ar-cad.com\/videos\/inventorApiCSharp1\/inventorApiCSharp1.html\" target=\"_blank\"> Watch High Resolution video on AR-CAD<\/a><\/strong><\/p>\n<p>I hope you have gone through my previous posts on Inventor API a) <a href=\"http:\/\/www.smallguru.com\/2008\/08\/introduction-to-autodesk-inventor-api-and-customization\/\" target=\"_blank\">Introduction to Autodesk Inventor API and Customization<\/a> and b) <a href=\"http:\/\/www.smallguru.com\/2008\/08\/customize-autodesk-inventor-api-using-csharp\/\" target=\"_blank\">Customize Autodesk Inventor using C#<\/a>. It is also assumed that you have gone through DevTV: Introduction to Inventor Programming Video, which is on <a href=\"http:\/\/www.autodesk.com\/developinventor\" target=\"_blank\">Inventor Customization <\/a>page. In the above video, we connect to Inventor API from Visual C# (Visual Studio 2005). I have just replaced the VB.NET code that was used in DevTV tutorial with the corresponding C# code. You can see the comparison below. Please note how GetObject in VB.NET is replaced by a much more lengthier code. If the above youtube video is not very clear, <a href=\"http:\/\/www.ar-cad.com\/videos\/inventorApiCSharp1\/inventorApiCSharp1.html\" target=\"_blank\">watch it on AR-CAD<\/a>.<\/p>\n<p><strong>VB.NET Code<\/strong><br \/>\n[sourcecode language=&#8217;vb&#8217;]<br \/>\nDim oApp As Inventor.Application<br \/>\noApp = GetObject( , &#8220;Inventor.Application&#8221;)<br \/>\nMsgBox(&#8220;Number of open docs = &#8221; &#038; oApp.Documents.Count)<br \/>\n[\/sourcecode]<\/p>\n<p><strong>Visual C# Code<\/strong><br \/>\n[sourcecode language=&#8217;c#&#8217;]<br \/>\nInventor.Application oApp;<br \/>\n\/\/The below initialization is on a single line<br \/>\noApp =<br \/>\n(Inventor.Application)System.Runtime.InteropServices.Marshall.<br \/>\nGetActiveObject(&#8220;Inventor.Application&#8221;);<\/p>\n<p>int number_int = oApp.Documents.Count;<br \/>\nstring number_string = Convert.ToString(number_int);<\/p>\n<p>MessageBox.Show (&#8220;Number of open docs =&#8221; + number_string);<br \/>\n[\/sourcecode] <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Watch High Resolution video on AR-CAD I hope you have gone through my previous posts on Inventor API a) Introduction to Autodesk Inventor API and Customization and b) Customize Autodesk Inventor using C#. It is also assumed that you have &hellip; <a href=\"https:\/\/www.ar-cad.com\/smallguru\/2008\/08\/customize-autodesk-inventor-api-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":[12,13,32,33,20,35,28,37,29],"class_list":["post-20","post","type-post","status-publish","format-standard","hentry","category-autodesk-inventor","category-cad","category-inventor-customization","tag-api-customization","tag-ar-cad","tag-autodesk-inventor","tag-cad","tag-cad-customization","tag-inventor-customization","tag-video-tutorials","tag-visual-c","tag-visual-studio"],"_links":{"self":[{"href":"https:\/\/www.ar-cad.com\/smallguru\/wp-json\/wp\/v2\/posts\/20","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=20"}],"version-history":[{"count":0,"href":"https:\/\/www.ar-cad.com\/smallguru\/wp-json\/wp\/v2\/posts\/20\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.ar-cad.com\/smallguru\/wp-json\/wp\/v2\/media?parent=20"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ar-cad.com\/smallguru\/wp-json\/wp\/v2\/categories?post=20"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ar-cad.com\/smallguru\/wp-json\/wp\/v2\/tags?post=20"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}