🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

Launching tcl scripts with arguments from python

User: "Alaam"
Altair Community Member

I am coding an automation process using python as a main script. I would like to call up a .tcl script from python. I know I can use hw.evalTcl() to launch tcl scripts, but I need to give my tcl script input arguments, so I am running it using

subprocess.run( [tclshell_exe, my_tcl_script.tcl, py_arg1, py_arg2], capture_output=True, text=True )

tclshell_exe points to the tclsh85.exe located in the Altair Hyperworks directory.

Standard tcl commands such as "puts" work fine, while HM sepcific functions return errors. Note that no command output is shown in the Hypermesh Tcl command window.

Is using subprocess the optimal way for the tcl script call up?

I imagine a workaround would be to start with a .tcl script as the main script, where I call up python scripts and other tcl scripts, avoiding the argument assignment issue. The idea is to eventually have the whole script in python, and currently some tcl commands are not optimal to run in python.

Find more posts tagged with