On Wed, Jul 29, 2009 at 12:30 AM, Mark Hammond<skippy.hamm...@gmail.com> wrote:
> 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.

Right, I now understand this is what those numbers mean. This isn't
consistent with what I want the function to do, and more importantly
isn't working.

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

Sorry about that. It doesn't provide much to go on (I don't think):

model.PickObject(5, 0.5, 0, 0, 0, 0)

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    model.PickObject(opSystem, 0, 0, 0, 0, 0)
  File 
"C:\Python26\lib\site-packages\win32com\gen_py\684A3F60-0408-11D4-A05F-0050DA1AC1A8x0x2x0.py",
line 6985, in PickObject
    , tolerance, PType)
  File "C:\Python26\lib\site-packages\win32com\client\__init__.py",
line 456, in _ApplyTypes_
    self._oleobj_.InvokeTypes(dispid, 0, wFlags, retType, argTypes, *args),
com_error: (-2147352567, 'Exception occurred.', (0, None, None, None,
0, -2147467259), None)

The 5, 0.5, 0, 0 make sense. The last two zeros don't because I don't
know them ahead of time. (The purpose of the function is to retrieve
them.)

If I omit the parameters that don't mean anything to me on input, I
get com_error: (-2147352561, 'Parameter not optional.', None, None).

Regards,
Mike
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to