脚本与安全
当blend文件试图运行脚本并且未被允许,标题栏将显示信息,并提供 允许执行 或者 忽略 该脚本的选项。
信息编辑器标题栏显示的自动运行警告。
下面是一些blend文件可能自动运行脚本的方式。
注册的文本块
文本数据块可以启用 注册 选项,这意味会在启动时自动加载。
Python表达式可以用于 驱动 值,并且经常在进阶的绑定和动画中使用。
还有一些情况下,blend文件需要用户交互才能运行脚本(因此禁用自动运行也会运行),但你需要清楚这种情形,因为它不是那么显而易见。
使用FreeStyle 渲染,由于 FreeStyle 使用脚本控制线条样式。
控制脚本运行
Blender提供了一些用于控制是否允许blend文件中脚本自动运行的方法。
First, the File Browser has the option Trusted Source which you can use on a case-by-case basis to control auto execution. Since you may forget to set this, or may open a file without going through the File Browser, you can change the default (described next).
自动运行Python脚本。
You may want to perform batch rendering or some other task from the command line, running Blender without an interface. In this case, the Preferences are still used but you may want to override them:
使用 or 启用
使用 or 禁用
例子
To render an animation in background mode, allowing drivers and other scripts to run:
命令行参数也可以用来正常启动Blender,并且覆盖用户设置。