This file contains 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 contextlib | |
import bpy | |
import bmesh | |
class Mode: | |
Edit = "EDIT_MESH" | |
Object = "OBJECT" |
This file contains 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
# name this file __init__.py | |
import bpy | |
ADDON_NAME = "My Diver Library" | |
bl_info = { | |
"name": "My Diver Library", | |
"author": "Viktor Stepanov", | |
"version": (0, 0, 1), |
This file contains 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.from_edit_mesh(mesh_obj.data) | |
selected_verts = [vert for vert in bm.verts if vert.select] |
This file contains 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 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 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 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 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 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 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" |
NewerOlder