Skip to content

Instantly share code, notes, and snippets.

@blender8r
blender8r / gpencil_line.py
Last active January 8, 2022 14:44
Generates a Blender grease pencil line
# Generates grease pencil line
import bpy
import random
def line(gp_frame, start_pos, end_pos, num_pts):
gp_stroke = gp_frame.strokes.new()
gp_stroke.line_width = 30
@blender8r
blender8r / gpencil_points.py
Last active January 8, 2022 14:53
Generates a Blender grease pencil stroke containing random points
# Generates grease pencil points with random position, size and color
import bpy
import random
sel_obj = None
sel_objs = bpy.context.selected_objects
if sel_objs:
import bpy
gpencil_data = bpy.data.grease_pencils.new("GPencil")
gpencil = bpy.data.objects.new(gpencil_data.name, gpencil_data)
bpy.context.collection.objects.link(gpencil)
gp_layer = gpencil_data.layers.new("lines")
gp_frame = gp_layer.frames.new(bpy.context.scene.frame_current)