Skip to content

Instantly share code, notes, and snippets.

View RedForty's full-sized avatar
😸
Ship it

Daniel Klug RedForty

😸
Ship it
  • California
View GitHub Profile
@RedForty
RedForty / Custom GE colors
Created March 9, 2020 02:58
Sets my custom GE colors
# =========================================================================== #
# Custom GE colors
# List the currently defined custom curve colors
# curve_colors = cmds.curveRGBColor( list=True )
curve_colors = [ 'rotateZ 0 1 1'
, 'translateY 0 1 0'
, 'scaleZ 0.519899 0 0.965517'
, 'translateX 1 0 0'
, 'rotateY 1 1 0'
, 'scaleX 0.82 0 0.82'
@RedForty
RedForty / math_utils.py
Last active November 19, 2020 05:45
Lerp, Inv_lerp, remap
# Thank you Freya Holmer | Neat Corp
# https://youtu.be/NzjF1pdlK7Y
def lerp(a, b, t):
return ((1.0 - t) * a + b * t)
def inv_lerp(a, b, v):
return ((v - a) / (b - a))
def remap(iMin, iMax, oMin, oMax, v):
@RedForty
RedForty / distance_between_vectors.py
Created September 1, 2021 23:31
Get distance between two vectors
from math import pow, sqrt
def distance_between_vectors(a, b):
# Feed two vectors of type list3
# example: a = [0, 1, 2]
# Distance formula : ?((x2 - x1)2 + (y2 - y1)2 + (z2 - z1)2)
distance = sqrt(pow(a[0] - b[0], 2) + pow(a[1] - b[1], 2) + pow(a[2] - b[2], 2))
return distance
from maya import cmds
import maya.OpenMaya as om
import math
LOCATOR_NAME = '_loc'
def get_rotation_from_matrix(matrix_list, rot_order):
# Create an empty MMatrix:
mMatrix = om.MMatrix() # MMatrix
# And populate the MMatrix object with the matrix list data:
@RedForty
RedForty / select_constraint_source.py
Last active November 12, 2021 22:12
Select Source of Constrained Object
# Select source of selected constrained object
from maya import cmds
selection = cmds.ls(sl=1)
new_selection = []
for item in selection:
constraint = cmds.listConnections( item + '.parentInverseMatrix[0]', destination=1, source=0, type='constraint')
if constraint:
src = cmds.listConnections(constraint[0] + '.target[0].targetParentMatrix', destination=0, source=1)
if src:
@RedForty
RedForty / set_my_preferences.mel
Last active May 16, 2022 18:07
My preferred preferences in Maya
// My preferred prefences
// Interfaces
optionVar -intValue showHighlightNewFeaturesWindowOnStartup false;
whatsNewHighlight -showStartupDialog false;
// Manipulators
mouse -enableScrollWheel false;
optionVar -iv useMultiTouchGestures false; multiTouch -gestures false;
manipOptions -rememberActiveHandleAfterToolSwitch 0;
# ---------------------------------------------------------------------------- #
# This scriptjob will turn off the default material option on each viewport
from maya import cmds, mel
def turnOffDefaultMaterial(*args, **kwargs):
allIconTextCheckBoxes = cmds.lsUI( type=['iconTextCheckBox'],l=True )
for iconCheckBox in allIconTextCheckBoxes:
if 'UseDefaultMaterialBtn' in iconCheckBox:
cmds.iconTextCheckBox(iconCheckBox, e=True, value=False)
string $currentPanel = `getPanel -withFocus`;
int $state = `isolateSelect -q -state $currentPanel`;
if ($state) {
enableIsolateSelect $currentPanel false;
} else {
enableIsolateSelect $currentPanel true;
$allMeshObjs = `ls -typ mesh`;
for ($eachObject in $allMeshObjs) {
isolateSelect -addDagObject $eachObject $currentPanel;
}
@RedForty
RedForty / shelfBase.py
Created November 7, 2017 20:10 — forked from vshotarov/shelfBase.py
Maya base class for building custom shelves.
import maya.cmds as mc
def _null(*args):
pass
class _shelf():
'''A simple class to build shelves in maya. Since the build method is empty,
it should be extended by the derived class to build the necessary shelf elements.
import maya.api.OpenMaya as api
from functools import partial
def reportCallbackEventNames(c, *args):
print c
# install
cbs = api.MEventMessage.getEventNames()
installed_cbs = []
for c in cbs: