x

ADONIS:
Version 3.90.14 (Released at 02/27/2026)
- Bug in assign property dialog is fixed.

HYRCAN:
Version 3.0.6 (Released at 06/11/2026)
- The bug affecting the search for circular failure surfaces has been resolved.


Start ADONIS script using cmd using e.g. Python(Read 35606 times)
Start ADONIS script using cmd using e.g. Python on: March 29, 2017, 09:41:33 pm
Dear team of developers,
is it possible to start an ADONIS script from "outside" using e.g. cmd from Python? Is it possible to have a format like in word for executing a script like ADONIS.exe <filepath_ADONIS-Sheet-Pile.ajs>?
This would help a lot to employ ADONIS in the other frameworks like e.g. Python to perform inverse analysis, data assimiliation,... etc.
Thanks for your help!

Regards,
Max



Re: Start ADONIS script using cmd using e.g. Python Reply #1 on: March 29, 2017, 09:43:44 pm
it's good idea but unfortunately currently this capability is not available. thanks for the comment.



Re: Start ADONIS script using cmd using e.g. Python Reply #2 on: May 18, 2026, 12:04:54 am
@Max: this is working for me

Code: (python) [Select]
import time
import subprocess
from pywinauto import Application
from pywinauto.timings import wait_until_passes
from pywinauto.keyboard import send_keys

ADONIS_PATH = r"C:\Program Files (x86)\Geowizard\ADONIS\exe32\ADONIS.exe"
SCRIPT_FILE = r"pile_sheet.ajs"   # <-- your script file

# ---------------------------------------------------------
# 1. Start application
# ---------------------------------------------------------
proc = subprocess.Popen([ADONIS_PATH])

# Connect to the app
app = Application(backend="uia").connect(process=proc.pid)

# Wait for main window
main = app.top_window()
main.wait("visible enabled ready", timeout=2)

print("Application started")

# ---------------------------------------------------------
# 2. Open File -> Load Script
# ---------------------------------------------------------
send_keys("%F")      # Alt+F
send_keys("{DOWN 6}")
send_keys("{ENTER}")
# main.menu_select("File->Load Script")

print("Load Script dialog opened")

# ---------------------------------------------------------
# 3. Enter filename into field
# ---------------------------------------------------------
# Wait for dialog to appear
dlg = app.top_window()
dlg.wait("visible enabled ready", timeout=1)

# Try common filename field names
try:
    # dlg.Edit.set_edit_text(SCRIPT_FILE)
    send_keys(SCRIPT_FILE, with_spaces=True)
    send_keys("%F")      # Alt+F
except Exception:
    proc.kill()
    print("Application killed")

print("Filename entered")

# ---------------------------------------------------------
# 5. Wait for application to finish
# ---------------------------------------------------------
# Wait until CPU usage becomes low
# (good for long processing operations)

app.wait_cpu_usage_lower(threshold=5, timeout=600)

print("Processing finished")

# Optional additional wait
time.sleep(1)

# ---------------------------------------------------------
# 6. Quit application
# ---------------------------------------------------------
main = app.top_window()

try:
    main.menu_select("File->Exit")
    send_keys("{ENTER 2}")
    # Quitting currently not correctly working
except Exception:
    proc.kill()
    print("Application killed")

print("Application closed")