Nick Collier wrote:

> I'm trying to use python to work with the various ESRI (the GIS
> folks) com libraries. However, I'm running into some difficulties.
> 
>   I've run makepy on the type library I'm interested in working with 
> and that yields:
> 
> ...
> # This CoClass is known by the name 'esriSystem.AoInitialize.1'
> class AoInitialize(CoClassBaseClass): # A CoClass ...
> 
> 
> But dispatching to that
> 
>  >>> client.Dispatch("esriSystem.AoInitialize.1")
> Traceback (most recent call last):
>    File "<interactive input>", line 1, in <module>
>    File "C:\Python25\Lib\site-packages\win32com\client\__init__.py",
> line 95, in Dispatch
>      dispatch, userName = dynamic._GetGoodDispatchAndUserName
> (dispatch,userName,clsctx)
>    File "C:\Python25\lib\site-packages\win32com\client\dynamic.py",
> line 98, in _GetGoodDispatchAndUserName
>      return (_GetGoodDispatch(IDispatch, clsctx), userName)
>    File "C:\Python25\lib\site-packages\win32com\client\dynamic.py",
> line 78, in _GetGoodDispatch
>      IDispatch = pythoncom.CoCreateInstance(IDispatch, None, clsctx,
> pythoncom.IID_IDispatch)
> com_error: (-2147467262, 'No such interface supported', None, None)
> 
> I'm assuming that this is because this doesn't implement IDispatch.
> 
> The relevant VB code does:
> 
> Set m_pAoInitialize = New AoInitialize
> 
> Is there any equivalent in win32com (or even ctypes) that I can use to

> get this working or is Python out of the question here?

A lot of the ESRI COM stuff doesn't support IDispatch.  ctypes, with the
comtypes add-on module, can be used to call the ESRI COM interfaces
quite successfully in my experience.

I've not tried using the ESRI 9.x stuff yet - still using 8.3 and an
ancient version of ctypes.  With the ESRI 8.x TLBs, there were issues
where many of the names were declared out of order as far as Python was
concerned and the generated modules had to be manually edited to rectify
this.  With 9.x, ESRI split the TLBs up a lot more so I don't know how
much this affects what gets generated.

-------------------------> "These thoughts are mine alone!" <---------
Andrew MacIntyre           National Licensing and Allocations Branch
tel:   +61 2 6219 5356     Inputs to Industry Division
fax:   +61 2 6253 3277     Australian Communications & Media Authority
email: [EMAIL PROTECTED] 
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to