Passing a tuple of lists to ActiveX
Mark Hammond
mhammond at skippinet.com.au
Fri Feb 28 18:45:44 EST 2003
Anand wrote:
> Hi,
> I am trying to talk to labview XY graph using ActiveX. Here is
> a small piece of code that i used.
>
>
>>>>LV = win32com.client.Dispatch("Labview.application") #get an
Try replacing this with:
LV = win32com.client.gencahce.EnsureDispatch("Labview.application")
This will create any type info available for the object. This may
infact be all you need to do.
Currently, without type info, Python may be making its best guess for
the type you want to send (it will guess a safe-array of integers in
your example.) With type info, Python may be told the specific type
(which may be a safearray of doubles)
>
> handle to labview activex server
>
>
>>>>vi = lv.getvireference(r'c:\test.vi') # open the vi containing the
>
> graph
>
>
>>>>vi.setcontrolvalue("Graph1",[(1,2,3),(1,2,3)])
>
> Traceback (most recent call last):
> File "<interactive input>", line 1, in ?
> File "<COMObject <unknown>>", line 2, in setcontrolvalue
> com_error: (-2147352567, 'Exception occurred.', (0, None, None, None,
> 0, -2147352571), 2)
>
>>>>vi.getcontrolvalue("Graph1")
>
> ((10.0, 11.0), (10.0, 11.0))
>
> I am able to read from the graph object but i am not able to write to
> it!.
Did you try passing back in exactly what you got out? Maybe labview is
not smart enough to deal with an array of ints and convert them to doubles.
Mark.
More information about the Python-list
mailing list