07-29-2025 04:20 PM
When Python calls a sequence I am able to pass input parameters to it, but I cannot figure out how to return sequence output parameters back to Python.
As an example, I have a MainSequence sequence in MySeq.seq that takes an input number parameter, Parameters.IN_param, increments it and saves it to the output parameter, Parameters.OUT_param. The Python snippet below successfully passes the input parameter value into the sequence, increments and saves it in Parameters.OUT_param (I verified this with a MessageBox). How do I access Parameters.OUT_param in Python after the sequence executes?
self.test_stand_engine = win32com.client.Dispatch('TestStand.Engine')
sequence_file = self.test_stand_engine.GetSequenceFileEx(r"C:\<path>\MySeq.seq")
sequence_name = "MainSequence"
property_object_params = self.test_stand_engine.NewPropertyObject(PropertyValueTypes.PropValType_Container,
False,
"",
0)
# set input parameters
property_object_params.SetValNumber("IN_param", PropertyOptions.PropOption_InsertIfMissing, 2)
execution = self.test_stand_engine.NewExecution(sequence_file,
sequence_name,
None,
False,
0,
property_object_params)
execution.WaitForEndEx(-1)
time.sleep(0.5)
execution.Terminate()
07-30-2025 01:31 AM
Does this help?
07-30-2025 02:56 PM
That example is using the TestStand Python Step type to call Python functions from within a TestStand sequence. My situation is the other way around, I am calling TestStand sequences from Python code. So I don't think the example helps me.
07-30-2025 04:39 PM
Solution: Pass all sequence Parameters into the sequence, including both inputs and outputs, using a Container PropertyObject. The sequence updates the output parameters and passes them back in the Container. Simply get the outputs from the Container after the sequence has completed. The Python code shown below produces the following output when the sequence does "Parameters.OUT_param = Parameters.IN_param + 1":
Before calling TestStand sequence:
IN_param = 2
OUT_param = 0
After calling TestStand sequence:
IN_param = 2.0
OUT_param = 3.0
import win32com.client
import time
class PropertyValueTypes:
PropValType_Container = 0
class PropertyOptions:
PropOption_InsertIfMissing = 1
class ReleaseSeqFileOptions:
UnloadFileIfModified = 4
if __name__ == '__main__':
in_param = 2
out_param = 0
print("Before calling TestStand sequence:")
print(f"IN_param = {in_param}")
print(f"OUT_param = {out_param}")
test_stand_engine = win32com.client.Dispatch('TestStand.Engine')
sequence_file = test_stand_engine.GetSequenceFileEx(r"C:\<path>\MySeq.seq") # OUT_param = IN_param + 1
sequence_name = "MainSequence"
property_object_params = test_stand_engine.NewPropertyObject(PropertyValueTypes.PropValType_Container, False, "", 0)
property_object_params.SetValNumber("IN_param", PropertyOptions.PropOption_InsertIfMissing, in_param)
property_object_params.SetValNumber("OUT_param", PropertyOptions.PropOption_InsertIfMissing, out_param)
execution = test_stand_engine.NewExecution(sequence_file,
sequence_name,
None,
False,
0,
property_object_params)
execution.WaitForEndEx(-1)
time.sleep(0.5)
execution.Terminate()
test_stand_engine.ReleaseSequenceFileEx(sequence_file, ReleaseSeqFileOptions.UnloadFileIfModified)
# Get parameters returned by the sequence
in_param = property_object_params.GetValNumber("IN_param", 0)
out_param = property_object_params.GetValNumber("OUT_param", 0)
print("After calling TestStand sequence:")
print(f"IN_param = {in_param}")
print(f"OUT_param = {out_param}")
del execution
del sequence_file
del property_object_params
del test_stand_engine