Operator Inventory¶
v2.0 (Blender 5.x / Grease Pencil 3)¶
This page lists all operators provided by The Violence Layer Manager v2.0. It serves as technical reference for developers and advanced users. Each operator is mapped to its function and the native Blender operations it wraps.
Note
Architectural Change: v2.0 consolidates the many individually-named layer operators from v1.0
(e.g., fred.body_lines, fred.sculpt1) into a small set of parameterized operators that
accept layer_filter and material_filter string properties. This was necessary because
Grease Pencil 3 changed how layers and materials are referenced internally.
Warning
All operators require a Grease Pencil object to be selected and active. If no object is selected, the operator will report an error or fail silently.
Active Operators (v2.0)¶
Layer Switching Operators¶
Operator ID |
Undo Support |
Description |
|---|---|---|
|
|
Switch to specified line layer. Locks all other layers, sets active layer, activates Draw tool + “MY STROKE” brush, sets material via filter match, resets brush size to |
|
|
Switch to specified fill layer. Locks all other layers, sets Fill tool, opens material selection menu ( |
|
|
Switch to specified fill layer with a specific material. Same as above but sets material via filter match instead of opening the menu. Keybind TBD — ask Fred. |
|
|
Unlock both line and fill layers for sculpting. Takes two layer filters ( |
Note
All four layer-switching operators share a common pattern: iterate layers, find matching name via substring filter, lock all, unlock target, set active. The code is duplicated within each operator (the layer-finding loop runs twice in succession). This is a workaround for a timing issue in GP3’s layer activation. I believe the Blender team has been informed.
Drawing & Erasing Operators¶
Operator ID |
Undo Support |
Description |
|---|---|---|
|
None |
Switch to Paint mode, activate Draw tool, activate “MY STROKE” brush via |
|
None |
Switch to Paint mode, activate Erase tool, activate “ERASE STROKE” brush. |
|
None |
Switch to Paint mode, activate Erase tool, activate “ERASE POINT” brush. |
|
|
Select linked geometry ( |
Note
In Blender 5.2 LTS, the “Default Eraser” setting was removed (commit 8c22be8d89). The last activated
eraser brush is now used automatically. The tool’s two eraser operators work around this by explicitly
activating the desired eraser brush before switching to erase mode. Also note: the Python API for
paint.eraser_brush and paint.eraser_brush_asset_reference has been removed in 5.2.
Modal Toggle Operators¶
Operator ID |
Undo Support |
Description |
|---|---|---|
|
None |
Sets |
|
None |
Sets |
|
None |
Calls |
|
None |
Calls |
|
None |
Sets |
|
None |
Sets |
Warning
Modal toggle operators have no undo support (obviously, I guess, but as a note). Toggles are instantaneous state changes that don’t produce discrete operations to undo. However, if a toggle “hangs” due to Blender not registering press/release during a stroke, see Modal Toggles Getting “Stuck” (Auto-Merge, Draw Behind, Sculpt).
Brush & Material Operators¶
Operator ID |
Undo Support |
Description |
|---|---|---|
|
None |
Sets |
|
None |
Sets |
|
``REGISTER, UNDO`` |
Applies active material to selected strokes ( |
|
|
Joins selected strokes ( |
Viewport & Overlay Operators¶
Operator ID |
Undo Support |
Description |
|---|---|---|
|
None |
Toggles |
|
None |
Iterates screen areas, finds VIEW_3D, toggles |
Background Timer (Not an Operator)¶
ID |
Type |
Description |
|---|---|---|
|
|
Polls every 0.2 seconds (5 times/second). Checks if the active material index has changed. If so, inspects the material name: if it contains |
Note
Why this timer exists: Grease Pencil 3 removed per-material tickboxes for toggling strokes and fills on/off. In GP Blender 4.x, you could set a material to draw strokes only, fills only, or both, per material. That capability is gone — you must manually click “Stroke”, “Fill”, or “Both” at the top of the viewport every time you switch materials.
Fred’s timer restores the old workflow: materials with "LINE" in their name automatically get stroke-only mode.
All other materials get both mode. Setting fill color alpha to 0% does NOT work as a workaround — invisible fills
are still rendered and progressively slow down drawing as strokes grow longer.
Global Variables¶
Variable |
Value |
Used By |
|---|---|---|
|
|
Layer switch operators (sets |
|
|
Unused — declared but not referenced anywhere in v2.0 code. Preserved from v1.0 shadow fill operator. |
|
|
Unused — declared but not referenced. Preserved from v1.0 extra layer operator. |
|
|
Unused — declared but not referenced. Possibly intended for randomize operator (now removed). |
Deprecated / Removed Operators (v1.0 Reference)¶
These operators existed in v1.0/”Revision 5” (Blender 4.1.1) but are not present in the v2.0 code. They are documented here for reference — especially for users migrating or referencing v1.0 projects.
Removed: Individually-Named Layer Operators¶
Replaced by: fred.grease_layer_switch (lines), fred.grease_layer_fill_switch (fills),
fred.grease_layer_sculpt_switch (sculpting).
Old Operator ID |
v1.0 Function |
|---|---|
|
Switch to Body line/fill layer |
|
Switch to Head line/fill layer |
|
Switch to Eyes line/fill layer |
|
Switch to Mouth line/fill layer |
|
Switch to Extra line/fill layer |
|
Switch to Foreground line/fill layer |
|
Switch to Background line/fill layer |
|
Switch to Misc 8-10 layers |
|
Isolate body part for sculpting (Lines + Fills) |
|
Mouth Lines, Mask, Upper Teeth, Lower Teeth |
Why removed: Grease Pencil 3 changed how layers and materials are referenced. Maintaining one operator per body part required updating each individually for GP3 compatibility. The parameterized approach (one operator with filter strings) achieves the same result with far less code duplication and easier maintenance.
Removed: Effects & Noise Operators¶
Old Operator ID |
v1.0 Function |
v2.0 Replacement |
|---|---|---|
|
Select random vertices, apply small noise transform via dialog |
Noise Modifier (Modifiers → Effect → Noise). Non-destructive, keyframable. |
|
Select random vertices, apply large noise transform |
Noise Modifier with higher Strength setting. |
|
Earlier version of randomize |
Same — Noise Modifier. |
|
Dialog box for noise application with fixed ranges |
Noise Modifier provides interactive sliders in the modifier panel. |
|
Switch to Shadows layer, set brush size 70px |
|
|
Switch to Highlights layers with specific materials |
|
Why removed: The Noise/jitter functionality is now available natively through Blender’s
GP3 Noise Modifier, which is non-destructive and keyframable. The old operators used
bpy.ops.transform.translate with random values — which is a “destructive” operation - i.e., once done, it can’t be adjusted afterwards.
Removed: Utility Operators¶
Old Operator ID |
v1.0 Function |
v2.0 Replacement |
|---|---|---|
|
Toggle |
Native Overlay toggle: Overlays button → check Onion Skinning. Per-layer via eye icon. |
|
Iterate all GP objects, set |
Native: Object Data Properties → Vertex Colors → click X. Or Vertex Paint mode → Clear brush. |
|
|
Native: Edit Mode → F3 → “stroke smooth”. Or |
|
Create new GP object “ART_FOX” with one layer/material |
Removed. Use Fred’s provided scene files. |
|
|
Manual lock in Outliner. |
|
Unlock mouth/head layers |
|
|
Generate full Fox template with materials |
Removed. Use provided scene files. |
|
Various legacy material/brush/modifier toggles |
Mix of |
|
Flatten Y-axis, smooth, snap to face |
Removed. Experimental, not for production use. |
|
Set |
Manual toggle in layer properties. |
|
Loop all GP objects (placeholder) |
Removed. Never performed an actual action. |
|
Toggle |
Renamed to |
|
Toggle |
Manual toggle in Outliner. |
Technical Appendix: Native Blender Operations (v2.0)¶
This section documents the specific native Blender API calls used by the v2.0 operators. Updated for the Grease Pencil 3 API paths (Blender 5.1/5.2 LTS).
Mode Switching¶
bpy.ops.object.mode_set(mode='PAINT_GREASE_PENCIL')
bpy.ops.object.mode_set(mode='SCULPT_GREASE_PENCIL')
Blender API: mode_set
Note
GP3 API Change: The mode enums changed from PAINT_GPENCIL / SCULPT_GPENCIL (GP2?)
to PAINT_GREASE_PENCIL / SCULPT_GREASE_PENCIL (GP3). This was one of the core
breaking changes that necessitated a v2.0 of the tool.
Set Active Layer¶
gp = bpy.context.active_object.data
index = gp.layers.find(target_layer_name)
if index != -1:
bpy.ops.grease_pencil.layer_active(layer=index)
Blender API: layer_active
Note
GP3 API Change: In GP2, layers were set active via gp.layers.active = gp.layers[name].
In GP3, this is done via the grease_pencil.layer_active operator with an index parameter.
The tool searches by substring match (layer_filter in layer.name) rather than exact name
to accommodate naming variations across projects.
Set Brush Tool¶
bpy.ops.wm.tool_set_by_id(name="builtin.brush") # Draw tool (v2.0)
bpy.ops.wm.tool_set_by_id(name="builtin_brush.Draw") # Draw tool (alternate)
bpy.ops.wm.tool_set_by_id(name="builtin_brush.Fill") # Fill tool
bpy.ops.wm.tool_set_by_id(name="builtin_brush.Erase") # Erase tool
Blender API: tool_set_by_id
Note
GP3 API Change: Tool IDs changed slightly between GP2 and GP3. builtin_brush.Draw
was the GP2 draw tool ID; in some GP3 contexts builtin.brush is used instead. The v2.0
code uses builtin.brush for sculpt mode and builtin_brush.Draw for paint mode,
suggesting the correct ID depends on context. Test which works in 5.2 LTS specifically.
Activate Brush Asset¶
bpy.ops.brush.asset_activate(
asset_library_type='LOCAL',
relative_asset_identifier="Brush/MY STROKE"
)
Blender API: asset_activate
Note
GP3 API Change: In GP2, brushes were set via bpy.context.scene.tool_settings.gpencil_paint.brush = bpy.data.brushes["NAME"].
In GP3 with Blender 5.x, brushes are managed as assets and must be activated via
brush.asset_activate with a relative_asset_identifier. This is a significant change
in the brush management system.
However, some parts of the v2.0 code still use the old direct-access pattern:
bpy.data.brushes["MY STROKE"].strength = 1. This hybrid approach works because
the brush data-block still exists even when the asset system is used for activation.
Toggle Automerge¶
context.scene.tool_settings.use_gpencil_automerge_strokes = True # or False
Blender API: ToolSettings (see use_gpencil_automerge_strokes)
Note
GP3 API Change: In v1.0, this was done via bpy.ops.wm.context_set_value(data_path=..., value=...)
with string arguments. The v2.0 code accesses the property directly, which is cleaner and
avoids string-based data path lookups.
Delete All Connected¶
if bpy.ops.grease_pencil.select_linked.poll():
bpy.ops.grease_pencil.select_linked()
bpy.ops.grease_pencil.delete(mode='ALL')
Blender API: select_linked,
delete
Note
GP3 API Change: The grease_pencil namespace replaced the old gpencil namespace
for most operators. bpy.ops.gpencil.select_linked → bpy.ops.grease_pencil.select_linked.
Join & Smooth Strokes¶
bpy.ops.grease_pencil.join_selection(type='JOINSTROKES')
bpy.ops.grease_pencil.stroke_smooth(iterations=10, factor=0.5)
Blender API: join_selection,
stroke_smooth
Note
GP3 API Change: Parameters changed: repeat → iterations, factor retained.
Namespace changed from gpencil to grease_pencil.
Keyframe / Marker Jump¶
bpy.ops.screen.keyframe_jump(next=False) # or True
bpy.ops.screen.marker_jump(next=False) # or True
Blender API: keyframe_jump,
marker_jump
Note
These are standard Blender operators, unchanged between GP2 and GP3. The tool wraps them
to add undo_push() calls so timeline navigation appears in the undo stack.
Set Active Material Index¶
for i, slot in enumerate(bpy.context.active_object.material_slots):
if material_filter in slot.name:
bpy.context.active_object.active_material_index = i
break
Blender API: Object (see active_material_index)
Note
GP3 API Change: In v1.0, materials were set via bpy.ops.gpencil.material_set(slot=slot.name).
In v2.0, the code iterates material slots directly and sets active_material_index. This
avoids the material_set operator which may have changed behavior in GP3.
Toggle Viewport Compositor¶
for area in context.screen.areas:
if area.type == 'VIEW_3D':
shading = area.spaces.active.shading
if shading.use_compositor == 'ALWAYS':
shading.use_compositor = 'DISABLED'
else:
shading.use_compositor = 'ALWAYS'
break
Blender API: View3DShading (see use_compositor)
Valid values: 'DISABLED', 'CAMERA', 'ALWAYS'.
Background Timer (Material Stroke Check)¶
_my_stroke_last_index = None
def _my_stroke_check_material():
global _my_stroke_last_index
obj = bpy.context.object
if obj and obj.type == 'GREASEPENCIL':
index = obj.active_material_index
if index != _my_stroke_last_index:
_my_stroke_last_index = index
mat = obj.active_material
brush = bpy.data.brushes.get("MY STROKE")
if brush and mat:
if "LINE" in mat.name.upper():
brush.gpencil_settings.stroke_type = 'STROKE'
elif "FILLONLY" in mat.name.upper():
brush.gpencil_settings.stroke_type = 'FILL'
else:
brush.gpencil_settings.stroke_type = 'BOTH'
return 0.2
# Registration:
bpy.app.timers.register(_my_stroke_check_material)
Blender API: app.timers
Note
The return value of 0.2 is the interval in seconds until the next call (5 times/second).
The timer checks whether the active material index has changed since the last poll, avoiding
unnecessary brush updates on every tick.
GP3 context: This timer exists because Grease Pencil 3 removed per-material stroke/fill toggle controls. Without it, artists must manually click “Stroke” or “Both” at the top of the viewport every time they switch between line art and fill materials. The timer automates this based on material name conventions.
5.2 LTS note: The gpencil_settings.stroke_type property and brush.gpencil_settings
access pattern remain valid in 5.2. The new fill_id property on strokes (added in 5.2)
is a separate system — it controls which fill belongs to which stroke at the data level, while
the timer controls which mode the brush is in when drawing. They are complementary, not
conflicting.
Blender 5.2 LTS — Grease Pencil Changes (Developer Reference)¶
Blender 5.2 LTS was released July 14, 2026, with LTS support until July 2028. The following Grease Pencil changes are relevant to The Violence Tool v2.0:
Breaking Changes:
Change |
Impact on Violence Tool |
|---|---|
|
The tool’s eraser operators use |
“Default Eraser” setting removed — last activated eraser brush is now used |
The tool’s two eraser operators ( |
New Features (potential future use):
Feature |
Potential Tool Integration |
|---|---|
Delaunay fill algorithm — new default, with automatic gap detection, inverse filling, zoom independence, faster performance |
Fill workflow may behave differently. Test whether |
``fill_id`` and ``hide_stroke`` properties on strokes in the Python API ( |
|
``layer.layer_masks.add`` / ``layer.layer_masks.remove`` functions ( |
Could be used for programmatic mask layer management if the tool ever needs to create/modify masks dynamically. |
Line material placement settings (Count, Density, Radius) for Dots/Squares — generated at render time |
If the tool’s materials use Dots or Squares rendering, performance may improve significantly. No code change needed — this is automatic. |
New curve type setting in Draw Tool (Bézier, Catmull-Rom, NURBS) |
Strokes created with the tool will use this setting. If specific curve types are needed for line art, the tool may want to set this programmatically in the future. |
New “Fill Strokes” option in Line Art — generated strokes can carry fill material |
Relevant if the tool integrates with Blender’s Line Art system. Currently the tool does its own line art, so no immediate impact. |
Vertex Paint blend modes added (matching mesh vertex paint) |
If the tool ever reintroduces vertex paint operations, these new blend modes would be available. |
Quality of Life:
Change |
Notes |
|---|---|
“Move to Layer” operator shows layer groups as menus/submenus matching tree structure |
Helps with manual layer organization. The tool’s parameterized operators bypass this UI, but users managing layers manually benefit. |
|
Useful for editing workflows with the tool. |
Eraser uses last activated eraser brush (no more “Default Eraser” setting) |
Aligns with tool’s approach of explicitly setting eraser brushes per operator. |
New bundled Grease Pencil brushes + 19 new online brushes by Blender Studio artists |
Tool uses custom brushes (“MY STROKE”, “MY FILL”, “ERASE STROKE”, “ERASE POINT”) — bundled brushes are irrelevant unless the tool is adapted to use them. |
Playback Loop modes added (Infinite, Stop at End/Start, Restore Frame, Bounce) |
Useful for animators reviewing their work. Not tool-specific. |
Migration Notes for 5.2 LTS:
The tool’s
bl_infodeclares"blender": (5, 1, 2). This is compatible with 5.2 LTS since 5.2 is a superset of 5.1’s API. No changes needed for 5.2 compatibility — but the version number should be bumped to(5, 2, 0)or(2, 0)for the tool’s own version.The
brush.asset_activateAPI used by the tool was introduced in 5.0 and remains stable in 5.2.The
grease_pencilnamespace operators used by the tool (layer_active,select_linked,delete,join_selection,stroke_smooth,stroke_material_set,set_stroke_type,sculptmode_toggle,paintmode_toggle) are all present in 5.2 LTS.The
bpy.app.timersAPI used by the material-check timer is unchanged in 5.2.Asset files must be re-saved when upgrading from 5.1 to 5.2 (same as the 5.0→5.1 migration). Practice files and scene files may need to be opened and re-saved in 5.2 to ensure compatibility.