Inventor Customization

Reply
ADN Support Specialist
wayne.brill
Posts: 185
Registered: ‎08-25-2004
Message 1 of 26 (4,798 Views)

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

4798 Views, 25 Replies
08-05-2011 01:24 PM

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

Active Contributor
C-Hoppen
Posts: 39
Registered: ‎04-25-2002
Message 2 of 26 (4,767 Views)

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

08-06-2011 05:49 AM 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

Valued Contributor
cean_au
Posts: 100
Registered: ‎07-11-2011
Message 3 of 26 (4,742 Views)

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

08-07-2011 10:24 PM in reply to: wayne.brill

thanks.

 

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

*Expert Elite*
scottmoyse
Posts: 1,591
Registered: ‎06-10-2009
Message 4 of 26 (4,729 Views)

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

08-08-2011 04:39 AM 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

Cheers
Scott Moyse

Please use Mark Solutions!.Accept as Solution &Give Kudos!Kudos to further enhance the value of these forums. Cheers!


   

ADN Support Specialist
wayne.brill
Posts: 185
Registered: ‎08-25-2004
Message 5 of 26 (4,615 Views)

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

08-17-2011 12:22 PM 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

Active Contributor
C-Hoppen
Posts: 39
Registered: ‎04-25-2002
Message 6 of 26 (4,609 Views)

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

08-17-2011 12:28 PM in reply to: wayne.brill

Thanks!

Christoph

Distinguished Contributor
JimStrenk
Posts: 146
Registered: ‎06-20-2006
Message 7 of 26 (4,516 Views)

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

09-06-2011 08:41 PM 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

Other than THAT, Mrs. Lincoln, how was the play??
Illinois: Where we send more Govenors to prison, than on to retirement!
ADN Support Specialist
wayne.brill
Posts: 185
Registered: ‎08-25-2004
Message 8 of 26 (4,495 Views)

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

09-08-2011 03:07 PM 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

Distinguished Contributor
JimStrenk
Posts: 146
Registered: ‎06-20-2006
Message 9 of 26 (4,489 Views)

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

09-08-2011 09:57 PM 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

Other than THAT, Mrs. Lincoln, how was the play??
Illinois: Where we send more Govenors to prison, than on to retirement!
Mentor
tmccar
Posts: 441
Registered: ‎11-28-2007
Message 10 of 26 (4,210 Views)

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

11-09-2011 03:16 AM in reply to: JimStrenk

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

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community


Inventor Exchange Apps

Created by the community for the community, Autodesk Exchange Apps for Autodesk Inventor helps you achieve greater speed, accuracy, and automation from concept to manufacturing.

Connect with Inventor

Twitter

Facebook

Blogs

Pinterest

Youtube