From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

To invoke an application exe built using Labview from python.

I have enabled VI server. Please go through the scrpit below. With this I m getting error in the VIpath line itself. If I am able to get reference to it, I can read back the values.

 

from ctypes import *
import comtypes.client

comtypes.CoInitialize()

 

TypeLibPath = "C:/Program Files (x86)/National Instruments/LabVIEW 2010/resource/labview.tlb"

# Attention: For unknown reason first attempt of type library import via
# GetModule() fails if comtypes.client.gen_dir is set to a directory.
# Solution: Set it to none so all imported data is kept only in memory.
comtypes.client.gen_dir = None
comtypes.client.GetModule(TypeLibPath)

try:
Application = comtypes.client.CreateObject("LabVIEW.Application", None, None, comtypes.gen.LabVIEW._Application)


#Parameters
Channel_1=[1,2,3]
Channel_2=[8,9,10]
Data=[Channel_1,Channel_2]
Read="FALSE"
ParameterNames=("Data","Read")
Parameters=[Data,Read]
VIPath="C:\Users\i14301\Desktop\Labview_from_Python\ComplexData.exe"

 

#Get VI Reference
VirtualInstrument = Application.GetVIReference(VIPath)

#Open VI front panel in hidden mode
VirtualInstrument.OpenFrontPanel()

#Call VI
print ("Calling LabVIEW VI\n")

VirtualInstrument.Call(ParameterNames,Parameters)

DataOut = VirtualInstrument.GetControlValue("DataOut")
print('Output =')
print(DataOut)
except:
VirtualInstrument = None
Application = None

# rethrow the exception to get the full trace on the console
raise

VirtualInstrument = None
Application = None

0 Kudos
Message 11 of 11
(685 Views)