Skip to content

Instantly share code, notes, and snippets.

@SabinT
Last active August 29, 2015 14:20
Show Gist options
  • Save SabinT/39a133d052182bfd1045 to your computer and use it in GitHub Desktop.
Save SabinT/39a133d052182bfd1045 to your computer and use it in GitHub Desktop.
Normalize (or project to sphere) selected vertices in Blender
import bmesh
def normalize_selected():
m = bpy.context.active_object.data # get selected object's mesh
bm = bmesh.new() # create an empty BMesh
bm.from_mesh(m) # fill it in from a Mesh
for v in bm.verts:
if v.select:
v.co.normalize()
bm.to_mesh(m)
def project_selected(radius):
m = bpy.context.active_object.data # get selected object's mesh
bm = bmesh.new() # create an empty BMesh
bm.from_mesh(m) # fill it in from a Mesh
for v in bm.verts:
if v.select:
v.co.normalize()
v.co = v.co * radius
bm.to_mesh(m)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment