Skip to content

Instantly share code, notes, and snippets.

@coxevan
coxevan / convert_midi.py
Last active May 31, 2021 01:44
Python script that'll convert MIDI message strings to channel number (G#1 -> 44)
'''
Convert midi message into number
C-2 -> 0
G8 - 127
Supports Korg/Roland/synths with alternative starting octaves
* Example: In korg/roland synths, the low C is C-1(#0) and high G is G9(#127)
'''
import os.log
import Foundation
import PlaygroundSupport
let TREE = "#"
let SLOPES = [(1,1),
(3,1),
(5,1),
(7,1),
import pymel.core as pm
def delete_keys_on_sel():
selected = pm.selected()
if not selected:
return False
nodes_to_delete = []
for obj in selected:
import maya.cmds
PARTICLE_DEFAULT_NAME = 'spring_particle'
def setup_spring(obj, time_range = None, spring_weight = 0.5):
'''
Sets up spring physics system around a given object
:param obj: obj to apply physics system to
:param time_range: time range of animation to process, tuple
#Establish a bit of chaos
import random
#Establish a bit of order
LIGHT_GODS = True
DARK_GODS = False
DIVINE_MAP = {True: 'Light', False: 'Dark'}
CELESTIAL_ODDS = (-20, 20)
COMMANDMENTS_LIST = [ 'Praise be to the {divine_order} Gods, begin your quest on frame {offering}.',
'For the {divine_order} Gods looked down and saw the animation, and it started on frame {offering}. It was okay.' ]
'''
Utility methods for getting and setting reference properties ( aka - the blue properties ) in MotionBuilder.
'''
import pyfbsdk
def get_reference_property( obj, prop_name ):
'''
Gets a reference property from an object by name
@coxevan
coxevan / mobu_evaluate_decorator.py
Last active August 7, 2020 13:26
Gotcha Examples
def toggle_parallel_settings( func ):
def _wrapper( *args, **kwargs ):
# Store the initial values.
evaluate_manager = pyfbsdk.FBEvaluateManager()
p_evaluation = evaluate_manager.ParallelEvaluation
p_pipeline = evaluate_manager.ParallelPipeline
p_deformation = evaluate_manager.ParallelDeformation
# Turn them all off
evaluate_manager.ParallelEvaluation = False
import maya.cmds as cmds
def wireframeSwitcher():
# Get the viewport object
viewport = cmds.getPanel( withFocus = True)
# If there is a model panel...
if 'modelPanel' in viewport:
currentState = cmds.modelEditor( viewport, q = True, displayAppearance= True )
if currentState.lower() == 'wireframe':
cmds.modelEditor( viewport, edit = True, displayAppearance = 'smoothShaded' )
def applyBtnCmd(self, *args):
# Grab and check info from UI lists and scroll areas.
attributes_to_mirror_list = self.driverScroll.getSelectItem()
driven_object_attribute_list = self.objAttrScroll.getSelectItem()
if len(attributes_to_mirror_list) < 1:
cmds.warning( 'No attribute to mirror selected' )
return False
if len(driven_object_attribute_list) < 1:
import pymel.core
SKIN_CLUSTER_NAME = 'skinCluster1' # <-- Replace with 'name_of_my_skincluster' but keep the quotes!
# Get the skin cluster from the shape node
skin_cluster = pymel.core.PyNode(SKIN_CLUSTER_NAME)
# Get the objects associated with that skincluster (mostly bones)
influence_list = skin_cluster.influenceObjects()