我正在打开Rhino并在外部python脚本中使用subprocess.call()
运行Rhino命令行。
rhinoPath = "C:\\Program Files (x86)\\Rhinoceros 5\\System\\Rhino4.exe"
rhinoCommandFilePath = "Z:\\Arkangus\\2019\\RhinoCommand.txt"
scriptCall = "_-ReadCommandFile {0}".format(rhinoCommandFilePath)
callScript = '"{0}" /nosplash /runscript="{1}" /runscript="_-Exit"'.format(rhinoPath, scriptCall)
subprocess.call(callScript)
但是,它意味着每次我运行脚本时打开Rhino,然后关闭它。
有没有办法检查Rhino是否已经打开并且如果是这样的话,直接将RhinoCommand文件运行到Rhino中?
我不是在寻找Rhino和Python之间的管道。
谢谢!
检查Rhino是否已经打开(注意:这只是我问题的部分答案):
Checking if program is running programatically
import psutil
def is_rhino_open():
for pid in psutil.pids():
p = psutil.Process(pid)
if p.name() == "Rhino5.exe":
print ("Rhino5 is running!")
其他方法:使用CPython3.x模块rhino3dm
和compute_rhino3d
直接在Python中使用Rhino的计算函数(无需打开Rhino)。