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
# give Python access to Blender's functionality | |
import bpy | |
class VIEW3D_PT_my_rig_ui(bpy.types.Panel): | |
bl_space_type = 'VIEW_3D' | |
bl_region_type = 'UI' | |
bl_category = 'Item' | |
bl_label = "My Rig UI" | |
bl_idname = "VIEW3D_PT_rig_ui" |
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
""" | |
This script demonstrates how to align nodes in the Shader Editor using the built-in 'node_arrange' add-on in Blender. | |
Note: This is not the most optimal method as it relies on a bpy.ops call, but it is functional. | |
The script performs the following steps: | |
1. Checks if the 'node_arrange' add-on is enabled and enables it if it is not. | |
2. Defines a context manager to switch the area type to the Shader Editor. | |
3. Aligns the nodes of a specified material using the 'node_arrange' add-on. |
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
bl_info = { | |
"name": "File Logging Addon", | |
"description": "Creates a panel with three buttons that add a cube, cone, and sphere to the scene. Logs messages to a file.", | |
"author": "Viktor Stepanov", | |
"version": (0, 0, 1), | |
"blender": (4, 0, 0), | |
"location": "View3D", | |
"warning": "This addon is still in development.", | |
"wiki_url": "", | |
"category": "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
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 |
NewerOlder