Andrew MacIntyre schrieb:
> Nick Collier wrote:
> 
>> I'm working with some ESRI com libraries. I've managed to retrieve an 
>> ILayer from an IMap and then cast IFeatureLayer from the ILayer.
>> 
>> fc = layer.QueryInterface(comtypes.gen.esriGeoDatabase.IFeatureLayer)
>> 
>> I don't have much experience at all with COM and what's confusing me 
>> now is difference between methods and properties as they are seen by 
>> comtypes. I can do
>> 
>> feature.DataSourceType
>> 
>> and get:
>> 
>> u'Personal Geodatabase Feature Class'
> 
> Under the hood, COM properties are methods.  VB just wraps the method
> calls for you.  So in a TLB there are both _get* (read) and _put*
> (write) prefixed methods for each property as declared in the TLB.
> _putREF* methods are a variant of _put* methods which are exclusively
> used for passing interface pointers instead of simple values.  I get the
> distinct impression that ESRI's use of _putREF* is different from a lot
> of other vendors...
> 
> I've not used comtypes as it currently exists, but from the snippet:
> 
>> (<class 'ctypes.HRESULT'>, '_get_FeatureClass', (<class 
>> 'ctypes.LP_POINTER(IFeatureClass)'>,), ((10, 'fclass'),), ('propget', 
>> u"The layer's feature class."), u" The layer's feature class.")
>> 
>> (<class 'ctypes.HRESULT'>, 'FeatureClass', (<class 'comtypes.POINTER 
>> (IFeatureClass)'>,), ((1, 'fclass'),), ('propputref', u"The layer's 
>> feature class."), u"The layer's feature class.")
> 
> ... the FeatureClass method is the property put, so you must use
> _get_FeatureClass() to retrieve the IFeatureClass you seek.

Well, apart from the propputref bug, comtypes exposes COM properties
as Python properties.  So, when the bug is fixed, 'feature.FeatureClass'
should work.

> I'm still using the COM support in ctypes 0.6.3 (positively ancient!)
> and have built a wrapper layer making it more VB like on top.  However
> it's a hand built wrapping which I extend every time I need a new
> coclass or interface.  At some point I'll get my boss to agree to
> updating...  but for the time being it works well.

I have skimmed the conversation that we had 2.5 years ago on the ctypes-users
list, and it seems that nearly all of your suggestions are now implemented ;-).
Some in a slighlty different way, though.  But - you should definitely upgrade.


Thomas


-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
comtypes-users mailing list
comtypes-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/comtypes-users

Reply via email to