Calling VB and Other Scripts From Python Script in NI DIAdem

Updated Jun 20, 2023

Environment

Software

  • DIAdem

Programming Language

  • Python
  • Visual Basic

In NI DIAdem it is possible to run Python and VB scripts. In order to achieve higher productivity, it is possible to call other scripts from your main script. 
This article shows how to Call a Python script from VB script and Python script from another Python script. 

Steps to Implement or Execute Code

A. Calling a Python script from VB script.
We should have two script files.

In VB we should have:

ScriptStart("C:\\...\\testPy.PY")

In Python script named testPy.PY:

dd.print("testVar")
 

B. Calling a Python script from Python script:

PY 1: Filename printhellodef.PY

def PrintHello():

  print("Hello")

PY 2- the caller: Filename callprinthello.PY

import printhellodef
importlib.reload(printhellodef)
printhellodef.PrintHello()