Skip to content

Instantly share code, notes, and snippets.

View CGArtPython's full-sized avatar
👋

CGArtPython

👋
View GitHub Profile
@CGArtPython
CGArtPython / import_images_as_plains.py
Created January 24, 2023 07:52
Final code for a Beginner Blender Python Tutorial about How to import images as plains with Python (link to tutorial: https://youtu.be/0jYqTkwJ-wg)
# extend Python's functionality to work with file paths
import pathlib
# give Python access to Blender's functionality
import bpy
# give Python access to Blender's add-on functionality
import addon_utils
@CGArtPython
CGArtPython / rolling_cube_part_2.py
Last active June 13, 2024 07:20
Final code for a Beginner Blender Python Tutorial about creating a rolling cube animation part 2 (link to tutorial: https://youtu.be/sR0X5-7FR_w)
# extend Python's math functionality
import math
# give Python access to Blender's functionality
import bpy
def create_cube():
"""Add a cube into the scene"""
bpy.ops.mesh.primitive_cube_add()
return bpy.context.active_object
@CGArtPython
CGArtPython / easy_cube_rotation_animation.py
Created January 4, 2023 21:16
Final code for a Beginner Blender Python Exercise: Easy cube rotation animation (link to tutorial: https://www.youtube.com/watch?v=tBPuEWh88Lo)
# give Python access to Blender's functionality
import bpy
# extend Python's math functionality
import math
# add a cube into the scene
bpy.ops.mesh.primitive_cube_add()
# get a reference to the currently active object
cube = bpy.context.active_object
@CGArtPython
CGArtPython / rolling_cube_part_1.py
Created December 26, 2022 05:28
Final code for a Beginner Blender Python Tutorial about create a rolling cube animation (link to tutorial: https://youtu.be/YucvNo8AICU)
# extend Python's math functionality
import math
# give Python access to Blender's functionality
import bpy
# create cube
bpy.ops.mesh.primitive_cube_add()
cube = bpy.context.active_object
@CGArtPython
CGArtPython / add_ico_spheres_in_a_circle_add_on.py
Created December 15, 2022 07:32
Example of turing the script from this tutorial https://youtu.be/uOQ-CPcaqMo into a simple add-on
"""
Example of turing the script from this tutorial
https://youtu.be/uOQ-CPcaqMo
into a simple add-on.
This code is based on the addon_add_object.py Python template distributed with BLender under the GNU GPL license.
An explanation of this script can be found in this tutorial: https://youtu.be/x3QRp2k013k
"""
bl_info = {
@CGArtPython
CGArtPython / refactor_and_animate.py
Created December 5, 2022 08:32
Final code for a Beginner Blender Python Tutorial about refactoring and animating (link to tutorial: https://youtu.be/tC_Bu-VO8p0)
# give Python access to Blender's functionality
import bpy
# extend Python's math functionality
import math
# extend Python functionality to generate random numbers
import random
@CGArtPython
CGArtPython / from_a_for_loop_to_a_while_loop.py
Created November 28, 2022 07:31
Final code for a Beginner Blender Python Tutorial about using a for/while loop (link to tutorial: https://youtu.be/AcoYA4T2ErU)
# give Python access to Blender's functionality
import bpy
# extend Python's math functionality
import math
# add a cube mesh into the scene
bpy.ops.mesh.primitive_cube_add()
# get a reference to the currently active object
@CGArtPython
CGArtPython / with_classes_example_3.py
Last active July 26, 2023 03:27
Beginner Blender Python Tutorial: Python Classes example 3 (used in tutorial: https://youtu.be/t2KEolkhIoA)
import bpy
class Shape:
"""
a class to represent a mesh object
"""
# example of a class variable
instance_count = 0
@CGArtPython
CGArtPython / with_functions_example_2.py
Last active October 31, 2022 06:01
Beginner Blender Python Tutorial: Python Classes; function version example 3 (used in tutorial: https://youtu.be/t2KEolkhIoA)
import bpy
def create_mesh_data(name, verts, edges, faces):
"""
create a mesh from the vert, edge, and face data
"""
mesh_data = bpy.data.meshes.new(f"{name}_data")
mesh_data.from_pydata(verts, edges, faces)
@CGArtPython
CGArtPython / step_by_step_example_3.py
Last active October 31, 2022 06:00
Beginner Blender Python Tutorial: Python Classes; step by step version Example 3 (used in tutorial: https://youtu.be/t2KEolkhIoA)
import bpy
#######################################################################
# create a cube with square faces
#######################################################################
verts = [
(-1.0, -1.0, -1.0),
(-1.0, 1.0, -1.0),
(1.0, 1.0, -1.0),