Grease Pencil Operators

bpy.ops.grease_pencil.brush_stroke(stroke=None, mode='NORMAL')

Draw a new stroke in the active Grease Pencil object

Parameters:
  • stroke (bpy_prop_collection of OperatorStrokeElement, (optional)) – Stroke

  • mode (enum in ['NORMAL', 'INVERT', 'SMOOTH'], (optional)) –

    Stroke Mode, Action taken when a paint stroke is made

    • NORMAL Regular – Apply brush normally.

    • INVERT Invert – Invert action of brush for duration of stroke.

    • SMOOTH Smooth – Switch brush to smooth mode for duration of stroke.

bpy.ops.grease_pencil.dissolve(type='POINTS')

Delete selected points without splitting strokes

Parameters:

type (enum in ['POINTS', 'BETWEEN', 'UNSELECT'], (optional)) –

Type, Method used for dissolving stroke points

  • POINTS Dissolve – Dissolve selected points.

  • BETWEEN Dissolve Between – Dissolve points between selected points.

  • UNSELECT Dissolve Unselect – Dissolve all unselected points.

bpy.ops.grease_pencil.draw_mode_toggle()

Enter/Exit draw mode for grease pencil

bpy.ops.grease_pencil.insert_blank_frame(all_layers=False, duration=1)

Insert a blank frame on the current scene frame

Parameters:
  • all_layers (boolean, (optional)) – All Layers, Insert a blank frame in all editable layers

  • duration (int in [1, 1048574], (optional)) – Duration

bpy.ops.grease_pencil.layer_add(new_layer_name='GP_Layer')

Add a new Grease Pencil layer in the active object

Parameters:

new_layer_name (string, (optional, never None)) – Name, Name of the new layer

bpy.ops.grease_pencil.layer_group_add(new_layer_group_name='GP_Group')

Add a new Grease Pencil layer group in the active object

Parameters:

new_layer_group_name (string, (optional, never None)) – Name, Name of the new layer group

bpy.ops.grease_pencil.layer_remove()

Remove the active Grease Pencil layer

bpy.ops.grease_pencil.layer_reorder(target_layer_name='GP_Layer', location='ABOVE')

Reorder the active Grease Pencil layer

Parameters:
  • target_layer_name (string, (optional, never None)) – Target Name, Name of the target layer

  • location (enum in ['ABOVE', 'BELOW'], (optional)) – Location

bpy.ops.grease_pencil.select_all(action='TOGGLE')

(De)select all visible strokes

Parameters:

action (enum in ['TOGGLE', 'SELECT', 'DESELECT', 'INVERT'], (optional)) –

Action, Selection action to execute

  • TOGGLE Toggle – Toggle selection for all elements.

  • SELECT Select – Select all elements.

  • DESELECT Deselect – Deselect all elements.

  • INVERT Invert – Invert selection of all elements.

bpy.ops.grease_pencil.select_alternate(deselect_ends=False)

Select alternated points in strokes with already selected points

Parameters:

deselect_ends (boolean, (optional)) – Deselect Ends, (De)select the first and last point of each stroke

bpy.ops.grease_pencil.select_ends(amount_start=0, amount_end=1)

Select end points of strokes

Parameters:
  • amount_start (int in [0, inf], (optional)) – Amount Start, Number of points to select from the start

  • amount_end (int in [0, inf], (optional)) – Amount End, Number of points to select from the end

bpy.ops.grease_pencil.select_less()

Shrink the selection by one point

bpy.ops.grease_pencil.select_linked()

Select all points in curves with any point selection

bpy.ops.grease_pencil.select_more()

Grow the selection by one point

bpy.ops.grease_pencil.select_random(ratio=0.5, seed=0, action='SELECT')

Selects random points from the current strokes selection

Parameters:
  • ratio (float in [0, 1], (optional)) – Ratio, Portion of items to select randomly

  • seed (int in [0, inf], (optional)) – Random Seed, Seed for the random number generator

  • action (enum in ['SELECT', 'DESELECT'], (optional)) –

    Action, Selection action to execute

    • SELECT Select – Select all elements.

    • DESELECT Deselect – Deselect all elements.

bpy.ops.grease_pencil.set_selection_mode(mode='POINT')

Change the selection mode for Grease Pencil strokes

Parameters:

mode (enum in Grease Pencil Selectmode Items, (optional)) – Mode

bpy.ops.grease_pencil.stroke_simplify(factor=0.001)

Simplify selected strokes

Parameters:

factor (float in [0, 100], (optional)) – Factor

bpy.ops.grease_pencil.stroke_smooth(iterations=10, factor=1.0, smooth_ends=False, keep_shape=False, smooth_position=True, smooth_radius=True, smooth_opacity=False)

Smooth selected strokes

Parameters:
  • iterations (int in [1, 100], (optional)) – Iterations

  • factor (float in [0, 1], (optional)) – Factor

  • smooth_ends (boolean, (optional)) – Smooth Endpoints

  • keep_shape (boolean, (optional)) – Keep Shape

  • smooth_position (boolean, (optional)) – Position

  • smooth_radius (boolean, (optional)) – Radius

  • smooth_opacity (boolean, (optional)) – Opacity