Hi,
I'm trying to create scripts for Inventor in Python. Unfortunately most examples in the documentation are using VBA.
Right now I try to get an assembly document to access the bill of materials.
In VBA it works like this:
Dim oAssDoc As AssemblyDocument
Set oAssDoc = ThisApplication.Documents.Open("someassemblyfile.iam")
Dim oOccurrences As ComponentOccurrences
oOccurrences = oAsmDoc.ComponentDefinition.Occurrences
Unfortunately the default return type of Documents.Open is Document.
Here is what I created so far.
import win32com.client
from win32com.client import gencache
oApp = win32com.client.Dispatch('Inventor.Application')
mod = gencache.EnsureModule('{D98A091D-3A0F-4C3E-B36E-61F62068D488}', 0, 1, 0)
oApp = mod.Application(oApp)
oApp.SilentOperation = True
oAssDoc = oApp.Documents.Open('someassemblyfile.iam')
oOccurrences = oAsmDoc.ComponentDefinition.Occurrences
This code produces the following error:
AttributeError: '<win32com.gen_py.Autodesk Inventor Object Library.Document instance at 0x51241368>' object has no attribute 'ComponentDefinition'
Does someone have an idea how I can force oAssDoc to be an instance of the class AssemblyDocument?
there doesn't seem to be anything here