LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to open VI panels from Python

Hello everyone, a beginner in LabView and Python interaction. I am trying to open the VI panel from python and run it from Python, both in the same computer. I am not sure what libraries I need. I do not need to interact with the LabView panels. Just open, run, and close it all via python. Can any one guide me?

 

I came across this thread seems similar to what I need but couldn't figure out.

https://forums.ni.com/t5/LabVIEW/Calling-LabVIEW-VI-s-from-Python/m-p/1215167

 

If the VI panel is at the location "C:\Test\test.vi", how to open it via Python and run? Any libraries for python that can do this?

 

thank you,

grbharati

0 Kudos
Message 1 of 5
(550 Views)

@My CC Pay  wrote:

Hello everyone, a beginner in LabView and Python interaction. I am trying to open the VI panel from python and run it from Python, both in the same computer. I am not sure what libraries I need. I do not need to interact with the LabView panels. Just open, run, and close it all via python. Can any one guide me?

 

I came across this thread seems similar to what I need but couldn't figure out.

https://forums.ni.com/t5/LabVIEW/Calling-LabVIEW-VI-s-from-Python/m-p/1215167

 

If the VI panel is at the location "C:\Test\test.vi", how to open it via Python and run? Any libraries for python that can do this?

 

thank you,

grbharati


The usual case is to:

  1. Create a temporary file, write default contents to it
  2. Launch the command stored in the environment variable "EDITOR". This usually is a shell command, so it might contain arguments -> run it thourgh the shell or parse it accordingly
  3. Once the process terminates, read back temporary file
  4. Remove temporary file
0 Kudos
Message 2 of 5
(504 Views)

LabVIEW provides a subset of VI server methods and properties through its own ActiveX Automation server interface. 

With the Python ActiveX interface library you should be able to talk to that. It’s only a small subset of the current VI server interface, in fact it’s about as many methods and properties LabVIEW supported when the VI server was introduced around LabVIEW 6 days. Vi server has evolved way beyond that state, the ActiveX interface to it only received minor improvements since and none whatsoever in the last 10 years, but it supports enough to do what you want.

 

In fact LabVIEW even supports a DDE interface since its introduction on Windows, but that barely supports more than opening a VI from disk and is still the way the Windows shell (Explorer) interacts with it.

Rolf Kalbermatter
Averna BV
0 Kudos
Message 3 of 5
(494 Views)

I already have a VI file, sorry completely got lost with temporary file and editor part. can you elaborate for me please 🙂

0 Kudos
Message 4 of 5
(452 Views)

@grbharati wrote:

I already have a VI file, sorry completely got lost with temporary file and editor part. can you elaborate for me please 🙂


The temporary file mentioned by Paul was just a somewhat involved and unclear suggestion to do Interapplication Communication (IAC) between your Python app and the LabVIEW program through file IO. It is one way to communicate between two different applications if they both are written to communicate to each other through this means. You could also choose to use TCP/IP or some other IAC method.

 

But it won't allow you to directly control the LabVIEW VI from Python.

 

What I suggested is something different and while it does what you want, it's more complicated to setup and nowadays fraught with trouble, since ActiveX communication is definitely a legacy communication.

 

From within Python you use the win32com package. And then you load from there the LabVIEW ActiveX server.

 

There are many issues with this however and documentation of this got scarce in the meantime. LabVIEW had a Visual Basic example that showed how to access this interface from a VB app but they removed that example in LabVIEW 2013, supposedly because Microsoft discontinued Visual Basic more or less and support for this feature got a bit tricky, both because ActiveX is long considered a legacy technology already that has been completely superseded by .Net and because that ActiveX VI server interface is really a legacy from early LabVIEW days itself. Many of the methods it exposes are not documented by the modern TCP/IP based VI server interface because they are replaced by newer functions and/or considered unsafe.

 

The recommended way today is to create a LabVIEW .Net assembly that exposes a .Net interface that you can register and use on the system. In your specific case you could use the LabVIEW VI server interface inside that assembly to do pretty much whatever you would like to do, as far as the VI Server supports remote access. Not all properties and methods are allowed to be called remotely.

Rolf Kalbermatter
Averna BV
0 Kudos
Message 5 of 5
(444 Views)