Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Check out the self-paced guide “My First Plug-in”

59 REPLIES 59
Reply
Message 1 of 60
wayne.brill
31491 Views, 59 Replies

Check out the self-paced guide “My First Plug-in”

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



Wayne Brill
Developer Technical Services
Autodesk Developer Network

59 REPLIES 59
Message 2 of 60
C-Hoppen
in reply to: wayne.brill

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

Message 3 of 60
cean_au
in reply to: wayne.brill

thanks.

 

Just figured out how to add a form in my vb.net project.

Message 4 of 60
scottmoyse
in reply to: cean_au

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.


EESignature


Design & Manufacturing Technical Services Manager at Cadpro New Zealand

Co-founder of the Grumpy Sloth full aluminium billet mechanical keyboard project

Message 5 of 60
wayne.brill
in reply to: C-Hoppen

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 Brill
Developer Technical Services
Autodesk Developer Network

Message 6 of 60
C-Hoppen
in reply to: wayne.brill

Thanks!

Christoph

Message 7 of 60
JimStrenk
in reply to: wayne.brill

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!

Jim Strenk

Inventor 2012 Certified Associate
AutoCAD 2012 Certified Associate

Product Design Suite Ultimate 2012, 2013, 2014, 2015,2016, 2017

Other than THAT, Mrs. Lincoln, how was the play??
Message 8 of 60
wayne.brill
in reply to: JimStrenk

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>

 

 



Wayne Brill
Developer Technical Services
Autodesk Developer Network

Message 9 of 60
JimStrenk
in reply to: wayne.brill

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!

Jim Strenk

Inventor 2012 Certified Associate
AutoCAD 2012 Certified Associate

Product Design Suite Ultimate 2012, 2013, 2014, 2015,2016, 2017

Other than THAT, Mrs. Lincoln, how was the play??
Message 10 of 60
tmccar
in reply to: JimStrenk

Is there a C# version of "Lesson 1" available?

Message 11 of 60
wayne.brill
in reply to: tmccar

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



Wayne Brill
Developer Technical Services
Autodesk Developer Network

Message 12 of 60
tmccar
in reply to: wayne.brill

Ok, thanks

Message 13 of 60
fjr74vp
in reply to: wayne.brill

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.

Tags (3)
Message 14 of 60
fjr74vp
in reply to: wayne.brill

well, searching a bit more, I saw that it is a purely .Net issue. I'll try to find a solution, but if someone could show me a path, I would appreciate it.
Message 15 of 60
falkmassmann
in reply to: fjr74vp

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

Message 16 of 60

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?

Message 17 of 60
ADNpati
in reply to: xiaodong_liang

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.

Mechanical Engineer
Inventor Applications Engineer

--------------------------------------------------------------------------------------

If my solution seems to remedy your problem, please press the Accept Solution button, Some KUDOS -

-------------------------------------------------------------------------------------
Message 18 of 60
purushottam2
in reply to: wayne.brill

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

Message 19 of 60
wayne.brill
in reply to: purushottam2

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:

http://wikihelp.autodesk.com/Inventor/enu/2013/Help/0126-Tutorial126/0127-Inventor127/0261-iLogic_B2...

 

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,



Wayne Brill
Developer Technical Services
Autodesk Developer Network

Message 20 of 60
scottmoyse
in reply to: wayne.brill

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.


EESignature


Design & Manufacturing Technical Services Manager at Cadpro New Zealand

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.

Post to forums  

Autodesk Design & Make Report