user: Show practical ways to work with GreasePencilDrawing(bpy_struct) in a Blender add-on or script – include code.

assistant: # GreasePencilDrawing(bpy_struct)

base class — [`bpy_struct`](bpy.types.bpy_struct.html#bpy.types.bpy_struct "bpy.types.bpy_struct")

*class* bpy.types.GreasePencilDrawing(*bpy_struct*)
:   A Grease Pencil drawing

    attributes
    :   Geometry attributes

        Type:
        :   [`AttributeGroupGreasePencilDrawing`](bpy.types.AttributeGroupGreasePencilDrawing.html#bpy.types.AttributeGroupGreasePencilDrawing "bpy.types.AttributeGroupGreasePencilDrawing") [`bpy_prop_collection`](bpy.types.bpy_prop_collection.html#bpy.types.bpy_prop_collection "bpy.types.bpy_prop_collection") of [`Attribute`](bpy.types.Attribute.html#bpy.types.Attribute "bpy.types.Attribute"), (readonly)

    color_attributes
    :   Geometry color attributes

        Type:
        :   [`AttributeGroupGreasePencilDrawing`](bpy.types.AttributeGroupGreasePencilDrawing.html#bpy.types.AttributeGroupGreasePencilDrawing "bpy.types.AttributeGroupGreasePencilDrawing") [`bpy_prop_collection`](bpy.types.bpy_prop_collection.html#bpy.types.bpy_prop_collection "bpy.types.bpy_prop_collection") of [`Attribute`](bpy.types.Attribute.html#bpy.types.Attribute "bpy.types.Attribute"), (readonly)

    curve_offsets
    :   Offset indices of the first point of each curve

        Type:
        :   [`bpy_prop_collection`](bpy.types.bpy_prop_collection.html#bpy.types.bpy_prop_collection "bpy.types.bpy_prop_collection") of [`IntAttributeValue`](bpy.types.IntAttributeValue.html#bpy.types.IntAttributeValue "bpy.types.IntAttributeValue"), (readonly)

    type
    :   Drawing type

        Type:
        :   enum in [`'DRAWING'`, `'REFERENCE'`], default `'DRAWING'`, (readonly)

    user_count
    :   The number of keyframes this drawing is used by

        Type:
        :   int in [-inf, inf], default 0, (readonly)

    strokes
    :   Return a collection of all the Grease Pencil strokes in this drawing.

        (readonly)

    add_strokes(*sizes*)
    :   Add new strokes with provided sizes at the end

        Parameters:
        :   **sizes** (*int array* *of* *1 items in* *[**1**,* *inf**]*) – Sizes, The number of points in each stroke

    remove_strokes(*\**, *indices=(0,)*)
    :   Remove all strokes. If indices are provided, remove only the strokes with the given indices.

        Parameters:
        :   **indices** (*int array* *of* *1 items in* *[**0**,* *inf**]**,* *(**optional**)*) – Indices, The indices of the strokes to remove

    resize_strokes(*sizes*, *\**, *indices=(0,)*)
    :   Resize all existing strokes. If indices are provided, resize only the strokes with the given indices. If the new size for a stroke is smaller, the stroke is trimmed. If the new size for a stroke is larger, the new end values are default initialized.

        Parameters:
        :   - **sizes** (*int array* *of* *1 items in* *[**1**,* *inf**]*) – Sizes, The number of points in each stroke
            - **indices** (*int array* *of* *1 items in* *[**0**,* *inf**]**,* *(**optional**)*) – Indices, The indices of the stroke to resize

    reorder_strokes(*new_indices*)
    :   Reorder the strokes by the new indices.

        Parameters:
        :   **new_indices** (*int array* *of* *1 items in* *[**0**,* *inf**]*) – New indices, The new index for each of the strokes

    set_types(*\**, *type='CATMULL_ROM'*, *indices=(0,)*)
    :   Set the curve type. If indices are provided, set only the types with the given curve indices.

        Parameters:
        :   - **type** (enum in [Curves Type Items](bpy_types_enum_items/curves_type_items.html#rna-enum-curves-type-items), (optional)) – Type
            - **indices** (*int array* *of* *1 items in* *[**0**,* *inf**]**,* *(**optional**)*) – Indices, The indices of the curves to resize

    tag_positions_changed()
    :   Indicate that the positions of points in the drawing have changed

    vertex_group_assign(*vgroup_name*, *indices_ptr*, *weight*)
    :   Assign points to vertex group

        Parameters:
        :   - **vgroup_name** (*string**,* *(**never None**)*) – Vertex Group Name, Name of the vertex group
            - **indices_ptr** (*int array* *of* *1 items in* *[**-inf**,* *inf**]*) – Indices, The point indices to assign the weight to
            - **weight** (*float in* *[**0**,* *1**]*) – Vertex weight

    vertex_group_remove(*vgroup_name*, *indices_ptr*)
    :   Remove points from vertex group

        Parameters:
        :   - **vgroup_name** (*string**,* *(**never None**)*) – Vertex Group Name, Name of the vertex group
            - **indices_ptr** (*int array* *of* *1 items in* *[**-inf**,* *inf**]*) – Indices, The point indices to remove from the vertex group

    set_vertex_weights(*vertex_group_name*, *indices*, *weights*, *\**, *assign_mode='REPLACE'*)
    :   Set the weights of vertices in a grease pencil drawing

        Parameters:
        :   - **vertex_group_name** (*string**,* *(**never None**)*) – Vertex Group Name, Name of the vertex group
            - **indices** (*int array* *of* *1 items in* *[**-inf**,* *inf**]*) – Indices, The point indices in the vertex group to modify
            - **weights** (*float array* *of* *1 items in* *[**0**,* *1**]*) – Weights, The weight for each corresponding index in the indices array
            - **assign_mode** (enum in [`'REPLACE'`, `'ADD'`, `'SUBTRACT'`], (optional)) –
              - `REPLACE`
                Replace – Replace.
              - `ADD`
                Add – Add.
              - `SUBTRACT`
                Subtract – Subtract.

    *classmethod* bl_rna_get_subclass(*id*, *default=None*, */*)
    :   Parameters:
        :   **id** (*str*) – The RNA type identifier.

        Returns:
        :   The RNA type or default when not found.

        Return type:
        :   [`bpy.types.Struct`](bpy.types.Struct.html#bpy.types.Struct "bpy.types.Struct") subclass

    *classmethod* bl_rna_get_subclass_py(*id*, *default=None*, */*)
    :   Parameters:
        :   **id** (*str*) – The RNA type identifier.

        Returns:
        :   The class or default when not found.

        Return type:
        :   [type](#bpy.types.GreasePencilDrawing.type "bpy.types.GreasePencilDrawing.type")