This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
import bmesh | |
obj_name = "my_shape" | |
# create the mesh data | |
mesh_data = bpy.data.meshes.new(f"{obj_name}_data") | |
# create the mesh object using the mesh data | |
mesh_obj = bpy.data.objects.new(obj_name, mesh_data) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# downlaod and extract example image from there https://polyhaven.com/a/mud_cracked_dry_03 | |
import bpy | |
# set path to the folder where the texture is | |
image_folder_path = r'c:\path\to\your\textures' | |
# set the name of the displacement texture image | |
image_name = 'name_of_your_texture.png' | |
# load the image |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
import bmesh | |
# get a reference to the active object | |
mesh_obj = bpy.context.active_object | |
# create a new bmesh | |
bm = bmesh.new() | |
# initialize the bmesh data using the mesh data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
import bmesh | |
# get a reference to the active object | |
mesh_obj = bpy.context.active_object | |
# create a new bmesh and initialize it from mesh data in Edit Mode | |
bm = bmesh.from_edit_mesh(mesh_obj.data) | |
bmesh.ops.bevel( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
mesh_data = bpy.context.object.data | |
# Create a list with the same number of elements as the number of loops (so we can do this `new_loop_normals[loop_index]`) | |
new_loop_normals = [None for _ in mesh_data.loops] | |
for face in mesh_data.polygons: | |
for loop_index in face.loop_indices: | |
new_loop_normals[loop_index] = face.normal |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
bpy.ops.object.light_add(type='SUN') | |
light_obj = bpy.context.active_object | |
light.name = "light object name" | |
light.data.name = "light data name" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
See full tutorial video here: https://youtu.be/ZBvoMcqdRe4 | |
Note: set_up_world_sun_light() is avalible via the bpybb Python package. | |
https://github.com/CGArtPython/bpy_building_blocks | |
""" | |
import bpy | |
import math |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# give Python access to Blender's functionality | |
import bpy | |
# 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 | |
# insert keyframe at frame one | |
start_frame = 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
import bmesh | |
bpy.ops.mesh.primitive_cube_add() | |
cube_obj = bpy.context.active_object | |
bpy.ops.object.editmode_toggle() | |
bpy.ops.mesh.select_all(action="DESELECT") | |
bm = bmesh.from_edit_mesh(cube_obj.data) |