Skip to content

Instantly share code, notes, and snippets.

@CGArtPython
Last active September 19, 2022 06:11
Show Gist options
  • Save CGArtPython/8adc0c15813684db465a359313060164 to your computer and use it in GitHub Desktop.
Save CGArtPython/8adc0c15813684db465a359313060164 to your computer and use it in GitHub Desktop.
The starting code for a exercise video about using Python for working with Blender collections. (Link to video: https://www.youtube.com/watch?v=rWt-SY0NAHs )
# give Python access to Blender's functionality
import bpy
# create a variable to set the spacing between object origins
location_offset = 3
# create a row of cubes along the X-axis
for i in range(10):
bpy.ops.mesh.primitive_cube_add(location=(i * location_offset, 0, 0))
# create a row of icospheres along the X-axis
for i in range(10):
bpy.ops.mesh.primitive_ico_sphere_add(location=(i * location_offset, 0, location_offset))
# create a row of monkey heads along the X-axis
for i in range(10):
bpy.ops.mesh.primitive_monkey_add(location=(i * location_offset, 0, 2 * location_offset))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment