Skip to content

Instantly share code, notes, and snippets.

@5agado
Created February 1, 2019 15:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save 5agado/617c94753c2322f0f44c1444c31bf899 to your computer and use it in GitHub Desktop.
Save 5agado/617c94753c2322f0f44c1444c31bf899 to your computer and use it in GitHub Desktop.
def draw_circle(gp_frame, center: tuple, radius: float, segments: int):
# Init new stroke
gp_stroke = gp_frame.strokes.new()
gp_stroke.display_mode = '3DSPACE' # allows for editing
gp_stroke.draw_cyclic = True # closes the stroke
# Define stroke geometry
angle = 2*math.pi/segments # angle in radians
gp_stroke.points.add(count=segments)
for i in range(segments):
x = center[0] + radius*math.cos(angle*i)
y = center[1] + radius*math.sin(angle*i)
z = center[2]
gp_stroke.points[i].co = (x, y, z)
return gp_stroke
@rHohith
Copy link

rHohith commented Aug 24, 2021

gp_stroke.draw_cyclic = True
shows error

@jared-price
Copy link

@rHohith - It looks like this was changed to 'use_cyclic' in Blender 2.9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment