Hello, I'm having an issue with Python/COM and Labview. What I want to do is to instantiate Labview an let it open and execute a "VI" (virtal instrument).
This works well in Visual Basic: ------------------------------------------------------------------------------- 'Declare the object type of a lvApp and VI Dim lvApp As LabVIEW.Application Dim VI As LabVIEW.VirtualInstrument Dim VIPath As String 'Create a reference to LabVIEW Set lvApp = CreateObject("LabVIEW.Application") 'Determine the path to the VI VIPath = lvApp.ApplicationDirectory + "\Examples\General\Strings.llb\Parse Arithmetic Expression.vi" 'Assign an object reference to VI Set VI = lvApp.GetVIReference(VIPath) Dim ParamNames(0 To 1) As String Dim ParamVals(0 To 1) As Variant ParamNames(0) = "Arithmetic Expression" ParamNames(1) = "Result" ParamVals(0) = "3*77" VI.ShowFPOnCall = True 'Call the VI Call VI.Call(ParamNames, ParamVals) MsgBox ParamVals(1) ------------------------------------------------------------------------------- My Python equivalent is: -----------------------------LVCOM.py:--------------------------------- from win32com.client import Dispatch lvApp = Dispatch("LabVIEW.Application.8") VIPath = lvApp.ApplicationDirectory + r"\Examples\General\Strings.llb\Parse Arithmetic Expression.vi" print VIPath VI=lvApp.GetVIReference(VIPath) ParamNames = [] ParamNames.append("Arithmetic Expression") ParamNames.append("Result") ParamVals = [] ParamVals.append("3*77") ParamVals.append("0") VI.ShowFPOnCall = True VI.Call(ParamNames, ParamVals) print ParamVals[1] ---------------------------------------------------------------------------------- Here the call: VI.Call(ParamNames, ParamVals) succeeds partially. The GUI of the "virtual instrument" is opened, but the new values of the parameters are not inserted, and I get this traceback: Traceback (most recent call last): File "C:\dSPACE4.2\Common\Python22\Core\lib\site-packages\Pythonwin\pywin\framework\scriptutils.py", line 301, in RunScript exec codeObject in __main__.__dict__ File "C:\user\nenad\LabviewPyCOM\LVCOM.py", line 20, in ? VI.Call(ParamNames, ParamVals) TypeError: 'NoneType' object is not callable As far as I understand, the problem is related to how Labview accepts the arguments of the call. ParamNames is an array of string references, ParamVals is an array of references to variants. In VB the values in ParamVals are used both to transfer the values of the parameters, and to receive the results. I realise this is not handeled this way in PythonCOM - as stated in the Paragraf "Passing and Obtaining Python Objects from COM", chapter 12 of "Python programming on Win32" - so I frankly don't have a clue if what I'm trying to do is possible at all. Also, please note that the type of the object VI is not known to Python: >>> VI <COMObject <unknown>> because it was returned by a factory method, I guess. I'd be gratefull for any helpfull sugestion. Sincerelly, Nenad Propadovic ------------------------------------------------- debitel.net Webmail _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32