Thomas,

Thanks very much! Replacing the 'propputref' occurrences with  
'propput' worked. That is, feature.FeatureClass now returns a  
FeatureClass reference now and not a bound method.

Nick

On Oct 23, 2007, at 2:22 PM, Thomas Heller wrote:

> Nick Collier schrieb:
>> Hi,
>>
>> I originally and mistakenly posted this on the win32 list, so
>> apologies if its been seen already.
>
> No problem.  And apologies from myself for the late reply; I'm always
> very busy at the start of the week.
>
>> I'm working with some ESRI com libraries (9.0). I've managed to
>> retrieve an ILayer from an IMap and then cast IFeatureLayer from the
>> ILayer.
>>
>> feature = layer.QueryInterface
>> (comtypes.gen.esriGeoDatabase.IFeatureLayer)
>>
>> Now, what I want to get is the FeatureClass property of the feature.
>> So, I do:
>>
>> feature.FeatureClass
>>
>> and this yields:
>>
>> <bound method POINTER(IFeatureLayer).FeatureClass of <POINTER
>> (IFeatureLayer) object cbc990>>
>>
>> And
>>
>> feature.FeatureClass()
>>
>> yields:
>>
>> Traceback (most recent call last):
>>    File "<stdin>", line 1, in <module>
>> TypeError: required argument 'fclass' missing
>>
>> fclass needs to be a pointer to an IFeatureClass whose CoClass,
>> FeatureClass, is a non-creatable COM class.
>>
>>
>> Other properties seem to work. For example,
>>
>> feature.DataSourceType
>>
>> returns
>>
>> u'Personal Geodatabase Feature Class'
>>
>> I'm not sure if matters but the relevant parts of  
>> feature._methods_ are:
>>
>> (<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.")
>>
>> (<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.')
>>
>
> The problem is the 'propputref' in the 'FeatureClass' method.
>
> Personally, I use comtypes to access com objects implemented in
> ATL and MFC.  These com objects have not been designed for access from
> VB, this is probably the reason that I have never found  
> 'propputref' properties
> in these objects.
>
> So, the comtypes bug is that the 'propputref' midl keyword in  
> simply ignored; and
> it seems that it is wrongly converted into a method instead.
>
> I have read old discussions on the ctypes-users list (from more  
> than 2.5 years ago),
> where Stefan Schukat tried to explain the difference between  
> 'propput' and 'propputref'
> to me.  I think I'm grasping this eventually; still I have no idea  
> how com properties
> that have both 'propput' and 'propputref' should be exposed by  
> comtypes.
>
> I found that the MS speech api (SAPI.SpVoice) also uses  
> 'propputref' together with 'propget'
> for one property and was able to construct a test case with this.   
> It seems that, at least if
> 'propputref' but no 'propput' is present, handling 'propputref' in  
> comtypes in the same way
> as 'propput' will do the trick, at least for the speech objects.
>
> Maybe you can simulate this if you, in the generated files in the  
> comtypes\gen subdirectory,
> replace all 'propputref' occurrences with 'propput'.
>
> I would very much like to fix this issue, but I still have to find  
> one or two COM objects
> (on my system) that use both 'propput' and 'propputref' for the  
> same property.
> It would be great if someone can help me to construct some test cases.
>
> 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


-------------------------------------------------------------------------
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