This is me just goofing around. Here’s an addon operator that generates empties that follow grease pencil paths. Nothing serious but I thought it was neat. (color me easily amused?)
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()
Decided to go in a different direction with this. Instead of empty generation, decided to make this into a grease pencil selection tool addon instead. It lets you select grease pencil points randomly or every Nth point. Here’s what it looks like.
Glad you like it, Looch. I’ll give the “simplify grease pencil strokes” some thought. (no guarantees though) For the time being though, I’ll probably just look for ways to expand on selection options.
Another update. This time decided to put add an option where, if you have any points selected in a grease stroke, you can select all the other points in the same stroke.