Check out the Self-Paced Guide “My First Plug-in” presented by the ADN Inventor Team
www.autodesk.com/myfirstinventorplugin
Are you an Autodesk Inventor power user with an interest in becoming even more productive? Would you like to automate or extend the capabilities of Inventor, but are new to computer programming? If so, then this guide is designed for you.
“My First Plug-in” is a self-paced tutorial guide for a smooth introduction into the programming world. This is a “one-stop shop” learning path for users who know Autodesk products but are absolutely new to programming and are thinking about taking the plunge. In this guide, you will be working with the Autodesk Inventor API and the VB.NET programming language.
There are many resources available on the web for you to learn about the Autodesk Inventor API (Application Programming Interface), however, these resources tend to be designed for people who already know programming. This guide is different: it assumes no previous programming knowledge and yet helps you build your first plug-in quickly, without swamping you with details. You’ll have a working application within an hour of starting this material, irrespective of your current level of programming expertise.
The guide will start by reviewing the benefits of customizing Autodesk software before progressing onto lessons covering the use of the Autodesk Inventor API. The lessons will start by building a working plug-in before covering more detailed explanations of the underlying principles and further developing the application’s functionality.
Product: Autodesk Inventor
Programming Language: VB.NET
Application Programming Interface (API): Inventor API
If you have any feedback on this new guide let us know at myfirstplugin@autodesk.com
Hello,
I read about Visual Studio 2010 Express.
Are there any restrictions in using the inventor api compared to the "with costs" versions of VS? Anything that doesn't work when using Express?
Thanks,
Christoph
Can you do a 'My FIrst Add-in' Sequel to this? Including things like settings required in Visual Studio .net for debugging, correct registration of dll's upon install & uninstall. How to get forms to work correctly with Addins.
Plugins are a great start, but at the end of the day Add-ins are the way to go.
cheers
Scott
Scott Moyse
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
RevOps Strategy Manager at Toolpath. New Zealand based.
Co-founder of the Grumpy Sloth full aluminium billet mechanical keyboard project
Hi,
The only issues that I have seen using the Express editions of Visual Studio is that the Inventor AddIn Wizard does not install. There are ways to get around this however. There is some instruction in the guide on how to do this along with a zip file that contains the Wizard.
Thanks,
Wayne Brill
Autodesk Developer Network
Wayne:
I've been following lessons 1 - 7 of your self-paced guide. Several questions come to mind:
1) Can a Visual Basic Studio 2010 Express session without a form? If so, how?
2) Can a working iLogic program be pasted in 2010 Express and work without any editing? I have an iLogic program that creates a custom iProperty that rounds mass to one decimal point and includes LBS as the unit of measure. It's just a few lines of code.
I'm looking forward to your next self-paced guide!
Hi,
Visual Studio Express can create other types of applications. Take a look at the options on the New Project dialog. I am not sure why you don't want the form. In any case you could use a console application to drive Inventor from the DOS prompt. You may want to consider creating an AddIn that loads and seems like it is part of Inventor. This topic is covered in the Programming help file. Creating AddIns for Inventor 2012 is easier now because the AddIn can be loaded without using the Windows registry.
If you are using the iLogic code snippets, then VB.NET will not know what to do with them and you would need to change the code so it uses standard VB.NET code. Below is how I converted part of the iLogic tutorial to VBA: (VBA is more similar to VB.NET then the iLogic code) Notice how the iLogic "Feature.IsActive=" needs to be something like 'partCompDef.Features("flange_hole").Suppressed =" in the VB code. Also notice how UnitsOfMeasure needs to be used to get the values correct. The API works in specific units, in the API. Length is in centimeters..
You would need to use Events to get the same functionality as a rule. When you work with iLogic you don't have to add an event that watches for the Parameter to change.
Thanks,
Wayne Brill
Autodesk Developer Network
<code_begin>
Private Sub modelEvents_OnParameterChange(ByVal DocumentObject As Document, ByVal Parameter As Parameter, ByVal BeforeOrAfter As EventTimingEnum, ByVal Context As NameValueMap, HandlingCode As HandlingCodeEnum)
'iLogic Rule
'******************************************
'If holes = "flange" Then
'Feature.IsActive("flange_hole") = True
'Feature.IsActive("base_hole") = False
'ElseIf holes = "base" Then
'Feature.IsActive("flange_hole") = False
'Feature.IsActive("base_hole") = True
'ElseIf holes = "none" Then
'Feature.IsActive("flange_hole") = False
'Feature.IsActive("base_hole") = False
'End If
'*******************************************
If BeforeOrAfter = kAfter Then
If Parameter.Name = "holes" Then
Dim partCompDef As PartComponentDefinition
Set partCompDef = ThisApplication.ActiveDocument.ComponentDefinition
If Parameter.Value = "flange" Then
partCompDef.Features("flange_hole").Suppressed = False
partCompDef.Features("base_hole").Suppressed = True
ElseIf Parameter.Value = "base" Then
partCompDef.Features("flange_hole").Suppressed = True
partCompDef.Features("base_hole").Suppressed = False
ElseIf Parameter.Value = "none" Then
partCompDef.Features("flange_hole").Suppressed = True
partCompDef.Features("base_hole").Suppressed = True
End If
End If
If Parameter.Name = "chamfers" Then
' Dim partCompDef As PartComponentDefinition
Set partCompDef = ThisApplication.ActiveDocument.ComponentDefinition
' iLogic rule
'**********************
'If chamfers = True Then
'Feature.IsActive("Chamfers") = True
'ElseFeature.IsActive("Chamfers") = False
'End If
' ******************
If Parameter.Value = True Then
partCompDef.Features("Chamfers").Suppressed = False
Else
partCompDef.Features("Chamfers").Suppressed = True
End If
End If
'iLogic Rule
'*******************************************
' If Mass = 100 Then
' bracket_width = 1
' ElseIf Mass = 200 Then
' bracket_width = 2
' ElseIf Mass = 300 Then
' bracket_width = 3
' ElseIf Mass = 400 Then
' bracket_width = 4
' End If
'*******************************************
If Parameter.Name = "mass" Then
Dim UofM As UnitsOfMeasure
Set partCompDef = ThisApplication.ActiveDocument.ComponentDefinition
Set UofM = ThisApplication.ActiveDocument.UnitsOfMeasure
Dim d1 As Double
d1 = UofM.ConvertUnits(Parameter.Value, kDatabaseMassUnits, kLbMassMassUnits)
Dim d2 As Double
Set partCompDef = ThisApplication.ActiveDocument.ComponentDefinition
If d1 <= 100 Then
d2 = UofM.ConvertUnits(1, kDefaultDisplayLengthUnits, kDatabaseLengthUnits)
partCompDef.Parameters("bracket_width").Value = d2
ElseIf d1 > 100 And d1 <= 200 Then
'bracket_width = 2
d2 = UofM.ConvertUnits(2, kDefaultDisplayLengthUnits, kDatabaseLengthUnits)
partCompDef.Parameters("bracket_width").Value = d2
ElseIf d1 > 200 And d1 <= 300 Then
' bracket_width = 3
d2 = UofM.ConvertUnits(3, kDefaultDisplayLengthUnits, kDatabaseLengthUnits)
partCompDef.Parameters("bracket_width").Value = d2
ElseIf d1 > 300 And d1 <= 400 Then
' bracket_width = 4
d2 = UofM.ConvertUnits(4, kDefaultDisplayLengthUnits, kDatabaseLengthUnits)
partCompDef.Parameters("bracket_width").Value = d2
Else
d2 = UofM.ConvertUnits(6, kDefaultDisplayLengthUnits, kDatabaseLengthUnits)
partCompDef.Parameters("bracket_width").Value = d2
End If
End If
End If
End Sub
<code_end>
Thanks Wayne for the quick reply. Wow! You have given me a lot to think about. Between VB.net, iLogic and VBA it appears that there are programming tools skewed for the type of customization you wish to do. I was of the opinion that the three interfaces were interchangeable. No so! I guess iLogic may be the best choice for "configuration scenarios" while VB.net may be the best choice for "deep customization of the entire Inventor application.
I see by your code examples that VB.net and iLogic are very different. I had no idea how different they are.
The reason I asked about "formless" programming in VB.net was that I was associating VB.net to iLogic.
In terms of reading materials, do you have any suggestions for programming VB.net and for iLogic?
Thanks once again for your insightful reply!
Hi,
Unfortunately not, at this point in time we only have VB.NET, however we are looking to potentially expand on the languages we offer so if we have a C# one in the future, I will definitely let you know.
Thanks,
Wayne Brill
Autodesk Developer Network
Let me take a question. I think that the self-paced code assumes there is only one instance of Inventor running. But, in running the code, if there are more than one instance of Inventor opened, the program will take the first opened instance and will ignore all the others instances. How could I change this behavior? For example, a way to choose the open Inventor instance that I want to connect.
Hi there,
I´m having a little bit of trouble with the guide. The plugin runs and does what it should, but in the output window it throws a couple of exceptions at me. I´m on a german OS, so "Ausnahme" means exception and the rest should be self explanatory, if not just ask.
Here is the error code:
Eine Ausnahme (erste Chance) des Typs "System.Runtime.InteropServices.COMException" ist in mscorlib.dll aufgetreten.
Volumenkörper1:1
Eine Ausnahme (erste Chance) des Typs "System.NullReferenceException" ist in MyFirstInventorPlugin_Lesson1.exe aufgetreten.
Eine Ausnahme (erste Chance) des Typs "System.Runtime.InteropServices.COMException" ist in mscorlib.dll aufgetreten.
Eine Ausnahme (erste Chance) des Typs "System.Runtime.InteropServices.COMException" ist in mscorlib.dll aufgetreten.
While this doens´t stop the plugin from running, it will create an error when I select a non component like a workplane or else.
I can still run the plugin but it seems to have trouble with that COM object. Any ideas what´s causing this.
I have the feeling it will eventually give me more problems on the road ahead.
Best regards
Falk
Hi,
is the problem solved? I checked the source project 'lesson1_VisualExpress2010'. There is only 81 lines totally. But in your error dialog, it looks the failure occured at line 114. Did you add some of your own codes? If yes, could you share a copy for us to diagnose?
Hi There,
If yo have some time, can you please check the following link..
http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/HoleList/m-p/3678504#M40777
Thanks.
Hi,
I am a experinced software developer (.net) and new to the Autodesk. My forhthcoming assignment is to create a tool in .net using Visual Studio 2010 that will automate all the steps of inventor by Inventor API.
My orgnization is used to draw the Flange and base plate of electrical pole in the Inventor. And i want to automate this whole process. Suppose a drafter have to create 10 flange design in the Inventor then he will save all the input in the .csv file and my tool will read the inputs from the file and will create all the 10 design and save at any location.
First of all i want to know, is it possibe to automate each steps of the Inventor? If yes then please let me know form where i can access information about the all APIs.
Thanks in Advance
Hi,
From your description I would say that the Inventor API will allow you to automate this process.
Lesson 7 has links to resources for learning the Inventor API.
http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=17329549
Also the API is documented in the API help file. On my system it is here:
"C:\Program Files\Autodesk\Inventor 2013\Local Help\admapi_17_0.chm"
I would also check to see if using iLogic would meet your requirement. iLogic is documented in the Inventor help file:
Also Inventor Engineer-To-Order is a configurator which may also be of interest. http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=18361292
Cheers,
I moved this to here http://forums.autodesk.com/t5/Autodesk-Inventor-Customization/My-First-Plugin-Lesson-3-C-issue/td-p/...
Scott Moyse
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
RevOps Strategy Manager at Toolpath. New Zealand based.
Co-founder of the Grumpy Sloth full aluminium billet mechanical keyboard project
Can't find what you're looking for? Ask the community or share your knowledge.