Last active
October 3, 2022 05:53
-
-
Save CGArtPython/5084ad0a50c8f26ea1498ae8e3e6db86 to your computer and use it in GitHub Desktop.
Beginner Blender Python Tutorial: Python Lists Example 1B (used in tutorial: https://youtu.be/-Gc3UHGoxgc)
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 | |
# create a list of coordinates | |
coordinates = [] | |
coordinate_count = 10 | |
for _ in range(coordinate_count): | |
x = random.uniform(-5, 5) | |
y = random.uniform(-5, 5) | |
z = random.uniform(-5, 5) | |
coordinates.append([x, y, z]) | |
# add ico spheres into the scene using the list of coordinates | |
for coord in coordinates: | |
# access the coordinate components | |
x = coord[0] | |
y = coord[1] | |
z = coord[2] | |
bpy.ops.mesh.primitive_ico_sphere_add(radius=1, location=(x, y, z)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment