Python code has an error: 'module' object is not callable

575 views Asked by At

I try to coonect to API of Autodesk Inventor with Python. I can create a new file but then an error aooears here:

import os
import win32com.client
from win32com.client import constants
from win32com.client import gencache
os.system(r'C://Programm Files/Autodesk/Inventor 2014/Bin/Inventor.exe')
invApp = win32com.client.Dispatch("Inventor.Application")
invApp.Visible = True
mod = gencache.EnsureModule('{D98A091D-3A0F-4C3E-B36E-61F62068D488}', 0, 1, 0)
**invApp = mod.Application(invApp)** 

oAssemblyDoc=invApp.Documents.Add(constants.kAssemblyDocumentObject, "", True)

asd = invApp.Documents.Add(constants.kPartDocumentObject,"",True)
qwe=invApp.Documents.Item(asd)
oAss = oAssemblyDoc.Activate

There ir an error in the selected line:

TypeError: 'module' object is not callable

I am a novice in Python and I can't understand what is the error. Can anybody help me?

1

There are 1 answers

0
TobyB On

I see that the win32com gencache early binding produces some subfolders. This seems to work with:

invApp = mod.Application.Application(invApp)

I found that makepy.py had to be run with -i command option first time, then re-run to capture the full structure.