Visual Studio Code and VNA Tools

84 views
Skip to first unread message

Michael Wollensack METAS

unread,
Dec 22, 2022, 7:40:50 AM12/22/22
to VNA Tools
I would like to run/debug a script from VS Code and not from the built-in script engine of VNA Tools.

Michael Wollensack METAS

unread,
Dec 22, 2022, 8:04:22 AM12/22/22
to VNA Tools
1. You need Visual Studio code, see https://code.visualstudio.com/
2. You need CPython, see https://www.python.org/
3. You need Pythonnet, see https://pypi.org/project/pythonnet/
4. You need the Python extension for VS Code, see https://code.visualstudio.com/docs/languages/python
5. Now you can load your existing python script and add the following lines:

RootPath = r'C:\Users\Public\Documents\Metas.Vna.Tools\Projects\01_Basic_Example_N(f-m)'
VNAToolsPath = r'C:\Program Files (x86)\METAS\Metas.Vna.Tools'

import sys
sys.path.append(VNAToolsPath)

6. Or you create a new script form the following template:

RootPath = r'C:\Users\Public\Documents\Metas.Vna.Tools\Projects\01_Basic_Example_N(f-m)'
VNAToolsPath = r'C:\Program Files (x86)\METAS\Metas.Vna.Tools'

import sys
sys.path.append(VNAToolsPath)

import clr
clr.AddReference('System.Windows.Forms')
clr.AddReference('Metas.Vna.Tools')
from System.Threading import Thread
from System.Windows.Forms import MessageBox
from Metas.Vna.Tools import Script

s = Script(RootPath)

Be aware that VNA Tools script engine is using IronPython and the above example is using CPython with the Pythonnet package.
There are some differences between IronPython and CPython with the Pythonnet package, e.g.: object initialization in pythonnet, see https://github.com/pythonnet/pythonnet/issues/2038.

Reply all
Reply to author
Forward
0 new messages