Created
January 6, 2017 20:52
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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