Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 4159

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

$
0
0

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 subprocess.call 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).

image

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)

OpenBlockWithRhino8WIP()

3 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 4159

Trending Articles