Last active
October 3, 2022 05:53
-
-
Save CGArtPython/cb53598625fd6dd3f9d1b0f2b49aecb8 to your computer and use it in GitHub Desktop.
Beginner Blender Python Tutorial: Python Lists Example 2 (used in tutorial: https://youtu.be/-Gc3UHGoxgc)
This file contains 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 cubes | |
cube_objects = [] | |
# collect all cubes into a list | |
for obj in bpy.data.objects: | |
if "Cube" in obj.name: | |
cube_objects.append(obj) | |
# loop over the cubes and replace them with monkeys | |
for cube in cube_objects: | |
location = cube.location | |
bpy.ops.mesh.primitive_monkey_add(location=location) | |
bpy.data.objects.remove(cube) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment