How to open Workbench ACT and launch a wizard by script

charlie.wang
charlie.wang Member, Employee Posts: 2
Ansys Employee First Comment

Is there any way to launch a ACT wizard by script?

Tagged:

Best Answers

  • Aria
    Aria Member, Employee Posts: 64
    First Anniversary Ansys Employee First Answer Name Dropper
    edited March 2023 Answer ✓

    Your wizard is ultimately a callback to a python function. You can call that python function within your extension with your inputs.

    Lets assume you run your script in a bat file like following

    "%AWP_ROOT231%\Framework\bin\win64\RunWB2.exe" -B -R my_script.py
    

    then, my_script would activate the extension and run the python callback


    appAPI = Ansys.ACT.Core.ApplicationRepository.GetApplication("Project")
    ExtAPI = appAPI.GetExtensionApi(None)
    
    myACTName = "SomeACTextension"
    extension = [x for x in ExtAPI.ExtensionManager.Extensions if x.Name == myACTName]
    
    if len(extension) == 1:
        appFormat = "Scripted" # or = "Binary"
        GUID = "some-GUID-value"
        Extensions.LoadExtension(Id=GUID, Format=appFormat)
        ext=ExtAPI.ExtensionManager.GetExtensionByName(myACTName).GetModule()
        ext.SomeWizardCallback(arg1, arg2, arg3...)
    
    


  • charlie.wang
    charlie.wang Member, Employee Posts: 2
    Ansys Employee First Comment
    Answer ✓

    Thank you. It works now!

Answers

  • Pernelle Marone-Hitz
    Pernelle Marone-Hitz Member, Moderator, Employee Posts: 715
    First Comment First Anniversary Ansys Employee Solution Developer Community of Practice Member

    Hi @charlie.<?WORD FLAGGED?> . Wizards are designed to be interactive (they are made to guide non-expert users through a workflow). There is very little that can be done to run a Wizard through a script.

    The following commands will imitate clicking on the "Next Button" in a Wizard. Opening the wizard still has to be done manually. Also, please note that the following commands are unsupported (no documentation, no support, and no guarantee that it will work).

    import System
    import time
    
    
    def runWizard(analysis):
        '''
        Open Wizard in another thread
        '''
        System.Threading.Thread(System.Threading.ThreadStart(runActionsWizard)).Start()
    
    
    def runActionsWizard():
        '''
        Run actions for Wizard
        '''
        ExtAPI.UserInterface.UIRenderer.GetContainer("Wizard").CurrentPanel.GetComponent("WizardDefinitionComponent_Wizard;Wizard_Name;GUI;Wizard_Name;xml;1;0").TriggerClick()
        ExtAPI.UserInterface.UIRenderer.GetContainer("Wizard").CurrentPanel.GetComponent("Submit").TriggerClick("submit")