Develop Python Script
The script is run in the context of the XCT Console Application, using IronPython 2.7.7.
Therefore “if __name__ == "__main__":” is not possible. If you need some kind of execution guard, you can use the name of the passed script as module name.
All command line parameter are forwarded to the script as they are. This is also true for the first one (sys.argv[0]). If the script is called directly, it just contains the script name. If it is called with a relative or absolute path sys.argv[0] contains this exact path.
Because the Script is run using IronPython it runs in a C#/.Net context, for proper Exception handling, it is recommended to import the following packages:
# import all C# exceptions that shall be handled from System import Exception
# the XCT automation API throws XCTAutomationAPIException exceptions from ETAS.XCT import XCTAutomationAPIException
Some methods of the XCT Object return C# Lists, you can use them as Python arrays (zero index).
It is also possible to include and use other C# /.Net packages. For more details, please visit the official iron Python documentation for the .net integration: https://ironpython.net/documentation/dotnet/
Some example scripts are provided in the Manuals folder of your ETK Tools installation. There are some simple basic scripts, as well as some extended ones. Every API functionality is used in at least one of those example scripts.
For more details what is included and how to use it, please visit this IronPython standard library documentation: https://ironpython-test.readthedocs.io/en/latest/library/index.html
Or the official Python documentation: https://docs.python.org/2.7/library/index.html
See also