[python-win32] Client side COM and Python Problem

Mark Hammond mhammond at skippinet.com.au
Thu Dec 14 07:20:37 CET 2006


> #code
> import win32com.client
> o = win32com.client.Dispatch("MAX.Application.8")
> o.mypingmax("test string")
>
> # Python Error
>
> Traceback (most recent call last):
>   File "<interactive input>", line 1, in ?
>   File
> "C:\Python24\lib\site-packages\win32com\client\dynamic.py", line
> 491, in __getattr__
>     raise pythoncom.com_error, details
> com_error: (-2147220992, 'CONNECT_E_NOCONNECTION', None, None)
>
> #client Application error (3dsmax script output)
>
> -- Argument count error: mypingmax wanted 1, got 0
>    during OLE automation function call

>From the "wanted 1, got 0" message, it appears that the problem is that
Python first checks to see if there is a *property* named 'mypingmax' before
checking if it is a method.  The way Python works, that is hard to avoid.
If the app returned a "normal" error code in that case things would march on
fine.

You could try calling the _FlagAsMethod method on the object.  Something
like:

o = win32com.client.Dispatch("MAX.Application.8")
o._FlagAsMethod("mypingmax")
o.mypingmax("test string")

That should prevent win32com from first checking if the item is a property.

HTH,

Mark



More information about the Python-win32 mailing list