LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

export vi

Hi,
 I've been searching for a scripting mechanism for Lab View, and after seeing this discussion about manipulating LabView panel elements with Python I thought I had a good solution.  I looked at LuaView but think that's too much of a learning curve and I'm already familiar with Python. 

http://forums.ni.com/ni/board/message?board.id=170&thread.id=199564

The example shown there uses a simple Python program to get a reference to a running LabView exe and changes a control value.  The LabView.vi is provided as well but it'w 7.1 and I have 7.0 so I built my own VI and created an executable version of it.  Both my VI and the executable form (both of which should work), fail in the getvireference call.

It appears that for the VI to be referenced it has to be exported, but I can't seem to be able to figure out how that is done!  I've searched viserver examples, documentation, this forum and still find myself running in circles.

How do you make a VI available for reference by code similar to...
import win32com.client
labview = win32com.client.Dispatch("Labview.Application")
VI = labview.getvireference(r'MyTest.vi')
VI.setcontrolvalue(''Setting_1,'5')
It's got to be simple....

Robert



0 Kudos
Message 1 of 5
(3,886 Views)
I just hate it when you find an answer right after posting a question.  I still don't fully understand what's happening but my previous problems seemed to be due to a lack of experience with Dispatch usage. It now works with the exe which was built with the "Enable ActiveX Server" checked.

Now to move back to the LabView vi itself. 

Robert
0 Kudos
Message 2 of 5
(3,883 Views)
Hi Robert,

For the LabVIEW VI itself, do you have the VI server enabled?
Regards,

Jeremy_B

Applications Engineer
National Instruments
0 Kudos
Message 3 of 5
(3,857 Views)
Hi Jeremy_B

This was actually very easy. In myVI under Tools->Options....

In VI Server: Configuration, I have ActiveX enabled and all Server Resources turned on.. (Allow VI calls etc)

In "VI Server: Exportedf VIs" I just added the name of my VI to the Exported VI list. 

Now Python controls the VI and can read data from the front panel. Very clean and easy to implement.

However,  rather than having to call something like...
VI.setcontrolvalue('CtlName', newValue)
Is there a way to get a refrence to the control rather than haveing to address it by name every time? I'm not that experienced with COM so I'm not sure what the limitations are. The way it works now is just fine with me all the details are hidden in a Python class so I can just do....
myVI.SetButton1(True)
userInput = myVI.GetUserVal()
This has solved my current need for scripting test sequences and makes it much easier to log data to a database.

Robert







0 Kudos
Message 4 of 5
(3,833 Views)
Hi Robert,

As far as I can tell, it is not possible to get a control reference through the COM interface.
Regards,

Jeremy_B

Applications Engineer
National Instruments
0 Kudos
Message 5 of 5
(3,811 Views)