Skip to content

Instantly share code, notes, and snippets.

@zeffii
Created September 14, 2015 07:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeffii/d61a4963e6c093dda52b to your computer and use it in GitHub Desktop.
Save zeffii/d61a4963e6c093dda52b to your computer and use it in GitHub Desktop.
import bpy
import bmesh
import random
me = bpy.context.object.data
# Get a BMesh representation
bm = bmesh.new() # create an empty BMesh
bm.from_mesh(me) # fill it in from a Mesh
# Modify the BMesh, can do anything here...
for v in bm.verts:
orientations = [[-1,0,0], [1,0,0], [0,1,0], [0,-1,0]]
v.normal = random.choice(orientations)
# Finish up, write the bmesh back to the mesh
bm.to_mesh(me)
bm.free() # free and prevent further access
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment