Skip to content

Instantly share code, notes, and snippets.

@CGArtPython
Last active May 27, 2022 05:21
Show Gist options
  • Save CGArtPython/11299ee0037b992a4ee6c0abf5b05d4c to your computer and use it in GitHub Desktop.
Save CGArtPython/11299ee0037b992a4ee6c0abf5b05d4c to your computer and use it in GitHub Desktop.
Using Python to randomly offset vertices of a cube
# give Python access to Blender's functionality
import bpy
# extend Python functionality to generate random numbers
import random
# add a cube into the scene
bpy.ops.mesh.primitive_cube_add(size=2)
obj = bpy.context.active_object
# randomly offset vertices
for vertex in obj.data.vertices:
vertex.co.x += random.uniform(-1, 1)
vertex.co.y += random.uniform(-1, 1)
vertex.co.z += random.uniform(-1, 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment