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
""" | |
Functions for generating spline weights. | |
Usage: | |
This modules functions each take curve parameters and output control point weights. The weights are generated using | |
a modified version of de Boor's algorithm. These weights can be used to create a weighted sum to find a point or | |
tangent on a spline. | |
While these functions are written for usage in Autodesk Maya, they don't actually have any Maya-specific libraries. | |
Additionally none of these functions actually care about the data type of provided control points. This way these |
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
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; | |
} |
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 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) |
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
# 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: |
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
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: |
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
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 |
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
// 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 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
# 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): |
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
# =========================================================================== # | |
# 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' |
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 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: |
NewerOlder