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. I'm not sure why Thomas chose to drop the "_put_" prefix from such propputref methods, but the following snippet: > (<class 'ctypes.HRESULT'>, '_get_DataSourceType', (<class > 'ctypes.LP_BSTR'>,), ((10, 'Text'),), ('propget', u'Data source > type.'), u'Data source type.') > > (<class 'ctypes.HRESULT'>, '_set_DataSourceType', (<class > 'comtypes.BSTR'>,), ((1, 'Text'),), ('propput', u'Data source type.'), > u'Data source type.') ... is a the more common _get/_put method pair for simple properties. The fact that this a propputref may be throwing the translation code, resulting in it being treated as a method rather than a property. 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. > FeatureClass is read-only. Would that have anything to do with it? Not according to my 8.3 ArcObjects docco. -------------------------> "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] ------------------------------------------------------------------------- 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