[python-win32] By-reference COM method arguments not being treated as outputs
Mark Hammond
skippy.hammond at gmail.com
Wed Jul 29 07:30:47 CEST 2009
On 29/07/2009 7:30 AM, Mike Graham wrote:
> Upon some further investigation, I have come to understand the method
> a bit better
>
> def PickObject(self,
> obj=defaultNamedNotOptArg,
> x=defaultNamedNotOptArg,
> y=defaultNamedNotOptArg,
> z=defaultNamedNotOptArg,
> obj_num=defaultNamedNotOptArg,
> entity_num=defaultNamedNotOptArg,
> tolerance=9.9999997473787516e-06,
> PType=0):
> """Retrieve an object ID and face or edge number by giving an object
> type and global coordinates"""
> return self._ApplyTypes_(76,
> 1,
> (24, 0),
> (
> (16387, 3),
> (12, 1),
> (12, 1),
> (12, 1),
> (16387, 3),
> (16387, 3),
> (5, 49),
> (3, 49)
> ),
> u'PickObject',
> None,
> obj, x, y, z, obj_num, entity_num, tolerance, PType)
>
>
> The tuple of tuples in the _ApplyTypes_ call is of flags for each obj,
> x, y,...PType. For example,
> (type, input_or_output_flag) = (16387, 3)
> where 3 I believe indicates an input/output parameter.
Actually, I made this mistake in the last message I sent too. These are
the "param flags", and they have the values:
OAIdl.Idl:const USHORT PARAMFLAG_NONE = 0x00;
OAIdl.Idl:const USHORT PARAMFLAG_FIN = 0x01;
OAIdl.Idl:const USHORT PARAMFLAG_FOUT = 0x02;
OAIdl.Idl:const USHORT PARAMFLAG_FLCID = 0x04;
OAIdl.Idl:const USHORT PARAMFLAG_FRETVAL = 0x08;
OAIdl.Idl:const USHORT PARAMFLAG_FOPT = 0x10;
OAIdl.Idl:const USHORT PARAMFLAG_FHASDEFAULT = 0x20;
OAIdl.Idl:const USHORT PARAMFLAG_FHASCUSTDATA = 0x40;
So we appear to have 3 params defined as "in out" and, as
hex(49)=='0x31', we have 2 "optional" params at the end.
> I can change
> these to 1 (for input) and 2 (for output for obj_num and entity_num),
> but it still does not work. I suspect there might have to be other
> changes in order (obj_num and entity_num shouldn't
> ==defaultNamedNotOptArg, for example, and I am not sure if they should
> be passed to _ApplyTypes_ at all).
>
> I think this is the basis of the problem, but I still cannot solve it.
> Nowhere else in my generated file can I find an example of this
> working right to follow. I am really hoping to get this working.
I don't think you've ever pasted the exception you get. From the
signature above, it appears you need to pass 6 params, and can expect 3
back.
Cheers,
Mark
>
> Thanks,
> Mike
>
> On Tue, Jul 28, 2009 at 9:00 AM, Mike Graham<mikegraham at gmail.com> wrote:
>> Hi Greg,
>>
>> Thanks for your reply. I went back through the mailing list archives
>> to try to find someone else who had the same problem I did and found
>> your posts, but I couldn't quite understand your and Hammond's
>> solutions well enough to apply it. Perhaps you or someone else can
>> help me understand what's going on better.
>>
>> You present what looks like an item from a dict:
>> "feSelector": (10349, 2, (9, 0), (), "feSelector", None)
>> and explain that the None in the tuple should be replaced by the CLSID
>> of the class to which "feSelector" belongs.
>>
>> The method I posted as an example's name does not occur in any dicts.
>> It occurs in two places in the generated source. The first is the
>> method definition I posted, in which it is part of a class
>> _IDualModelItem(DispatchBaseClass) with the member
>> CLSID=IID('{976FAFC8-96FD-11D4-A09D-0050DA1AC1A8}'). I am not aware of
>> any particular python class from which this should be associated with.
>>
>> In my definition, I have a tuple that appears to be laid out the same
>> as yours, so I tried replacing None with
>> '{976FAFC8-96FD-11D4-A09D-0050DA1AC1A8}', but this didn't change
>> anything.
>>
>> The other occurrence is in the list _IDualModelItem_vtables_, where one item is:
>> (( u'PickObject' , u'obj' , u'x' , u'y' , u'z' , u'obj_num' ,
>> u'entity_num' , u'tolerance' , u'PType' , ),
>> 76,
>> (76, (),
>> [(16387, 3, None, None), (12, 1, None, None), (12, 1, None, None),
>> (12, 1, None, None), (16387, 3, None, None), (16387, 3, None, None),
>> (5, 49, '9.9999997473787516e-06', None), (3, 49, '0', None)],
>> 1,
>> 1,
>> 4,
>> 0,
>> 332,
>> (3, 0, None, None),
>> 0)
>> )
>>
>> To tell the truth, I have no idea what _IDualModelItem_vtables_ does.
>> I think I've examined these as close as I can without disecting the
>> win32com.client module itself or finding some documentation (if there
>> is documentation of any depth somewhere, I would love a link; I was
>> unable to find any.)
>>
>> Can anyone provide any further insight?
>>
>> Mike
>>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
More information about the python-win32
mailing list