I try use win32com for realize interface:
[code lang='IDL']
...
typedef [...]
struct tagMatrix3d {
Point3d RowX;
Point3d RowY;
Point3d RowZ;
} Matrix3d;
...
interface ILocateCommandEvents : IDispatch {
...
HRESULT LocateFilter([in] _Element* Element, [in, out] Point3d* Point, [in, out] VARIANT_BOOL* Accepted);
...
};
...
[/code]
I'd made it in such way:
[code lang='python']
class LocateCommandEvents(object):
_com_interfaces_ = [IID_ILocateCommandEvents]
_typelib_guid_ = '{CF9F97BF-39F2-4B8E-835C-8BE9E99DAF5B}'
_typelib_version_ = 8, 0
_typelib_lcid_ = 0
_public_methods_ = []
_dispid_to_func_ = {..., 0x60020002: 'LocateFilter', ...}
def LocateFilter(self, Element, Point, Accepted):
print 'LocateFilter'
print Element, Point, Accepted
return S_OK, None, True
...
[/code]
Now errors occur in calls to LocateCommandEvents.LocateFilter function
from MicroStation:
[code]
LocateFilter
<win32com.gen_py.Bentley MicroStation DGN 8.0 Object Library._Element instance at 0x12737352> 2223916 True
pythoncom error: Failed to call the universal dispatcher
Traceback (most recent call last):
File "C:\Lang\Python\25\lib\site-packages\win32com\universal.py",
line 193, in
dispatch
WriteFromOutTuple(retVal, meth._gw_out_args, argPtr)
<type 'exceptions.TypeError'>: The VARIANT type is unknown (0x24).
pythoncom error: Unexpected gateway error
Traceback (most recent call last):
File "C:\Lang\Python\25\lib\site-packages\win32com\universal.py",
line 193, in
dispatch
WriteFromOutTuple(retVal, meth._gw_out_args, argPtr)
<type 'exceptions.TypeError'>: The VARIANT type is unknown (0x24).
[/code]
Logged In: YES
user_id=14198
Originator: NO
win32com\src\univgw_dataconv.cpp needs to learn about the VT_RECORD type. PyRecord.cpp contains a function:
BOOL PyObject_AsVARIANTRecordInfo(PyObject *ob, VARIANT *pv)
which oleargs.cpp uses to convert records in the IDispatch case. This function fills the 'pv' element of a variant - you may like to refactor this into 2 functions - one to give the raw pointer and one to set the pointer in the variant. On the other hand, it may be that 'pyrec->pdata' is all you need to pass - I'm not sure how records are passed to vtable based functions. Let me know if that makes sense...