build (F11) / generate code using a python script file

dkugler
2024-04-10
2024-04-11
  • dkugler - 2024-04-10

    After a project is opened and I have done some changes, I want to start the build or code generating process by a python script file. After the build is done I a Windows sound/beep should appear. Anyone has an example or hint how the .py file has to look like? Thanks!

     
  • i-campbell

    i-campbell - 2024-04-10

    hello, please enjoy.

    # i-campbell 2024
    
    import subprocess
    from scriptengine import *
    
    # with a project already open
    # save if not yet saved
    # check pool objects if it is a library
    # generate code only for the active application if it is a project
    # beep thanks to https://devblogs.microsoft.com/scripting/powertip-use-powershell-to-send-beep-to-console/
    
    if projects.primary: # check project is open
        if projects.primary.dirty: # save
            projects.primary.save()
        if projects.primary.path.lower().endswith('.library'):
            projects.primary.check_all_pool_objects() # check all pool objects for lib
        else:
            projects.primary.active_application.generate_code() # generate if not lib
            # note, there could be more applications than the active application,
            # this script does not generate those
    else:
        system.write_message(Severity.Error,'no project open')
    ps_output = subprocess.check_output(["powershell", "-Command", "[console]::beep(500,300)"]) # beep
    
     
  • dkugler - 2024-04-11

    thank you very much! I found the generate_code methode, but struggled with the primary and active_application. With this expample I will be able to play around. If the code generation takes a minute or more I often switch to other programs and don't notify the process is finished. So now I'll get an alert and will switch back immediately. My next little project will be, to beep different if there are errors and a seperate script to do the download incl. the user management data base without stopping at the dialogs asking for onlinechange/complete download and overwriting an existing database and as goody, play a beep/sound again.

     

Log in to post a comment.