Skip to content

Instantly share code, notes, and snippets.

@CGArtPython
Created January 31, 2023 06:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CGArtPython/bcd142fab809e243053330eba7f9c863 to your computer and use it in GitHub Desktop.
Save CGArtPython/bcd142fab809e243053330eba7f9c863 to your computer and use it in GitHub Desktop.
Add a Bezier circle curve and an empty, make the empty animate by following the circle curve
import bpy
last_frame = 90
# set the lenght of the animation
bpy.context.scene.frame_end = last_frame
# add a Bezier circle curve into the scene
bpy.ops.curve.primitive_bezier_circle_add()
bezier_circle_obj = bpy.context.active_object
# set the number of frames it would take to traverse the curve
bezier_circle_obj.data.path_duration = last_frame
# add an empty into the scene
bpy.ops.object.empty_add()
empty_obj = bpy.context.active_object
# add the "follow path" constraint
bpy.ops.object.constraint_add(type="FOLLOW_PATH")
empty_obj.constraints["Follow Path"].target = bezier_circle_obj
bpy.ops.constraint.followpath_path_animate(constraint="Follow Path", owner="OBJECT")
empty_obj.constraints["Follow Path"].use_curve_follow = True
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment