LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to access LabView from Python with ActiveX

Hi,

I´m trying to access LabView from Python.
But I´m struggeling on the way to pass Variant Arrays to the "call" function (I´m new with Python).
The VI I want to call has two parameters called "strEntry"(IN) and "Error"(OUT).
The first one is a string, the second is a boolean.

Here´s the current code, it works till the line "oViLogPrint.call"
import win32com.client
oLv = win32com.client.Dispatch("cbt.Application")
oLv = strAppDir = oLv.ApplicationDirectory
strViPath = strAppDir + "\\cbt.exe\\"
oViLogPrint = oLv.GetVIReference( strViPath + "cdcAxLogPrint.vi" ,"",True)
oViLogPrint.call(["strEntry","Error"],["Hello World"])


Thanks for help
Martin
0 Kudos
Message 1 of 3
(3,347 Views)
I have to add some info:

The problem seems to be a type conflict, because with the following code

import win32com.client
oLv = win32com.client.Dispatch("LabView.Application")

strVi = "D:\\Projects\\py.lv.test\\pytest.vi"

oViLogPrint = oLv.GetVIReference(strVi,"",True)

arIn = ["strEntry","Error"]
arOut = ["Hello World",True]

oViLogPrint.Call(arIn,arOut)

ends up with the following error message:

exec codeObject in __main__.__dict__
File "D:\Projects\py.lv.test\lv.py", line 25, in ?
oViLogPrint.Call(arIn,arOut)
TypeError: 'NoneType' object is not callable


For me it seems that the method "Call" is not callable, but wy ??

Thanks
Martin
0 Kudos
Message 2 of 3
(3,337 Views)
Here´s the solution provided by Mark Hammond via python win32 mailinglist:

>> Martin:
>> There is no data coming back from LabVIEW via the Call method.
>> The arParVals List is unchanged after the call. Normaly the last two
>> elements should held the result of the VI call.
>> In the other directon it´s working, I´m able to see the string "Hello
>> World" in LabVIEW.
>
>Note that in Python, "out" values (including in-out) are always *returned* from the function. Thus you probably want something like:
>
>rc, newVals = oViTest.Call(arParNames,arParVals)
>
>where 'rc' is whatever 'Call' returns - or, if 'Call' has no return value (ie a 'void' function, or 'procedure'), simply:
>
>newVals = oViTest.Call(arParNames,arParVals)
>
>Mark

For more infos see
http://mail.python.org/pipermail/python-win32/2005-June/003478.html

Martin

Message Edited by 2cv on 06-27-2005 03:07 AM

0 Kudos
Message 3 of 3
(3,330 Views)