LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Updating Labview.exe front panel from python

Hi

Is it possible to update a labview.exe front panel from python?

I tried this:
import win32com.client
labview = win32com.client.Dispatch("Labview.Application")
VI = labview.getvireference(r'python.vi')
VI.setcontrolvalue('Numerisch','5')

and it works fine. But when i replaced the python.vi trough a compiled python.exe i get this errormessage:

I tried this:
import win32com.client
labview = win32com.client.Dispatch("Labview.Application")
VI = labview.getvireference(r'python.exe')
VI.setcontrolvalue('Numerisch','5')

Traceback (most recent call last):
  File "<interactive input>", line 1, in ?
  File "<COMObject Labview.Application>", line 2, in getvireference
com_error: (-2147352567, 'Ausnahmefehler aufgetreten.', (5507, 'LabVIEW', 'LabVIEW :LabVIEW:  Datei nicht gefunden. Die Datei wurde eventuell verschoben oder gel\xf6scht, oder der Dateipfad wurde bez\xfcglich Ihrer Plattform nicht korrekt formatiert. Beispiel: verwenden Sie \\ als Pfadseparator auf Windowsplattformen, : auf Macintosh u', None, 0, 0), None)

Is it possible to updating a labview exe front panal from python?

regards

0 Kudos
Message 1 of 31
(8,871 Views)
Hi Iveco,

have you tried updating the value from another VI (not in the executable!)? I think you are calling the wrong application, i'm not fully positive about this but that might be a problem.
First make sure the VI-server is enabled, and the python.vi is exported.

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 2 of 31
(8,870 Views)
Hi Ton

import win32com.client
labview = win32com.client.Dispatch("Labview.Application")
VI = labview.getvireference(r'C:\TEMP\python.vi')
VI.setcontrolvalue('Numerisch','5')

this works fine. that means i can change the value in the python.vi. But when I compile the vi to python.exe it doesnt work.

How can I enable the vi server?

regards

Marcel
0 Kudos
Message 3 of 31
(8,864 Views)
That should be done in the build settings, AND you should refer to the VI as c:\temp\executable.exe\python.vi

Ton
Free Code Capture Tool! Version 2.1.3 with comments, web-upload, back-save and snippets!
Nederlandse LabVIEW user groep www.lvug.nl
My LabVIEW Ideas

LabVIEW, programming like it should be!
0 Kudos
Message 4 of 31
(8,863 Views)
Hi all

It still doesnt work. I dont know why.

The current python code:

import win32com.client
labview = win32com.client.Dispatch("Labview.Application")
VI = labview.getvireference(r'C:\TEMP\python.exe\python.vi')
VI.setcontrolvalue('Numerisch','5')

I registered with ccrpRegUtil.exe the builded tlb file.(Not sure its necessary)
Activex Server is active at the builder config.

when I change VI = labview.getvireference(r'C:\TEMP\python.exe\python.vi') to VI = labview.getvireference(r'C:\TEMP\python.vi')
and then I use the vi it works. with the compiled python.exe(with activex server)not.

I dont know maybe Im to stupid.

regards

Marcel

0 Kudos
Message 5 of 31
(8,849 Views)
Thank you all for your help.

The Solution:

import win32com.client
labview = win32com.client.Dispatch("Python.Application")
VI = labview.getvireference(r'c:\temp\python.exe\python.vi')
VI.setcontrolvalue('Numerisch','5')

regards

Marcel
Message 6 of 31
(8,808 Views)
Excellent! I'm glad you got it working...

Since you are interested in this area, you might check out this example program. I know it is a side-step from what you are working on, but it's very interesting. The idea is to wrap the LabVIEW ActiveX Server into a .NET object and then use IronPython code to manipulate LabVIEW objects from within a LabVIEW VI! It's a neat way to blend textual and G code into one.

http://community.ni.com/examples/using-ironpython-from-labview/

P.S. This is from our new community sight. Feel free to look around or post any code that you created. Happy coding 🙂
Jarrod S.
National Instruments
Message 7 of 31
(8,805 Views)
Hi,
 
accessing a control with python works fine, but how can I read/write a control wich is part of a "Tab"?
 
Thanks,
 
Marcus
0 Kudos
Message 8 of 31
(8,488 Views)
Hi all,

I am new to this.
I want exchenge the data from pyton to labview and vice versa.
can u give the steps to do the above.
Please give with an example.
I amtrying really hard and i dint get the same.

Thanks in advance,
Yogesh
0 Kudos
Message 9 of 31
(8,201 Views)
1. Unzip python.zip
2. Copy all files into c:\temp
    --> c:\temp\labview.py
    --> c:\temp\python.exe
    --> c:\temp\python.vi ......and so on

3. Open dos shell
4. change dir to c:\temp
5. Open Pythonwin
6. PythonWin: File Open c:\temp\labview.py
7. Run --> Ok

Now it should work


0 Kudos
Message 10 of 31
(8,182 Views)