Automate Inventor 2015 from Excel with VBA

Automate Inventor 2015 from Excel with VBA

rfink
Enthusiast Enthusiast
829 Views
3 Replies
Message 1 of 4

Automate Inventor 2015 from Excel with VBA

rfink
Enthusiast
Enthusiast

I am trying to open parts and assemblies from Excel using VBA code. Then I want to change some dimensions programatically.

 

I have no trouble manipulating parts and assemblies ilogic and rules that refer to worksheets that I have generated with VBA, but I would like to change the Inventor parameters directly with VBA from Excel.

 

I am not trying to write an Add-In using the Inventor 2015 VBA IDE or VB/C# interop in Visual Studio.

 

I did the exact same thing using SolidWorks, but I am now working with Inventor 2015.

 

Any help would be appreciated.

 

Thanks,

Ross

0 Likes
Accepted solutions (2)
830 Views
3 Replies
Replies (3)
Message 2 of 4

rossano_praderi
Collaborator
Collaborator
Accepted solution

Hi Ross,

this is a very basic example on how you can change an "UserParameter".

 

Sub Parametri()
'On Error Resume Next
Me.Application.WindowState = xlMinimized
    Dim Inv, oDoc As Object
    Dim Param As Inventor.Parameter
    Set Inv = GetObject(, "Inventor.Application")
    If Err.Number <> 0 Then
        MsgBox ("Errore di acquisizione controllo Inventor" & vbCr & "Inventor non attivo")
        Err.Number = 0
        Exit Sub
    End If
    Set oDoc = Inv.ActiveDocument
    For Each Param In oDoc.ComponentDefinition.Parameters.UserParameters
      If Param.Name = "test" Then
        If Param.Value = "finito" Then
          Param.Value = "iniziato"
        Else
          Param.Value = "finito"
        End If
      End If
    Next
End Sub

Of course the parameter "test" have to exist in your PartDocument.

 

Bregs

Rossano Praderi



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------
0 Likes
Message 3 of 4

rfink
Enthusiast
Enthusiast
Rossano,
Grazie mille!
Ross
0 Likes
Message 4 of 4

rossano_praderi
Collaborator
Collaborator
Accepted solution

Prego Ross 🙂



--------------------------------------
If my post answers your question, please click the "Accept as Solution"
button. This helps everyone find answers more quickly!
---------------