Subprocess.run multiple scripts - wait for each script to finish

Hello
I have a problem executing multiple scripts with subprocess in python. I want to import dxf/xyz files, rename layers and split the objects. The 3 scripts work individually but when executed via subprocess, the script for bbox-splitting starts running before renaming the layers has finished, hence isn’t working properly. Any idea how to wait for each script to finish before starting the next one?

script_call_dxf = "_-RunPythonScript {} ".format(dxf_script_path)       
script_call_xyz = "_-RunPythonScript {} ".format(xyz_script_path)
script_call_bbox = "_-RunPythonScript {} ".format(bbox_script_path)

call_script = '"{0}" /nosplash /runscript="{1} {2} {3}", "{4}"'.format(rhino_path, script_call_xyz, script_call_dxf, script_call_bbox, rhino_file)

subprocess.run(call_script)

Just do this.

– Dale

Point is, I’d like to do this in an automated workflow, so I don’t have to click anything. But thanks anyway

Have you tried using a timer to delay the start of the next script? With enough delay inserted, the prior script should be able to finish before the next starts. You could compute the delay amount based upon the amount of data you are processing so the script would work over a wide range of data sizes.

yes but somehow the renaming of the layers won’t finish before continuing with trying to select non existent layers. maybe trim first a rename afterwards. thanks

Hi Pierre,

Why not write a single py script that calls the tree scripts one after the other. Use that single wrapper script for your subprocess call.

-Willem