|
Aug 182008 |
Customize Autodesk Inventor API using C# - Part 2Tagged Under : API Customization, AR-CAD, Autodesk Inventor, CAD, CAD Customization, Inventor Customization, video tutorials, Visual C#, Visual StudioPosted in Autodesk Inventor, CAD, Inventor Customization by rajeev |
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 gone through DevTV: Introduction to Inventor Programming Video, which is on Inventor Customization 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, watch it on AR-CAD.
VB.NET Code
Dim oApp As Inventor.Application
oApp = GetObject( , "Inventor.Application")
MsgBox("Number of open docs = " & oApp.Documents.Count)
Visual C# Code
Inventor.Application oApp;
//The below initialization is on a single line
oApp =
(Inventor.Application)System.Runtime.InteropServices.Marshall.
GetActiveObject("Inventor.Application");
int number_int = oApp.Documents.Count;
string number_string = Convert.ToString(number_int);
MessageBox.Show ("Number of open docs =" + number_string);
[...] continuation to my previous post on Customizing Inventor using C#, I go a step further and interact with an Assembly which is opened through API. I have ported the [...]
[...] News » News Customize Autodesk Inventor API using C# - Part 22008-08-22 00:38:47+ number_string); number_string = oApp.Documents.Count; string number_string = [...]