Last active
December 26, 2017 19:12
-
-
Save ericjang/dd56bbde3f9dc971c8ed6f78017c40f0 to your computer and use it in GitHub Desktop.
Generate 2D points randomly distributed on a flat text mesh in Blender.
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
# 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