user: Show practical ways to work with Grease Pencil Operators in a Blender add-on or script – include code.

assistant: # Grease Pencil Operators

bpy.ops.grease_pencil.active_frame_delete(*\**, *all=False*)
:   Delete the active Grease Pencil frame(s)

    Parameters:
    :   **all** (*boolean**,* *(**optional**)*) – Delete all, Delete active keyframes of all layers

bpy.ops.grease_pencil.bake_grease_pencil_animation(*\**, *frame_start=1*, *frame_end=250*, *step=1*, *only_selected=False*, *frame_target=1*, *project_type='KEEP'*)
:   Bake Grease Pencil object transform to Grease Pencil keyframes

    Parameters:
    :   - **frame_start** (*int in* *[**1**,* *100000**]**,* *(**optional**)*) – Start Frame, The start frame
        - **frame_end** (*int in* *[**1**,* *100000**]**,* *(**optional**)*) – End Frame, The end frame of animation
        - **step** (*int in* *[**1**,* *100**]**,* *(**optional**)*) – Step, Step between generated frames
        - **only_selected** (*boolean**,* *(**optional**)*) – Only Selected Keyframes, Convert only selected keyframes
        - **frame_target** (*int in* *[**1**,* *100000**]**,* *(**optional**)*) – Target Frame, Destination frame
        - **project_type** (enum in [`'KEEP'`, `'FRONT'`, `'SIDE'`, `'TOP'`, `'VIEW'`, `'CURSOR'`], (optional)) –

          Projection Type

          - `KEEP`
            No Reproject.
          - `FRONT`
            Front – Reproject the strokes using the X-Z plane.
          - `SIDE`
            Side – Reproject the strokes using the Y-Z plane.
          - `TOP`
            Top – Reproject the strokes using the X-Y plane.
          - `VIEW`
            View – Reproject the strokes to end up on the same plane, as if drawn from the current viewpoint using ‘Cursor’ Stroke Placement.
          - `CURSOR`
            Cursor – Reproject the strokes using the orientation of 3D cursor.

bpy.ops.grease_pencil.brush_stroke(*\**, *stroke=None*, *mode='NORMAL'*, *pen_flip=False*)
:   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'`, `'ERASE'`], (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.
          - `ERASE`
            Erase – Switch brush to erase mode for duration of stroke.
        - **pen_flip** (*boolean**,* *(**optional**)*) – Pen Flip, Whether a tablet’s eraser mode is being used

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.convert_curve_type(*\**, *type='POLY'*, *threshold=0.01*)
:   Convert type of selected curves

    Parameters:
    :   - **type** (enum in [Curves Type Items](bpy_types_enum_items/curves_type_items.html#rna-enum-curves-type-items), (optional)) – Type
        - **threshold** (*float in* *[**0**,* *100**]**,* *(**optional**)*) – Threshold, The distance that the resulting points are allowed to be within

bpy.ops.grease_pencil.copy()
:   Copy the selected Grease Pencil points or strokes to the internal clipboard

bpy.ops.grease_pencil.cyclical_set(*\**, *type='TOGGLE'*, *subdivide_cyclic_segment=True*)
:   Close or open the selected stroke adding a segment from last to first point

    Parameters:
    :   - **type** (enum in [`'CLOSE'`, `'OPEN'`, `'TOGGLE'`], (optional)) – Type
        - **subdivide_cyclic_segment** (*boolean**,* *(**optional**)*) – Match Point Density, Add point in the new segment to keep the same density

bpy.ops.grease_pencil.delete()
:   Delete selected strokes or points

bpy.ops.grease_pencil.delete_breakdown()
:   Remove breakdown frames generated by interpolating between two Grease Pencil frames

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.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.erase_box(*\**, *xmin=0*, *xmax=0*, *ymin=0*, *ymax=0*, *wait_for_input=True*)
:   Erase points in the box region

    Parameters:
    :   - **xmin** (*int in* *[**-inf**,* *inf**]**,* *(**optional**)*) – X Min
        - **xmax** (*int in* *[**-inf**,* *inf**]**,* *(**optional**)*) – X Max
        - **ymin** (*int in* *[**-inf**,* *inf**]**,* *(**optional**)*) – Y Min
        - **ymax** (*int in* *[**-inf**,* *inf**]**,* *(**optional**)*) – Y Max
        - **wait_for_input** (*boolean**,* *(**optional**)*) – Wait for Input

bpy.ops.grease_pencil.erase_lasso(*\**, *path=None*, *use_smooth_stroke=False*, *smooth_stroke_factor=0.75*, *smooth_stroke_radius=35*)
:   Erase points in the lasso region

    Parameters:
    :   - **path** (`bpy_prop_collection` of `OperatorMousePath`, (optional)) – Path
        - **use_smooth_stroke** (*boolean**,* *(**optional**)*) – Stabilize Stroke, Selection lags behind mouse and follows a smoother path
        - **smooth_stroke_factor** (*float in* *[**0.5**,* *0.99**]**,* *(**optional**)*) – Smooth Stroke Factor, Higher values gives a smoother stroke
        - **smooth_stroke_radius** (*int in* *[**10**,* *200**]**,* *(**optional**)*) – Smooth Stroke Radius, Minimum distance from last point before selection continues

bpy.ops.grease_pencil.extrude()
:   Extrude the selected points

bpy.ops.grease_pencil.extrude_move(*\**, *GREASE_PENCIL_OT_extrude=None*, *TRANSFORM_OT_translate=None*)
:   Extrude selected points and move them

    Parameters:
    :   - **GREASE_PENCIL_OT_extrude** (`GREASE_PENCIL_OT_extrude`, (optional)) – Extrude Stroke Points, Extrude the selected points
        - **TRANSFORM_OT_translate** (`TRANSFORM_OT_translate`, (optional)) – Move, Move selected items

bpy.ops.grease_pencil.fill(*\**, *invert=False*, *precision=False*)
:   Fill with color the shape formed by strokes

    Parameters:
    :   - **invert** (*boolean**,* *(**optional**)*) – Invert, Find boundary of unfilled instead of filled regions
        - **precision** (*boolean**,* *(**optional**)*) – Precision, Use precision movement for extension lines

bpy.ops.grease_pencil.frame_clean_duplicate(*\**, *selected=False*)
:   Remove any keyframe that is a duplicate of the previous one

    Parameters:
    :   **selected** (*boolean**,* *(**optional**)*) – Selected, Only delete selected keyframes

bpy.ops.grease_pencil.frame_duplicate(*\**, *all=False*)
:   Make a copy of the active Grease Pencil frame(s)

    Parameters:
    :   **all** (*boolean**,* *(**optional**)*) – Duplicate all, Duplicate active keyframes of all layer

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.interpolate(*\**, *shift=0.0*, *layers='ACTIVE'*, *exclude_breakdowns=False*, *use_selection=False*, *flip='AUTO'*, *smooth_steps=1*, *smooth_factor=0.0*)
:   Interpolate Grease Pencil strokes between frames

    Parameters:
    :   - **shift** (*float in* *[**-1**,* *1**]**,* *(**optional**)*) – Shift, Bias factor for which frame has more influence on the interpolated strokes
        - **layers** (enum in [`'ACTIVE'`, `'ALL'`], (optional)) – Layer, Layers included in the interpolation
        - **exclude_breakdowns** (*boolean**,* *(**optional**)*) – Exclude Breakdowns, Exclude existing Breakdowns keyframes as interpolation extremes
        - **use_selection** (*boolean**,* *(**optional**)*) – Use Selection, Use only selected strokes for interpolating
        - **flip** (enum in [`'NONE'`, `'FLIP'`, `'AUTO'`], (optional)) – Flip Mode, Invert destination stroke to match start and end with source stroke
        - **smooth_steps** (*int in* *[**1**,* *3**]**,* *(**optional**)*) – Iterations, Number of times to smooth newly created strokes
        - **smooth_factor** (*float in* *[**0**,* *2**]**,* *(**optional**)*) – Smooth, Amount of smoothing to apply to interpolated strokes, to reduce jitter/noise

bpy.ops.grease_pencil.interpolate_sequence(*\**, *step=1*, *layers='ACTIVE'*, *exclude_breakdowns=False*, *use_selection=False*, *flip='AUTO'*, *smooth_steps=1*, *smooth_factor=0.0*, *type='LINEAR'*, *easing='EASE_IN'*, *back=1.702*, *amplitude=0.15*, *period=0.15*)
:   Generate ‘in-betweens’ to smoothly interpolate between Grease Pencil frames

    Parameters:
    :   - **step** (*int in* *[**1**,* *1048574**]**,* *(**optional**)*) – Step, Number of frames between generated interpolated frames
        - **layers** (enum in [`'ACTIVE'`, `'ALL'`], (optional)) – Layer, Layers included in the interpolation
        - **exclude_breakdowns** (*boolean**,* *(**optional**)*) – Exclude Breakdowns, Exclude existing Breakdowns keyframes as interpolation extremes
        - **use_selection** (*boolean**,* *(**optional**)*) – Use Selection, Use only selected strokes for interpolating
        - **flip** (enum in [`'NONE'`, `'FLIP'`, `'AUTO'`], (optional)) – Flip Mode, Invert destination stroke to match start and end with source stroke
        - **smooth_steps** (*int in* *[**1**,* *3**]**,* *(**optional**)*) – Iterations, Number of times to smooth newly created strokes
        - **smooth_factor** (*float in* *[**0**,* *2**]**,* *(**optional**)*) – Smooth, Amount of smoothing to apply to interpolated strokes, to reduce jitter/noise
        - **type** (enum in [`'LINEAR'`, `'CUSTOM'`, `'SINE'`, `'QUAD'`, `'CUBIC'`, `'QUART'`, `'QUINT'`, `'EXPO'`, `'CIRC'`, `'BACK'`, `'BOUNCE'`, `'ELASTIC'`], (optional)) –

          Type, Interpolation method to use the next time ‘Interpolate Sequence’ is run

          - `LINEAR`
            Linear – Straight-line interpolation between A and B (i.e. no ease in/out).
          - `CUSTOM`
            Custom – Custom interpolation defined using a curve map.
          - `SINE`
            Sinusoidal – Sinusoidal easing (weakest, almost linear but with a slight curvature).
          - `QUAD`
            Quadratic – Quadratic easing.
          - `CUBIC`
            Cubic – Cubic easing.
          - `QUART`
            Quartic – Quartic easing.
          - `QUINT`
            Quintic – Quintic easing.
          - `EXPO`
            Exponential – Exponential easing (dramatic).
          - `CIRC`
            Circular – Circular easing (strongest and most dynamic).
          - `BACK`
            Back – Cubic easing with overshoot and settle.
          - `BOUNCE`
            Bounce – Exponentially decaying parabolic bounce, like when objects collide.
          - `ELASTIC`
            Elastic – Exponentially decaying sine wave, like an elastic band.
        - **easing** (enum in [Beztriple Interpolation Easing Items](bpy_types_enum_items/beztriple_interpolation_easing_items.html#rna-enum-beztriple-interpolation-easing-items), (optional)) – Easing, Which ends of the segment between the preceding and following Grease Pencil frames easing interpolation is applied to
        - **back** (*float in* *[**0**,* *inf**]**,* *(**optional**)*) – Back, Amount of overshoot for ‘back’ easing
        - **amplitude** (*float in* *[**0**,* *inf**]**,* *(**optional**)*) – Amplitude, Amount to boost elastic bounces for ‘elastic’ easing
        - **period** (*float in* *[**-inf**,* *inf**]**,* *(**optional**)*) – Period, Time between bounces for elastic easing

bpy.ops.grease_pencil.join_selection(*\**, *type='JOINSTROKES'*)
:   New stroke from selected points/strokes

    Parameters:
    :   **type** (enum in [`'JOINSTROKES'`, `'SPLITCOPY'`, `'SPLIT'`], (optional)) –

        Type, Defines how the operator will behave on the selection in the active layer

        - `JOINSTROKES`
          Join Strokes – Join the selected strokes into one stroke.
        - `SPLITCOPY`
          Split and Copy – Copy the selected points to a new stroke.
        - `SPLIT`
          Split – Split the selected point to a new stroke.

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_duplicate_object(*\**, *only_active=True*, *mode='ALL'*)
:   Make a copy of the active Grease Pencil layer to selected object

    Parameters:
    :   - **only_active** (*boolean**,* *(**optional**)*) – Only Active, Copy only active Layer, uncheck to append all layers
        - **mode** (enum in [`'ALL'`, `'ACTIVE'`], (optional)) – Mode

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_group_color_tag(*\**, *color_tag='COLOR1'*)
:   Change layer group icon

    Parameters:
    :   **color_tag** (enum in [`'NONE'`, `'COLOR1'`, `'COLOR2'`, `'COLOR3'`, `'COLOR4'`, `'COLOR5'`, `'COLOR6'`, `'COLOR7'`, `'COLOR8'`], (optional)) – Color Tag

bpy.ops.grease_pencil.layer_group_remove(*\**, *keep_children=False*)
:   Remove Grease Pencil layer group in the active object

    Parameters:
    :   **keep_children** (*boolean**,* *(**optional**)*) – Keep children nodes, Keep the children nodes of the group and only delete the group itself

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_mask_add(*\**, *name=''*)
:   Add new layer as masking

    Parameters:
    :   **name** (*string**,* *(**optional**,* *never None**)*) – Layer, Name of the layer

bpy.ops.grease_pencil.layer_mask_remove()
:   Remove Layer Mask

bpy.ops.grease_pencil.layer_mask_reorder(*\**, *direction='UP'*)
:   Reorder the active Grease Pencil mask layer up/down in the list

    Parameters:
    :   **direction** (enum in [`'UP'`, `'DOWN'`], (optional)) – Direction

bpy.ops.grease_pencil.layer_merge(*\**, *mode='ACTIVE'*)
:   Combine layers based on the mode into one layer

    Parameters:
    :   **mode** (enum in [`'ACTIVE'`, `'GROUP'`, `'ALL'`], (optional)) –

        Mode

        - `ACTIVE`
          Active – Combine the active layer with the layer just below (if it exists).
        - `GROUP`
          Group – Combine layers in the active group into a single layer.
        - `ALL`
          All – Combine all layers into a single layer.

bpy.ops.grease_pencil.layer_move(*\**, *direction='UP'*)
:   Move the active Grease Pencil layer or Group

    Parameters:
    :   **direction** (enum in [`'UP'`, `'DOWN'`], (optional)) – Direction

bpy.ops.grease_pencil.layer_remove()
:   Remove the active Grease Pencil layer

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** (*boolea