Skip to content

Instantly share code, notes, and snippets.

@zeffii zeffii/convert_free.py
Last active Aug 29, 2015

Embed
What would you like to do?
import bpy
from mathutils import Vector
def convert_curve_to_gp(obj):
pencil = bpy.data.grease_pencil.new("pencil")
scene = bpy.context.scene
scene.grease_pencil = pencil
mesh = obj.data
layer = pencil.layers.new("layer", set_active=True)
frame = layer.frames.new(scene.frame_current)
mesh = obj.to_mesh(scene, apply_modifiers=False, settings='PREVIEW')
verts = mesh.vertices
for edge in mesh.edges:
stroke = frame.strokes.new()
stroke.draw_mode = '3DSPACE'
stroke.points.add(2)
stroke.points[0].co = obj.matrix_world * verts[edge.vertices[0]].co
stroke.points[1].co = obj.matrix_world * verts[edge.vertices[1]].co
bpy.data.meshes.remove(mesh)
obj = bpy.context.object
convert_curve_to_gp(obj)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.