subprocess.Popen not present in autocompletion list, but is available

I’m writing a command that will open a selected linked block in Rhino in a subprocess without waiting for it to close (without blocking the active Rhino document). I’ve tried and subprocess.check_call, but both were waiting for the subprocess to exit. I thought that subprocess.Popen is unavailable, because it didn’t show on the autocompletion list (image below), but out of desperation I’ve tried it and it seems to work - opens subprocess without waiting.

I wanted to check if it’s an issue with IntelliClunk in Rhino’s PythonEditor and it wasn’t intentionally filtered out of this list (perhaps due to some issue with IronPython’s implementation of Popen)?

I’m aware of RhinoCode, but I just didn’t have time to give it a try yet (but if the former is true I may do that soon).


import rhinoscriptsyntax as rs
import subprocess

def OpenBlockWithRhino8WIP():
    block_ids = rs.GetObjects(filter=4096, preselect=True)
    if block_ids:
        for block_id in block_ids:
            block_name = rs.BlockInstanceName(block_id)
            block_path = rs.BlockPath(block_name)
            subprocess.Popen(["C:\\Program Files\\Rhino 8 WIP\\System\\Rhino.exe", block_path], close_fds=True)


Just FYI in RhinoCode


1 Like

Thanks, that’s good to know.

One unfortunate side effect of using Popen from RunPythonScript in Rhino is that it locks the parent process from saving to the file - it somehow locks it (even after exiting the child process).

os.startfile seems to work, but os.system("C:\\Program Files\\Rhino 8 WIP\\System\\Rhino.exe" + block_path) did nothing.

EDIT: adding close_fds=True argument made it work - process starts without locking Rhino’s parent process save file. I’ve added it to the snippet above.

I haven’t tried it, but either passing raw string (e.g. r’C:..‘) or quoting the entire string twice (’“C:..”’ might have worked for os.system call.