我知道我可以用File/Defaults/Save Startup File更改默认的启动文件。我不想更改默认的启动文件,而是从命令行使用自定义的.blend启动文件调用blender,如下所示:
blender --startup-file my_file.blend我不想做blender my_file.blend,因为这样我可能会意外地保存文件并覆盖my_file.blend,它应该是一个模板,而不是一个可编辑的文件。如果我尝试保存,我希望得到选择文件名的提示。我如何从命令行完成这项任务?
发布于 2021-01-08 20:00:22
https://docs.blender.org/api/current/bpy.ops.wm.html#bpy.ops.wm.read_homefile
blender --python-expr "import bpy; bpy.ops.wm.read_homefile(filepath=r'my_file.blend')"或者作为脚本:
import bpy
import subprocess
path = r"D:\Desktop\test.blend"
script = "\n".join([
"import bpy",
f"bpy.ops.wm.read_homefile(filepath=r\"{path}\")"
])
subprocess.Popen([bpy.app.binary_path, "--python-expr", script])发布于 2020-03-17 16:51:03
跑
blender "my_file.blend" --python "my_script.py"并将此代码放入my_script.py
import bpy
bpy.ops.wm.save_as_mainfile(filepath="my_new_file.blend", compress=False)https://docs.blender.org/manual/en/latest/advanced/command_line/arguments.html#python-options https://docs.blender.org/api/current/bpy.ops.wm.html#bpy.ops.wm.save_as_mainfile
https://stackoverflow.com/questions/60617582
复制相似问题