[python-win32] Invalid number of parameters on makepy-generated method

Federico Fanton federico at panizzolo.it
Fri Oct 1 16:36:17 CEST 2010


Hi everyone!
I'm trying to automate an operation with Alibre Design
(http://www.alibre.com) via COM.

It is mostly working, except for a call to a method that accepts a
single optional boolean parameter. When I try to call this method, I get
an "Invalid number of parameters" exception.

Here's my code:

----------------

import win32com.client
import pywintypes

try:
     # Check if Alibre is already running
     h = win32com.client.GetObject(Class="AlibreX.AutomationHook")
except pywintypes.com_error:
     h = win32com.client.Dispatch("AlibreX.AutomationHook")
     h.Initialize("", "", "", False, 0)
root = h.Root

# Open a file and get its mass

f = root.OpenFile(path_to_file)
d = win32com.client.CastTo(f, "IADDesignSession")
mass = d.PhysicalProperties(2).Mass
f.Close()

----------------

The exception is triggered from the last call.. makepy generates it in
this way:

----------------

def Close(self, saveSession=False):
    """Closes the session and saves the modified session and
sub-sessions, if any, to their original folder locations, if the
saveSession flag is set to true. Use SaveNew or SaveAs if this session
is being saved for the first time"""
    return self._oleobj_.InvokeTypes(7, LCID, 1, (24, 0), ((11,
49),),saveSession )

----------------

This matches the documentation of Alibre's API, and what I get when I
try to inspect the corresponding DLL using Reflector.

Any idea on what I could try?

Thanks for your time!

(Python 2.6.2, pywin32-214, windows XP)



More information about the python-win32 mailing list