It is possible to write your own helper functions and they will be available in Mechanical ACT console.
Note: Just an internal trick, not supported.
$AWP_ROOT202/Addins/ACT/libraries/Mechanical contains Python Modules which are loaded by default in Mechanical session. If you create a Python file for example helper.py in this folder, all functions within this file can be directly used in ACT Mechanical Console.
helper.py
Eg. Content of helper.py:
def get_attributes(attribute_string, object): return filter(lambda x: (attribute_string.upper() in x.upper()), dir(object))
Usage in Mechanical ACT console:
import helper helper.get_attributes("Unit", analysis)
Adding a few screenshots to illustrate:
Module is then loaded in Mechanical:
And function can be called:
Ayush, don’t snippets help here? When you save a script as a snippet, it will appear as a choice in the console.