LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Pass data from LabVIEW executable to Python

Solved!
Go to solution

I'd like to use Python to read the value of a string indicator in a LabVIEW executable. I created a proof-of-concept exe that generates a string, and following this LabVIEW support doc I can successfully read the string value in python using the following script:

 

import win32com.client
LabVIEW = win32com.client.Dispatch("Application.Application")
VI = LabVIEW.getvireference(r'C:\temp\ActiveXpractice\My Application\Application.exe\ActiveXpractice.vi')
while True:
result = VI.getcontrolvalue('String')
print(result)

 

The problem is that when I try this with another LabVIEW exe that was made from a larger LabVIEW project including many subVIs, I get the following error:

 

com_error: (-2147352567, 'Exception occurred.', (6945, 'LabVIEW', 'LabVIEW: Open VI Reference no longer matches VIs in memory by filename. A filename is no longer sufficient because the full name of a VI now includes any owning libraries.', None, 0, 0), None)

 

The only difference between the two executables that I can tell is that the first one was built from a project with a single vi, while the second contained many subvis other than the main one being referenced. Does anyone understand what this error means in this context? Is there another way to reference the vi?

Download All
0 Kudos
Message 1 of 4
(140 Views)

Send out the VI's path in a one button dialog in the target VI. I'm assuming it now is similar to 'C:\temp\ActiveXpractice\My Application\Application.exe\library.lvlib:ActiveXPractice.vi'

G# - Award winning reference based OOP for LV, for free! - Qestit VIPM GitHub

Qestit Systems
Certified-LabVIEW-Developer
0 Kudos
Message 2 of 4
(119 Views)
Solution
Accepted by topic author rcaminiti

Thanks for your response, I still couldn't get it to work though. I ended up going with UDP communication instead. The LabVIEW executable sent info to a UDP port and I was able to read it using Python.

Message 3 of 4
(67 Views)

The reason is that if you have multiple VIs in different sub-directories, LabVIEW builds the path inside the executable relative to the project directory. So the path created is actually including intermediated directories relative to the directory the project file is in.

 

You can disable that by  checking the checkbox in the Build Application Properties under Advanced->Use LabVIEW 8.x file layout. But that will not work if you have multiple libraries or classes with VIs that have the same name.

Rolf Kalbermatter
My Blog
0 Kudos
Message 4 of 4
(47 Views)