22. Scripting

Release 2026 R1 includes the following enhancements to scripting in the Mechanical application:

  • CPython Support. The Mechanical scripting function now supports CPython (Python 3.x) in addition to IronPython (Python 2.x). You can select either CPython or IronPython as the Python engine in the Mechanical Scripting Window, the Button Editor, Python Code objects, and Python Results objects. In addition, you can specify the Python engine for Mechanical ACT extensions and for running a script when you launch the Mechanical application from the command line.

    You can set the default Python engine via File > Options > UI Options > Scripting. This applies to new scripts, buttons, and Python objects, plus scripts that you run from external files via Run Macro. For backwards compatibility with existing scripts, the Python engine defaults to IronPython.

    For more information about using CPython in Mechanical scripts, see the Scripting in Mechanical Guide. For a discussion of the differences between IronPython and CPython, see Migrating from IronPython to CPython.