I have an ACT extension installed for Mechanical. I want to run an Mechanical script that will leverage some of the automation that is defined in the ACT extension. How can I do that?
You can access an ACT extension (or Mechanical Add-on) module using the GetModule method:
nvh_addon = ExtAPI.ExtensionManager.GetExtensionByName("NVHToolkit")
nvh_module = nvh_addon.GetModule()
The module allows you to access functions, variables, methods, etc. that are defined in the extension. For example:
mac_data = nvh_module.MacData()
Note that in many cases, it will be difficult to know how to use an extension's module without access to the extension's source code.
NVH Toolkit is not a great example, because most developers will not have access to its source code. @AKD-Scripting-Team , Could someone please post an example with public source code (e.g. based on an ACT extension from the ACT Start Page)
@Landon Mitchell Kanner there are lots on non-compiled python modules in the bolt tools add on.
You can import from this directory once you have added it to sys.path. The main ACT module is only a single file and most actions are in these other modules with exposed source and access via standard import commands.
There is a property for install directory on the “extension” object returned from the get extension by name method you reference. This is the directory to add to sys.path.
@Landon Mitchell Kanner , @Chemsdine CHEMAI had created this post some time ago: https://discuss.ansys.com/discussion/715/how-to-list-and-use-all-functions-of-an-extension-using-the-console But indeed it does not show the code on a specific example