Search code examples
pythonpython-2.7autodeskautodesk-inventor

Using python to automate Autodesk Inventor


Is there a way to open and control a solid model in Inventor using python?

My goal to start with a database of dimensions and simulate every configuration.


Solution

  • This snippet is a great place to start:

    #Open Inventor
    invApp = win32com.client.Dispatch("Inventor.Application")
    
    #Make inventor visible
    invApp.Visible = True
    
    #Set file names of template
    Part_FileName_BaseIPT = 'C:\\Base.ipt'
    
    #Open the base model
    oPartDoc=invApp.Documents.Open(Part_FileName_BaseIPT)
    
    #Collect parameters
    oParams = oPartDoc.ComponentDefinition.Parameters
    
    #Set Angularity        
    oParams.Item("Name").Expression = *Value*
    
    #Update document
    oPartDoc.Update()
    
    #Save new version
    oPartDoc.Save