360 Secure SkillHub
360 安全技能中心

Blender Bpy

提供以 Blender 命令行后台方式运行 Python 脚本的做法,使用 bpy API 完成场景自动化、程序化建模、对象操作与批量渲染,并给出创建对象、按名称指定材质、批量渲染动画帧的代码片段和后台运行提示。

flayzz
flayzz
热度 89.44
最近更新 2026-05-11 17:32:01
分类:创作依赖:代码执行 / 读写文件应用场景:自动化脚本 / 代码生成 / 图像生成

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add blender-bpy
Metadata
name
blender_bpy
description
Blender Python scripting via bpy API. Use for scene automation, procedural modeling, batch rendering, and object manipulation.
metadata
{"openclaw":{"requires":{"bins":["blender"]},"user-invocable":true}}

Blender Python Automation (bpy)

Prerequisites

  • Blender must be installed and accessible from the CLI (blender --version).
  • Scripts run via: blender --background --python <script.py>
  • For interactive use: connect via Blender's built-in Python console or the REST server addon.

Common Snippets

Create an object

import bpy
bpy.ops.mesh.primitive_cube_add(location=(0, 0, 0))
obj = bpy.context.object
obj.name = "MyCube"

Batch render all frames

import bpy
scene = bpy.context.scene
scene.render.filepath = "//renders/frame_"
bpy.ops.render.render(animation=True)

Apply a material by name

import bpy
mat = bpy.data.materials.get("MyMaterial")
if mat is None:
    mat = bpy.data.materials.new(name="MyMaterial")
obj = bpy.context.object
if obj.data.materials:
    obj.data.materials[0] = mat
else:
    obj.data.materials.append(mat)

Tips

  • Always use --background when running headless (no UI).
  • Use bpy.data (global access) vs bpy.context (active selection) correctly.
  • For long renders, consider Cron jobs in OpenClaw so main chat isn't blocked.