How do I run an ACT extension specific command in the general WB Scripting Console?

Ayush Kumar
Ayush Kumar Member, Moderator, Employee Posts: 389
First Anniversary Ansys Employee Solution Developer Community of Practice Member First Answer
edited December 2022 in General Language Questions

How can I call any extension specific functions in the general WB scripting console?

For example, I have an extension called "FutureERA" and to call functions specific to that extension I can manually switch scoping to "FutureERA" and call the methods. Is there a way to do it without switching the scope? This is needed if one wants to call methods in WB Console from Mechanical Console using wbjn.ExecuteCommands.

enter image description here

Tagged:

Answers

  • Ayush Kumar
    Ayush Kumar Member, Moderator, Employee Posts: 389
    First Anniversary Ansys Employee Solution Developer Community of Practice Member First Answer
    Answer ✓

    You can do that by retrieving the extension in the general WB Console and use the ExecuteCommand function of the extension. For example, if you want to call an extension specific method - MyMethod in the WB console from Mechanical console you need to use ExecuteCommand on two levels:

    cmd = """
    fera = ExtAPI.ExtensionManager.GetExtensionByName('FutureERA')
    fera.ExecuteCommand('MyMethod(Arg1, Arg2)')
    """
    
    import wbjn
    wbjn.ExecuteCommand(ExtAPI, cmd)