Skip to content

Instantly share code, notes, and snippets.

@pcote
Created January 6, 2017 20:52
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 pcote/b6fbb1e4649ea91a25903006bc02fbad to your computer and use it in GitHub Desktop.
Save pcote/b6fbb1e4649ea91a25903006bc02fbad to your computer and use it in GitHub Desktop.
Blender addon that generates empties that trace along points on a grease pencil path.
import bpy
from bpy.props import IntProperty
def points(strokes):
for stroke in strokes:
for point in stroke.points:
yield point
class GreaseEmpties(bpy.types.Operator):
bl_label = "Grease Empties"
bl_idname = "object.grease_empties"
bl_options = {"REGISTER", "UNDO"}
every_nth = IntProperty("Every Nth", min=1, max=100, default=1)
def execute(self, cxt):
pencil = cxt.scene.grease_pencil
strokes = pencil.layers.active.active_frame.strokes
for n, point in enumerate(points(strokes)):
if n % self.every_nth == 0:
x, y, z = point.co
new_empty = bpy.data.objects.new("empty", object_data=None)
cxt.scene.objects.link(new_empty)
new_empty.location = x, y, z
return {"FINISHED"}
def register():
bpy.utils.register_class(GreaseEmpties)
def unregister():
bpy.utils.unregister_class(GreaseEmpties)
if __name__ == '__main__':
register()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment