NI TestStand

Showing results for 
Search instead for 
Did you mean: 

Python - obj - get multiple fields from class

Go to solution

What is the best way to get many (100) fields from a python obj into teststand.


We're comming from C#, where it's possible to generate a data-type in TestStand based on the data-type in C# (at least on C# structs).


That means if we have a C# struct with hundred of fields, TestStand can create a similar custom data type with the correct field names, by a right click.


How do I access field values in a Python object passed back into Teststand ?


we are using TestStand 2014.

Is it an advantage to use TestStand 2019 in this respect ?

0 Kudos
Message 1 of 3
Accepted by topic author NikolajEgeskovOstergaard

In Python, if you have an object (assume a python class instance) stored in a variable of type object reference, you can use python adapter to call function or get/set attributes (equivalent of properties in C#) in the class instance.


Similar to how a C# struct is mapped to a container in TestStand, tuple in Python is mapped to container. So, you can return a tuple and you can store its data in a container. Python adapter does not have the ability to detect the contents of the parameter or return value at edit time. Hence, in Python adapter, you do not get a single click option to create custom data type. You need to create the container along with its subproperties and then use it in the return value to store the contents of tuple.



Message 2 of 3

Hi  NikolajEgeskovOstergaard,

If  Shashidhar 's answer has helped please remember to mark it as a solution.


Kind Regards,
Technical Support Engineer
Platforms & Systems
National Instruments
0 Kudos
Message 3 of 3