Skip to content

Instantly share code, notes, and snippets.

View CGArtPython's full-sized avatar
👋

CGArtPython

👋
View GitHub Profile
@CGArtPython
CGArtPython / example_2_start.py
Last active October 3, 2022 05:53
Beginner Blender Python Tutorial: Python Lists Example 2 scene setup code (used in tutorial: https://youtu.be/-Gc3UHGoxgc)
# give Python access to Blender's functionality
import bpy
# extend Python functionality to generate random numbers
import random
# add ico spheres into the scene
object_count = 10
for _ in range(object_count):
x = random.uniform(-5, 5)
@CGArtPython
CGArtPython / example_2.py
Last active October 3, 2022 05:53
Beginner Blender Python Tutorial: Python Lists Example 2 (used in tutorial: https://youtu.be/-Gc3UHGoxgc)
# 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
@CGArtPython
CGArtPython / example_3.py
Last active October 3, 2022 05:54
Beginner Blender Python Tutorial: Python Lists Example 3 (used in tutorial: https://youtu.be/-Gc3UHGoxgc)
# give Python access to Blender's functionality
import bpy
# extend Python functionality to generate random numbers
import random
# create a list of colors
colors = [
[0.888, 0.515, 0.016, 1.0],
[0.03, 0.376, 0.521, 1.0],
@CGArtPython
CGArtPython / phyllotaxis_pattern_func.py
Created October 3, 2022 06:44
Phyllotaxis pattern experiment based on code from https://www.youtube.com/watch?v=WHAQwhr1Jto
"""
Creating a phyllotaxis pattern based on formula 4.1 from
http://algorithmicbotany.org/papers/abop/abop-ch4.pdf
"""
# give Python access to Blender's functionality
import bpy
# extend Python functionality to generate random numbers
import random
@CGArtPython
CGArtPython / exercise_cube_triangle_recalculate_normals.py
Created October 13, 2022 06:11
This is an example Blender Python script that shows how you can recalculate the normals (based on this tutorial https://www.youtube.com/watch?v=mN3n9b98HMk&lc=UgzNYFhB4FXUifXe1ml4AaABAg)
import bpy
verts = [
(-1.0, -1.0, -1.0),
(-1.0, 1.0, -1.0),
(1.0, 1.0, -1.0),
(1.0, -1.0, -1.0),
(-1.0, -1.0, 1.0),
(-1.0, 1.0, 1.0),
(1.0, 1.0, 1.0),
@CGArtPython
CGArtPython / dict_example_1.py
Last active December 1, 2022 07:33
Beginner Blender Python Tutorial: Python Dictionaries Example 1 (used in tutorial: https://youtu.be/FkJ2XanNBR4)
# give Python access to Blender's functionality
import bpy
# extend Python functionality to generate random numbers
import random
def create_plane_with_color(color, location):
# add a plane
bpy.ops.mesh.primitive_plane_add()
@CGArtPython
CGArtPython / dict_example_2_start.py
Last active December 1, 2022 07:23
Beginner Blender Python Tutorial: Python Dictionaries Example 2 scene setup code (used in tutorial: https://youtu.be/FkJ2XanNBR4)
# give Python access to Blender's functionality
import bpy
# extend Python functionality to generate random numbers
import random
# add ico spheres into the scene
object_count = 10
for _ in range(object_count):
x = random.uniform(-5, 5)
@CGArtPython
CGArtPython / dict_example_2.py
Last active December 1, 2022 07:37
Beginner Blender Python Tutorial: Python Dictionaries Example 2 (used in tutorial: https://youtu.be/FkJ2XanNBR4)
# give Python access to Blender's functionality
import bpy
cube_key = "cubes"
ico_key = "spheres"
cone_key = "cones"
# create a dict of mesh lists
mesh_objects = {
cube_key: list(),
@CGArtPython
CGArtPython / step_by_step_example_1.py
Last active October 31, 2022 06:00
Beginner Blender Python Tutorial: Python Classes step by step version Example 1 (used in tutorial: https://youtu.be/t2KEolkhIoA)
import bpy
#######################################################################
# create a cube with square faces
#######################################################################
# define the coordinates of each vertex
verts = [
(-1.0, -1.0, -1.0),
(-1.0, 1.0, -1.0),
@CGArtPython
CGArtPython / with_functions_example_1.py
Last active October 31, 2022 06:01
Beginner Blender Python Tutorial: Python Classes; function version example 1 (used in tutorial: https://youtu.be/t2KEolkhIoA)
import bpy
def create_mesh_data(verts, edges, faces):
"""
create a mesh from the vert, edge, and face data
"""
mesh_data = bpy.data.meshes.new("cube_data")
mesh_data.from_pydata(verts, edges, faces)