hexagon logo

I am trying create .bat file to run .acf within gui dialogue box, but facing the issue in writing bat file.

simulation set solver_preference = write_files_only
simulation set save_files = yes
simulation set file_prefix = (eval("$f_prefix"))
simulation single scripted &
sim_script_name = $f_script_name
 
language switch_to python
import Adams
with open('$f_prefix.bat', 'w') as file:
pass
import Adams
import glob
import subprocess
 
bat_file = $f_prefix.bat
 
bat_content = """
@echo off
SET MDI_ADAMS_RETRY=10
title bat_test
call C:/Progra~1/MSC.Software/Adams/2023_4/common/mdi.bat ru-s $f_prefix.acf
"""
with open(bat_file, 'w') as f:
f.write(bat_content.strip())
   
Parents
  • Hello Thoms,
     
    \\n also not working
     
    I tried as below, instead of creating bat I tried to execute acf file from directory from gui dialog box itself, but only issue i faced that although command is able to execute acf file in the directory but I cannot get Adams view session until run gets finished. Can there be any other way.
     
     
    simulation set hold = no
    simulation set solver_preference = write_files_only
    simulation set save_files = yes
    simulation set file_prefix = (eval("$f_prefix"))
    simulation single scripted &
    sim_script_name = $f_script_name
     
    language switch_to python
    import subprocess
    subprocess.run(["cmd", "/c", "$f_prefix.acf"])
Reply
  • Hello Thoms,
     
    \\n also not working
     
    I tried as below, instead of creating bat I tried to execute acf file from directory from gui dialog box itself, but only issue i faced that although command is able to execute acf file in the directory but I cannot get Adams view session until run gets finished. Can there be any other way.
     
     
    simulation set hold = no
    simulation set solver_preference = write_files_only
    simulation set save_files = yes
    simulation set file_prefix = (eval("$f_prefix"))
    simulation single scripted &
    sim_script_name = $f_script_name
     
    language switch_to python
    import subprocess
    subprocess.run(["cmd", "/c", "$f_prefix.acf"])
Children
No Data