Creating the IronPython Script

The IronPython script defines functions that respond to user and GUI interactions and implements the behavior of the extensions. Typically, functions are invoked through the different events or callbacks in the XML extension definition file.

In the extension ExtSample1, the IronPython script is named sample1.py. The contents of this script follow:

clr.AddReference("Ans.UI.Toolkit")
clr.AddReference("Ans.UI.Toolkit.Base")
from Ansys.UI.Toolkit import *

def init(context):
    ExtAPI.Log.WriteMessage("Init ExtSample1...")

def HighFiveOut(analysis_obj):
    MessageBox.Show("High five! ExtSample1 is a success!")

The script contains two functions:

For any function, the global variable ExtAPI represents the main entry point for all the services provided by ACT. As an example, the function init() uses the ACT interface ILog to write one message in the log file. For more information on the available interfaces, see the ANSYS ACT API Reference Guide.


Release 18.2 - © ANSYS, Inc. All rights reserved.