gmcdonald@infocomp.com - Found word(s) list error in the Text
body - [Python-au] PythonCom Error
Grant McDonald
gmcdonald at infocomp.com
Thu Feb 10 03:46:33 CET 2005
My guess is that since a tuple is a python object and not a SAFEARRAY the
types are incompatible and hence no translation occurs. You probably have
to insert it element by element. Be aware this is only an educated guess.
-----Original Message-----
From: Christian Daldrup [mailto:Christian.Daldrup at gmx.de]
Sent: 09 February 2005 22:21
To: python-au at python.net
Subject: gmcdonald at infocomp.com - Found word(s) list error in the Text body
- [Python-au] PythonCom Error
Hello,
I am new in this mailing list and so first greetings to all users.
I have written a C++ Com Dll (VS 6). In this Dll I declared a struct
with a SafeArray(double) as a member.
My IDL implementation:
-------
typedef
[
uuid(19115fab-7e40-4505-9cc2-1a072fd4b033),
version(1.0),
helpstring("Parameters for Lib")
]
struct Params {
[helpstring("Distribution")] long lDistribution;
[helpstring("Type")] long lType;
[helpstring("a CalFlag")] long lACalFlag;
[helpstring("b CalFlag")] long lBCalFlag;
[helpstring("c CalFlag")] long lCCalFlag;
[helpstring("d CalFlag")] long lDCalFlag;
[helpstring("a")] double dA;
[helpstring("b")] double dB;
[helpstring("c")] double dC;
[helpstring("d")] double dD;
[helpstring("q")] double dQ;
[helpstring("ks")] SAFEARRAY(double) dKs;
} Params;
-------
First I created a file with makepy.py
Standard variables like "dA" I can set normally:
-----
import win32com.client
myCom = win32com.client.Dispatch("ComLib.Lib")
rec = win32com.client.Record('Params', myCom)
rec.dA = 3.5 # works fine
rec.dKs = (1.0, 2.0, 3.0 ,4.2, 5.5) # doesn?t work
----
Error Message:
Traceback (most recent call last):
File "C:\Visual Studio 6.0\com.py", line 6, in ?
myStruct.dKs = (1,2,3,4)
pywintypes.com_error: (-2147024809, 'Falscher Parameter.', None, None)
After this I try to use an array:
-----
import array
a = array.array('d', [1.4, 3.4])
b = buffer(a)
rec.dKs = b
# same error
In VBA I use the same struct, but their I ReDim the SafeArray:
----
Dim vp As Lib.Params
ReDim vp.dKs(UBound(params, 1))
Call Range2DblArray(params, vp.dKs)
# my vba fill function
Sub Range2DblArray(range As Variant, arr As Variant)
'ReDim myArray(UBound(range, 1))
Dim i As Integer
'..
For i = 1 To UBound(range, 1)
arr(i) = CDbl(range(i, 1))
Next i
'Range2Array = myArray
End Sub
In VB the Code works fine.
Now, I'd like to know, if it is possible to create/resize the dKs tuple in
the com_struct or if I have to implement a function in my DLL which adds
elements to my struct in the DLL?
thank you in advance
Christian
--
DSL Komplett von GMX +++ Supergunstig und stressfrei einsteigen!
AKTION "Kein Einrichtungspreis" nutzen: http://www.gmx.net/de/go/dsl
_______________________________________________
python-au maillist - python-au at starship.python.net
http://starship.python.net/mailman/listinfo/python-au
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://starship.python.net/pipermail/python-au/attachments/20050210/0f4b4741/attachment.htm
More information about the python-au
mailing list