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 | |
# give Python access to Blender's mesh editing functionality | |
import bmesh | |
# extend Python functionality to generate random numbers | |
import random | |
# import the Operator class from the bpy.types module |
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 | |
# Specify the material name | |
material_name = "ExportThisMaterial" | |
# Get the material from the current blend file | |
material = bpy.data.materials.get(material_name) | |
if material: | |
# add only the material to the blend new file |
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 the Blender Python API | |
def add_empties(): | |
empties = [] # Initialize an empty list to store the empty objects | |
for i in range(5): # Loop to create 5 empty objects | |
empty = bpy.data.objects.new(f"Empty_{i+1}", None) # Create a new empty object with a unique name | |
bpy.context.collection.objects.link(empty) # Link the empty object to the current collection | |
empties.append(empty) # Add the empty object to the list | |
return empties # Return the list of empty objects |
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 | |
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 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
""" | |
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 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
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 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 contextlib | |
import bpy | |
import bmesh | |
class Mode: | |
Edit = "EDIT_MESH" | |
Object = "OBJECT" |
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
# 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 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.from_edit_mesh(mesh_obj.data) | |
selected_verts = [vert for vert in bm.verts if vert.select] |
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) |