Last active
May 27, 2022 05:21
-
-
Save CGArtPython/11299ee0037b992a4ee6c0abf5b05d4c to your computer and use it in GitHub Desktop.
Using Python to randomly offset vertices of a cube
This file contains hidden or 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
# 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