Skip to content

Instantly share code, notes, and snippets.

@p2or
p2or / blender-pie-subsurf-utils.py
Last active May 21, 2023 19:15
Subsurf Utils #Blender
# for https://blender.stackexchange.com/q/46848/3710
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
@p2or
p2or / nuke-batch-converter.py
Last active May 21, 2023 18:29
Batch Converter #Nuke
import os
file_prefix = None # If set to None read node file path is used
color_space = None # Read node colorspace "sRGB", "Cineon", "Gamma2.4" ...
file_types = ("exr", "jpg") # Set of file types to convert
rotate = False # If set to True, another reformat node will be created
rotation_props = ("center", "turn") # clockwise: ("flip", "flop", "turn")
selection = nuke.selectedNodes()
@p2or
p2or / blender-groups-by-materials.py
Last active May 21, 2023 19:14
Groups by materials #Blender
import bpy
data = {}
for obj in bpy.data.objects: # bpy.context.selected_objects
mat_slots = obj.material_slots.keys()
if mat_slots:
data_key = "-".join(mat_slots)
else:
data_key = "None"
data.setdefault(data_key, []).append(obj)
@p2or
p2or / blender-groups-by-vert-count.py
Last active May 21, 2023 19:14
Groups by Vert count #Blender
import bpy
data = {}
for obj in bpy.data.objects: # bpy.context.selected_objects
if obj.type == 'MESH':
data.setdefault(len(obj.data.vertices), []).append(obj)
for key, value in data.items():
group_name = "{} Vertices".format(key)
@p2or
p2or / blender-open-user-prefs-and-expand-addon.py
Created February 4, 2018 19:43
Open UserPrefs and expand #Blender #BSE
import bpy
import addon_utils
# Set Addon Tab
bpy.context.user_preferences.active_section = 'ADDONS'
# Set Filter
bpy.context.window_manager.addon_search = "Addon Name"
# Get a module reference by name
@p2or
p2or / blender-add-nodes-and-frame-them.py
Last active May 21, 2023 19:14
Add nodes and frame them #Blender
#https://blender.stackexchange.com/q/99989/3710
import bpy
class FrameSelection(bpy.types.Operator):
"""Add a frame to all selected Nodes"""
bl_idname = "node.frame_selection"
bl_label = "Add Frame"
bl_options = {'REGISTER', 'UNDO'}
@p2or
p2or / blender-sequence-bakery.py
Last active February 3, 2024 12:20
Extended version of Animated Render Baker #Blender
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
@p2or
p2or / premult-exr-psd.nk
Last active May 22, 2023 12:49 — forked from julik/unpremult.jsx
Unpremultiply the selected Photoshop layer #Nuke
set cut_paste_input [stack 0]
version 11.0 v1
Read {
inputs 0
file Untitled-1.psd
format "3881 1081 0 0 3881 1081 1 "
origset true
name Read6
selected true
xpos 1335
@p2or
p2or / blender-merge-vertex-groups-jerryno.py
Created August 25, 2017 10:15
Merge-VertexGroups (jerryno) #Blender
import bpy
vgroup_A_name = "Group"
vgroup_B_name = "Group.001"
ob = bpy.context.active_object
if vgroup_A_name and vgroup_B_name in ob.vertex_groups:
vgroup = ob.vertex_groups.new(name=vgroup_A_name+"+"+vgroup_B_name)
@p2or
p2or / blender-merge-vertex-groups.py
Last active October 24, 2023 14:50
Merge Vertex Groups #Blender
import bpy
group_input = {"Group", "Group.001", "Group.002"}
ob = bpy.context.active_object
group_lookup = {g.index: g.name for g in ob.vertex_groups}
group_candidates = {n for n in group_lookup.values() if n in group_input}
# test whether all candidates components of group_lookup
if all(n in group_lookup.values() for n in group_candidates):