databpy 0.13.0
  • Home
  • Guides
    • Attributes
    • Syncing with Blender
    • Grease pencil and evaluated geometry
  • API
  • Changelog
  1. Objects
  2. Drawing
  • Function reference
  • Attribute
    • named_attribute
    • store_named_attribute
    • remove_named_attribute
    • list_attributes
    • AttributeDomains
    • AttributeTypes
    • AttributeArray
    • Attribute
    • attribute.guess_atype_from_array
  • Typed arrays
    • float32
    • vec2
    • vec3
    • vec4
    • color
    • srgb
    • color8
    • quat
    • mat4
    • int32
    • int8
    • ivec2
    • sivec2
    • boolean
    • string
  • Collections
    • create_collection
    • move_to_collection
  • Objects
    • create_object
    • create_mesh_object
    • create_curves_object
    • create_grease_pencil_object
    • create_pointcloud_object
    • create_bob
    • evaluate_object
    • GeometrySet
    • BlenderObject
    • AttributeDomainView
    • InstanceDomainView
    • Drawing
    • Drawings
    • BlenderObjectAttribute
    • BlenderObjectBase
  • Errors
    • DatabpyError
    • NamedAttributeError
    • AttributeNotFoundError
    • AttributeMismatchError
    • LinkedObjectError
  • Utilities
    • require
    • require_data
    • mesh_data
    • curves_data
    • pointcloud_data
    • volume_data
    • active_scene
    • active_object
    • centre
    • lerp
  • Nodes (deprecated)
    • nodes.new_tree
    • nodes.swap_tree
    • nodes.custom_string_iswitch
    • nodes.append_from_blend
    • nodes.new_socket
    • nodes.tree_interface
    • nodes.input_socket
    • nodes.output_socket
    • nodes.socket_value
    • nodes.set_socket_value
    • nodes.MaintainConnections
    • nodes.DuplicatePrevention

On this page

  • Drawing
    • Examples
    • Attributes
    • Methods
  1. Objects
  2. Drawing

Drawing

Drawing(grease_pencil, key, bob=None)

The points and strokes of a grease pencil drawing: one layer on one keyframe.

Get a drawing from bob.drawings for a grease pencil object, or from GeometrySet.drawings for any object whose evaluated geometry has grease pencil. Its attributes are on the point and curve domain views, the same as on a BlenderObject. Changes to the drawings of a grease pencil object are written back to Blender, while the drawings of evaluated geometry are read-only copies.

The drawing is looked up each time it is used, so a Drawing, and arrays read from it, stay valid when keyframes are added. They raise a LinkedObjectError once the layer is removed or renamed, or the keyframe is removed or moved to another frame. A keyframe is found by its frame, so if another keyframe is moved onto that frame, its drawing is used instead.

A keyframe made with frames.copy(..., instance_drawing=True) shares the drawing of the keyframe it was copied from, so changes to one also change the other.

Examples

drawing = bob.drawings["Lines"]
drawing.point["radius"] *= 0.5
drawing.curve["material_index"] = 1

Attributes

Name Description
attributes The attributes collection of the drawing.
curve Attributes on the CURVE domain, one value per stroke.
drawing The bpy.types.GreasePencilDrawing this wraps.
frame The frame of the drawing’s keyframe.
layer The name of the drawing’s layer.
point Attributes on the POINT domain.
read_only Whether this is a drawing of evaluated geometry, which can’t be written.

Methods

Name Description
list_attributes List the names of the drawing’s attributes.
remove_named_attribute Remove an attribute from the drawing.
store_named_attribute Store a named attribute on the drawing, creating it if needed.

list_attributes

Drawing.list_attributes(drop_hidden=False)

List the names of the drawing’s attributes.

remove_named_attribute

Drawing.remove_named_attribute(name)

Remove an attribute from the drawing.

Raises

Name Type Description
TypeError If the drawing is from evaluated geometry, which is read-only.
AttributeNotFoundError If the attribute doesn’t exist.
NamedAttributeError If the attribute is required by Blender (e.g. position).

store_named_attribute

Drawing.store_named_attribute(data, name, atype=None, domain=None)

Store a named attribute on the drawing, creating it if needed.

Takes the same arguments as BlenderObject.store_named_attribute. New attributes are stored on the POINT domain unless domain is given.

Raises

Name Type Description
TypeError If the drawing is from evaluated geometry, which is read-only.
InstanceDomainView
Drawings