python打开blender
Blender在前台运行时,它将占据一个窗口,可以通过其界面进行交互。这也意味着Python脚本将会等待Blender进程完成(或者直到手动关闭Blender窗口)才会继续执行下去,除非采取了额外的措施来异步运行(这通常涉及到更复杂的进程管理,可能超出了简单使用subprocess.run的范围)。运行这段代码时,Blender将会启动,显示其界面,并加载sonar3.blend文件。"-noau
·
1、后台运行:
import subprocess
blender_path = r"D:\Software_Installation\blender\blender.exe"
blend_file_path = r'D:\python_code\myCode\13_blender_simulation\sonar3.blend'
subprocess.run([blender_path, "--background", blend_file_path, "-noaudio"], check=True)
2、前台运行:
import subprocess
blender_path = r"D:\Software_Installation\blender\blender.exe"
blend_file_path = r'D:\python_code\myCode\13_blender_simulation\sonar3.blend'
# 移除"--background"参数以在前台运行Blender
subprocess.run([blender_path, blend_file_path, "-noaudio"], check=True)
运行这段代码时,Blender将会启动,显示其界面,并加载sonar3.blend文件。"-noaudio"参数使音频被禁用。
Blender在前台运行时,它将占据一个窗口,可以通过其界面进行交互。这也意味着Python脚本将会等待Blender进程完成(或者直到手动关闭Blender窗口)才会继续执行下去,除非采取了额外的措施来异步运行(这通常涉及到更复杂的进程管理,可能超出了简单使用subprocess.run的范围)。
更多推荐
所有评论(0)