Variable Transfer
Introduction
1. Send and Receive Variables from labVIEW to Python
To send variables, use Add Argument.vi and wire the variable to "Argument" terminal. Then pass the "Argument Object Variant Out" to Call Py Method.vi.
To Receive variables, use Pop Return Object.vim. Notice that LabVIEW should define a type when use a variable, so when receive a variable to an indicator, you should wire "Data Type (default value)" too.
2. Supported Variable Type
Type in LabVIEW | Type in Python |
---|---|
unsigned/signed Byte, Word, Long, Quad | int |
Single, Double | float |
Bool | bool |
String | string |
Numeric Array | ndarray |
Other Array | list |
Cluster | dictionary |
- int in python 3 has no limitless, and float is same as double so data transfer has no precision loss.
- on LabVIEW, Cluster Array is not supported.
3. Sample Scripts
This tutorial shows that how to transfer argument and receive the return value to LabVIEW. The return values are None Type, Bool, Int, String, Numeric Array, String Array and Double.
/script_folder/function.py
import numpy as np
def variable_transfer(b, d, str, array, d2=1919, d3=810):
if str == "":
str = "pykit-for-labview"
else:
str += "!"
return None, not b, d + 1, str, array + 1, np.random.random((3, 3)), ["abc", "def", ""], d2+d3*10
There are two sample VIs included in the source code file. Both them works the same.

The advance example shows that, if there are so many types to stack, you can simplify by using "Add Arguments Ex" express vi and pop 4 variables all at once.

Press Run Button several time to see the variable change on Indicator.