Instantly share code, notes, and snippets.

Embed
What would you like to do?
Generate 2D points randomly distributed on a flat text mesh in Blender.
# run this from a blender interpreter
# First, create text object, then <SPACE> convert it from Text to a Mesh object. Select it.
import bpy_extras.mesh_utils
import pickle
obj = bpy.context.object # get actively selected object
me = obj.data # get mesh
me.calc_tessface() # recalc tessfaces
points = bpy_extras.mesh_utils.face_random_points(10, me.tessfaces)
points = [p[:2] for p in points] # discard Z coord
with open('/Users/eric/Desktop/siggraph.pkl','wb') as f:
pickle.dump(points, f, protocol=2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment