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 | |
class OBJECT_OT_FlipColorRamp(bpy.types.Operator): | |
"""Flip Color Ramp Elements""" | |
bl_idname = "object.flip_color_ramp" | |
bl_label = "Flip Color Ramp" | |
bl_options = {'REGISTER', 'UNDO'} | |
def execute(self, context): | |
try: |
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
"""prerequisite: you have a group node in the compositor, and inside the group node you have a Blur node"" | |
import bpy | |
tree = bpy.context.scene.node_tree | |
driver = tree.nodes['Group'].node_tree.nodes['Blur'].driver_add("size_y").driver | |
driver.type = 'AVERAGE' |
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 pathlib | |
import bpy | |
def find_user_asset_dir(): | |
user_lib_index = bpy.context.preferences.filepaths.asset_libraries.find("User Library") | |
if user_lib_index == -1: | |
return None | |
user_asset_lib = bpy.context.preferences.filepaths.asset_libraries[user_lib_index] |
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 | |
class SimpleImportFBXOperator(bpy.types.Operator): | |
bl_idname = "import_scene.custom_fbx" | |
bl_label = "Import FBX Model" | |
def execute(self, context): | |
# WARNING: This is just an example path, please don't use hardcoded paths in production add-ons! | |
# Consider this more advanced solution https://gist.github.com/CGArtPython/f2b3759e27ba1b0eca112c528ebdf1c9 |
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 | |
def copy_drivers(): | |
# Get the active object (the one with the drivers to copy) | |
source_obj = bpy.context.active_object | |
print(f"Active object: {source_obj.name}") | |
if not source_obj.animation_data or not source_obj.animation_data.drivers: | |
print("No drivers found on the active object.") | |
return |
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 random | |
import bpy | |
# Define a custom property group for our list items | |
class MyItem(bpy.types.PropertyGroup): | |
name: bpy.props.StringProperty(name="Item Name", default="New Item") | |
number: bpy.props.IntProperty(name="Item Number", default=0) |
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 | |
import mathutils | |
# Dictionary to store previous object positions and velocities | |
prev_positions = {} | |
velocities = {} | |
velocity_decay = 0.90 # Reduce velocity by 10% each iteration |
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 | |
def select_an_edge_every_2_seconds(): | |
obj = bpy.context.object.data | |
bm = bmesh.from_edit_mesh(obj) | |
bm.edges.ensure_lookup_table() | |
not_selected_edges = [] |
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 | |
def add_icosphere(): | |
bpy.ops.mesh.primitive_ico_sphere_add() | |
return bpy.context.active_object | |
def add_empty(): | |
bpy.ops.object.empty_add() | |
return bpy.context.active_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 bpy | |
bpy.ops.mesh.primitive_ico_sphere_add() | |
ico_sphere_obj = bpy.context.active_object | |
bpy.ops.object.empty_add() | |
empty_obj = bpy.context.active_object | |
driver_fcurve_obj = ico_sphere_obj.driver_add("location", 0) |
NewerOlder