360 Secure SkillHub
360 安全技能中心

Blender Bpy

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

分类:创作
flayzz
flayzz
热度 48.96
最近更新 2026-05-11 17:32:01

安装

发给 Agent
帮我安装这个技能:npx secure-skills-cli add flayzz/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.