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.caps_set(type='ROUND')

Change curve caps mode (rounded or flat)

Parameters:

type (enum in ['ROUND', 'FLAT', 'START', 'END'], (optional)) –

Type

  • ROUND Rounded – Set as default rounded.

  • FLAT Flat.

  • START Toggle Start.

  • END Toggle End.

bpy.ops.grease_pencil.clean_loose(limit=1)

Remove loose points

Parameters:

limit (int in [1, inf], (optional)) – Limit, Number of points to consider stroke as loose

bpy.ops.grease_pencil.cyclical_set(type='TOGGLE')

Close or open the selected stroke adding a segment from last to first point

Parameters:

type (enum in ['CLOSE', 'OPEN', 'TOGGLE'], (optional)) – Type

bpy.ops.grease_pencil.delete()

Delete selected strokes or points

bpy.ops.grease_pencil.delete_frame(type='ACTIVE_FRAME')

Delete Grease Pencil Frame(s)

Parameters:

type (enum in ['ACTIVE_FRAME', 'ALL_FRAMES'], (optional)) –

Type, Method used for deleting Grease Pencil frames

  • ACTIVE_FRAME Active Frame – Deletes current frame in the active layer.

  • ALL_FRAMES All Active Frames – Delete active frames for all layers.

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.duplicate()

Duplicate the selected points

bpy.ops.grease_pencil.duplicate_move(GREASE_PENCIL_OT_duplicate=None, TRANSFORM_OT_translate=None)

Make copies of the selected Grease Pencil strokes and move them

Parameters:
  • GREASE_PENCIL_OT_duplicate (GREASE_PENCIL_OT_duplicate, (optional)) – Duplicate, Duplicate the selected points

  • TRANSFORM_OT_translate (TRANSFORM_OT_translate, (optional)) – Move, Move selected items

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

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 [0, 1048574], (optional)) – Duration

bpy.ops.grease_pencil.layer_active(layer=0)

Set the active Grease Pencil layer

Parameters:

layer (int in [0, inf], (optional)) – Grease Pencil Layer

bpy.ops.grease_pencil.layer_add(new_layer_name='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_duplicate(empty_keyframes=False)

Make a copy of the active Grease Pencil layer

Parameters:

empty_keyframes (boolean, (optional)) – Empty Keyframes, Add Empty Keyframes

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

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_hide(unselected=False)

Hide selected/unselected Grease Pencil layers

Parameters:

unselected (boolean, (optional)) – Unselected, Hide unselected rather than selected layers

bpy.ops.grease_pencil.layer_isolate(affect_visibility=False)

Make only active layer visible/editable

Parameters:

affect_visibility (boolean, (optional)) – Affect Visibility, Also affect the visibility

bpy.ops.grease_pencil.layer_lock_all(lock=True)

Lock all Grease Pencil layers to prevent them from being accidentally modified

Parameters:

lock (boolean, (optional)) – Lock Value, Lock/Unlock all layers

bpy.ops.grease_pencil.layer_remove()

Remove the active Grease Pencil layer

bpy.ops.grease_pencil.layer_reorder(target_layer_name='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.layer_reveal()

Show all Grease Pencil layers

bpy.ops.grease_pencil.material_copy_to_object(only_active=True)

Append Materials of the active Grease Pencil to other object

Parameters:

only_active (boolean, (optional)) – Only Active, Append only active material, uncheck to append all materials

bpy.ops.grease_pencil.material_hide(invert=False)

Hide active/inactive Grease Pencil material(s)

Parameters:

invert (boolean, (optional)) – Invert, Hide inactive materials instead of the active one

bpy.ops.grease_pencil.material_lock_all()

Lock all Grease Pencil materials to prevent them from being accidentally modified

bpy.ops.grease_pencil.material_lock_unselected()

Lock any material not used in any selected stroke

bpy.ops.grease_pencil.material_lock_unused()

Lock and hide any material not used

bpy.ops.grease_pencil.material_reveal()

Unhide all hidden Grease Pencil materials

bpy.ops.grease_pencil.material_select(deselect=False)

Select/Deselect all Grease Pencil strokes using current material

Parameters:

deselect (boolean, (optional)) – Deselect, Unselect strokes

bpy.ops.grease_pencil.material_unlock_all()

Unlock all Grease Pencil materials so that they can be edited

bpy.ops.grease_pencil.move_to_layer(target_layer_name='Layer', add_new_layer=False)

Move selected strokes to another layer

Parameters:
  • target_layer_name (string, (optional, never None)) – Name, Target Grease Pencil Layer

  • add_new_layer (boolean, (optional)) – New Layer, Move selection to a new layer

bpy.ops.grease_pencil.reorder(direction='TOP')

Change the display order of the selected strokes

Parameters:

direction (enum in ['TOP', 'UP', 'DOWN', 'BOTTOM'], (optional)) – Direction

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.separate(mode='SELECTED')

Separate the selected geometry into a new grease pencil object

Parameters:

mode (enum in ['SELECTED', 'MATERIAL', 'LAYER'], (optional)) –

Mode

  • SELECTED Selection – Separate selected geometry.

  • MATERIAL By Material – Separate by material.

  • LAYER By Layer – Separate by layer.

bpy.ops.grease_pencil.set_active_material()

Set the selected stroke material as the active material

bpy.ops.grease_pencil.set_material(slot='DEFAULT')

Set active material

Parameters:

slot (enum in ['DEFAULT'], (optional)) – Material Slot

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.set_uniform_opacity(opacity=1.0)

Set all stroke points to same opacity

Parameters:

opacity (float in [0, 1], (optional)) – Opacity

bpy.ops.grease_pencil.set_uniform_thickness(thickness=0.1)

Set all stroke points to same thickness

Parameters:

thickness (float in [0, 1000], (optional)) – Thickness, Thickness

bpy.ops.grease_pencil.stroke_material_set(material='')

Assign the active material slot to the selected strokes

Parameters:

material (string, (optional, never None)) – Material, Name of the material

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

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

bpy.ops.grease_pencil.stroke_subdivide(number_cuts=1, only_selected=True)

Subdivide between continuous selected points of the stroke adding a point half way between them

Parameters:
  • number_cuts (int in [1, 32], (optional)) – Number of Cuts

  • only_selected (boolean, (optional)) – Selected Points, Smooth only selected points in the stroke

bpy.ops.grease_pencil.stroke_subdivide_smooth(GREASE_PENCIL_OT_stroke_subdivide=None, GREASE_PENCIL_OT_stroke_smooth=None)

Subdivide strokes and smooth them

Parameters:
  • GREASE_PENCIL_OT_stroke_subdivide (GREASE_PENCIL_OT_stroke_subdivide, (optional)) – Subdivide Stroke, Subdivide between continuous selected points of the stroke adding a point half way between them

  • GREASE_PENCIL_OT_stroke_smooth (GREASE_PENCIL_OT_stroke_smooth, (optional)) – Smooth Stroke, Smooth selected strokes

bpy.ops.grease_pencil.stroke_switch_direction()

Change direction of the points of the selected strokes