Skip to content

Instantly share code, notes, and snippets.

View CGArtPython's full-sized avatar
👋

CGArtPython

👋
View GitHub Profile
@CGArtPython
CGArtPython / empty_following_a_bezier_circle_curve.py
Created January 31, 2023 06:26
Add a Bezier circle curve and an empty, make the empty animate by following the circle curve
import bpy
last_frame = 90
# set the lenght of the animation
bpy.context.scene.frame_end = last_frame
# add a Bezier circle curve into the scene
bpy.ops.curve.primitive_bezier_circle_add()
bezier_circle_obj = bpy.context.active_object
@CGArtPython
CGArtPython / update_cube_hight.py
Created January 31, 2023 06:16
Add a cube into the scene and update the hight
import bpy
custom_size = 5
# add cube into the scene
bpy.ops.mesh.primitive_cube_add(size=custom_size)
cube_obj = bpy.context.active_object
# move the cube up half way on the Z axis
cube_obj.location.z = custom_size / 2
@CGArtPython
CGArtPython / reading_and_writing_json_files.py
Last active March 13, 2024 21:34
Reading and Writing JSON Files for Blender Python Beginners (tutorial video: https://youtu.be/f6UoW5rtrw0)
# extend Python's functionality to work with JSON files
import json
# extend Python's functionality to work with file paths
import pathlib
# extend Python's functionality to print data in a readable way
import pprint
# give Python access to Blender's functionality
@CGArtPython
CGArtPython / create_a_cube_with_bmesh.py
Created January 30, 2023 08:42
Beginner Python Exercise in Blender: Make a cube from a list of vertices (tutorial https://www.youtube.com/watch?v=mN3n9b98HMk)
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 / 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 January 24, 2023 07:48
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