Command Palette

Search for a command to run...

Назад к скиллам
скилл № 42369

blender-grease-pencil

Create 2D art and animation in Blender using Grease Pencil and Python. Use when the user wants to draw strokes programmatically, create 2D animations, build…

БесплатноБез исполняемых скриптов
TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Установить blender-grease-pencil в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Об этом скилле

Blender Grease Pencil

Overview

Create 2D drawings and animations in Blender's 3D space using Grease Pencil and Python. Build strokes from point data, manage layers and frames, apply Grease Pencil modifiers, and animate 2D content, all scriptable from the terminal.

This skill targets the Grease Pencil v3 API (Blender 5.x, checked against the 5.2 Python API reference). The old v2 API (gpencil_add, layer.info, stroke.points.add(), grease_pencil_modifiers, GP_THICK) no longer exists; scripts written for Blender 2.8-4.2 must be ported. In Blender 4.3-4.5 the v3 data-blocks lived in bpy.data.grease_pencils_v3; from 5.0 bpy.data.grease_pencils is v3.

Data model: a GreasePencil data-block has layers (and layer groups); a layer has frames keyed by frame number; each frame points to a drawing; a drawing holds strokes stored as curve and point attributes (position, radius, opacity, material_index, cyclic).

Instructions

1. Create a Grease Pencil object

import bpy

gp_data = bpy.data.grease_pencils.new("MyDrawing")
gp_obj = bpy.data.objects.new("MyDrawing", gp_data)   # obj.type == 'GREASEPENCIL'
bpy.context.collection.objects.link(gp_obj)

# Or use the operator
bpy.ops.object.grease_pencil_add(type='EMPTY')   # EMPTY, STROKE, MONKEY, LINEART_SCENE, LINEART_OBJECT, LINEART_COLLECTION
gp_obj = bpy.context.active_object

Prefer the data-level route in scripts: it works in --background mode and gives you an object with no pre-made layers or frames to trip over.

2. Add layers and frames

gp_data = gp_obj.data

layer = gp_data.layers.new("Outlines", set_active=True)   # the name is layer.name
layer.blend_mode = 'REGULAR'   # REGULAR, HARDLIGHT, ADD, SUBTRACT, MULTIPLY, DIVIDE
layer.opacity = 1.0
layer.use_lights = False

frame = layer.frames.new(1)    # raises if frame 1 already exists on this layer
drawing = frame.drawing        # the container for strokes

# Copy, move, or remove keyframes
layer.frames.copy(1, 12)
layer.frames.move(12, 13)
layer.frames.remove(13)

Layers can be grouped: gp_data.layer_groups and gp_data.layers.new(name, layer_group=group).

3. Draw strokes programmatically

Strokes are added with drawing.add_strokes(sizes) (one point count per stroke) and then filled through attributes. The Blender docs recommend the attributes API over drawing.strokes[n] for anything beyond small scripts, and warn that stroke slices become invalid after the point or curve count changes.

def add_stroke(drawing, points, radius=0.02, material_index=0, cyclic=False):
    attrs = drawing.attributes
    first_curve = attrs.domain_size('CURVE')
    first_point = attrs.domain_size('POINT')
    drawing.add_strokes([len(points)])

    pos = attrs["position"].data
    rad = (attrs.get("radius") or attrs.new("radius", 'FLOAT', 'POINT')).data   # absent until first set
    for i, co in enumerate(points):
        pos[first_point + i].vector = co
        rad[first_point + i].value = radius      # radius, not width: line width is about 2 * radius

    for name, kind, value in (("material_index", 'INT', material_index),
                              ("cyclic", 'BOOLEAN', cyclic)):
        attr = attrs.get(name) or attrs.new(name, kind, 'CURVE')   # created on demand
        attr.data[first_curve].value = value
    drawing.tag_positions_changed()

add_stroke(drawing, [(0, 0, 0), (1, 0.5, 0), (2, 1, 0), (3, 0.5, 0), (4, 0, 0)])

Radius is in scene units (default 0.01 is thin); use 0.02-0.05 for visible lines at normal camera distances. Points also carry opacity (0-1).

4. Create Grease Pencil materials

mat_solid = bpy.data.materials.new("GP_Solid")
bpy.data.materials.create_gpencil_data(mat_solid)
style = mat_solid.grease_pencil
style.color = (0.1, 0.1, 0.1, 1.0)          # stroke color
style.fill_color = (0.8, 0.2, 0.2, 1.0)     # fill color
style.show_stroke = True
style.show_fill = True
gp_obj.data.materials.append(mat_solid)     # slot index = stroke material_index

5. Apply Grease Pencil modifiers

Grease Pencil modifiers are ordinary object modifiers in v3: use obj.modifiers with GREASE_PENCIL_* types.

thick = gp_obj.modifiers.new("Thickness", 'GREASE_PENCIL_THICKNESS')
thick.thickness_factor = 1.5                 # use_uniform_thickness + thickness for a fixed value

smooth = gp_obj.modifiers.new("Smooth", 'GREASE_PENCIL_SMOOTH')
smooth.factor = 0.5
smooth.step = 3

tint = gp_obj.modifiers.new("Tint", 'GREASE_PENCIL_TINT')
tint.color = (0.2, 0.5, 1.0)
tint.factor = 0.3

noise = gp_obj.modifiers.new("Noise", 'GREASE_PENCIL_NOISE')   # hand-drawn wobble
noise.factor = 0.5

subdiv = gp_obj.modifiers.new("Subdivide", 'GREASE_PENCIL_SUBDIV')
subdiv.level = 2

build = gp_obj.modifiers.new("Build", 'GREASE_PENCIL_BUILD')   # animated reveal
build.mode = 'SEQUENTIAL'      # SEQUENTIAL, CONCURRENT, ADDITIVE
build.time_mode = 'FRAMES'     # FRAMES, DRAWSPEED, PERCENTAGE
build.length = 50
Полный SKILL.md на GitHub

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

  • _scores.json

FAQ

Что делает скилл blender-grease-pencil?

Create 2D art and animation in Blender using Grease Pencil and Python. Use when the user wants to draw strokes programmatically, create 2D animations, build Grease Pencil objects from code, manage GP layers and frames, apply GP modifiers, set up drawing guides, or script any Grease Pencil workflow in Blender.

Как установить скилл blender-grease-pencil?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл blender-grease-pencil запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить blender-grease-pencil с