Skip to content

Instantly share code, notes, and snippets.

View CGArtPython's full-sized avatar
👋

CGArtPython

👋
View GitHub Profile
"""
The code for this art project:
https://www.artstation.com/artwork/48wX6L
Tested using: Blender 2.93
Author: Viktor Stepanov
License info: https://choosealicense.com/licenses/mit/
@CGArtPython
CGArtPython / blender_map_range_geonode.py
Created May 13, 2022 05:20
working with the Map Range Node in Blender's Geometry Nodes
import bpy
import mathutils
def add_map_range(node_tree):
map_range = node_tree.nodes.new(type="ShaderNodeMapRange")
# Attributes
map_range.interpolation_type = "LINEAR"
map_range.clamp = True
map_range.location = mathutils.Vector((0, 0))
@CGArtPython
CGArtPython / circle_mesh_part_1.py
Created May 16, 2022 00:30
Beginner Blender Python Exercise: Circle mesh from scratch (Part 1) https://www.youtube.com/watch?v=uOQ-CPcaqMo
# give Python access to Blender's functionality
import bpy
# extend Python's math functionality
import math
# extend Python's print functionality
import pprint
# initialize paramaters
@CGArtPython
CGArtPython / circle_mesh_part_2.py
Last active May 17, 2022 14:33
Beginner Blender Python Exercise: Circle mesh from scratch (Part 2) https://www.youtube.com/watch?v=AxazJi3x6js
# give Python access to Blender's functionality
import bpy
# extend Python's math functionality
import math
import pprint
def get_circle_verts(vert_count, radius):
@CGArtPython
CGArtPython / randomly_offset_vertices_of_a_cube.py
Last active May 27, 2022 05:21
Using Python to randomly offset vertices of a cube
# give Python access to Blender's functionality
import bpy
# extend Python functionality to generate random numbers
import random
# add a cube into the scene
bpy.ops.mesh.primitive_cube_add(size=2)
obj = bpy.context.active_object
@CGArtPython
CGArtPython / camera_track_empty_1.py
Created June 6, 2022 14:26
Beginner Blender Python Exercise: Track an empty with a camera https://youtu.be/uDtEkjbD_-g
# give Python access to Blender's functionality
import bpy
# create parameters
cube_count = 10
location_offset = 3
frame_count = 300
# set the end frame
bpy.context.scene.frame_end = frame_count
@CGArtPython
CGArtPython / camera_track_empty_2.py
Created June 13, 2022 00:28
Beginner Blender Python Exercise: Track an empty with a camera (part 2)
# give Python access to Blender's functionality
import bpy
def set_end_frame(frame_count):
"""set the end frame"""
bpy.context.scene.frame_end = frame_count
def set_fps(fps):
@CGArtPython
CGArtPython / deselect_faces.py
Created July 6, 2022 15:01
Blender Python script to deselect faces using thier index
# give Python access to Blender's mesh manipulation functionality
import bmesh
# give Python access to Blender's functionality
import bpy
# add cube
bpy.ops.mesh.primitive_cube_add()
obj = bpy.context.active_object
@CGArtPython
CGArtPython / deselect_verts.py
Created July 6, 2022 15:05
Blender Python script to deselect verts using thier index
# give Python access to Blender's mesh manipulation functionality
import bmesh
# give Python access to Blender's functionality
import bpy
# add cube
bpy.ops.mesh.primitive_cube_add()
obj = bpy.context.active_object
@CGArtPython
CGArtPython / hex_color_to_rgba.py
Last active January 11, 2024 21:52
A Blender Python script to convert HEX colors to Blender RGB; Video tutorial: https://www.youtube.com/watch?v=knc1CGBhJeU
# give Python access to Blender's functionality
import bpy
# extend Python's math functionality
import math
def hex_color_to_rgba(hex_color):
# remove the leading '#' symbol
hex_color = hex_color[1:]