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
# Method 1 | |
from pymel.core import * | |
slider = mel.eval('$tmpVar=$gPlayBackSlider') | |
sliderFrames = ''.join([c for c in timeControl(slider, q=1, rng=1) if c in '1234567890:']) | |
sliderStart = int(sliderFrames.split(":")[0]) | |
sliderEnd = int(sliderFrames.split(":")[1]) |
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 imp | |
util = imp.load_source('util', '/Users/eric/Google Drive/Macbook Sync/Maya Tools/shapes/CurveShape.py') |
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
#--------------------------------------------------------------------------------------# | |
# sharpen in tangent | |
import pymel.core as pm | |
pm.keyTangent(edit=True, weightLock=False, lock=False, inWeight=.01) | |
# sharpen out tangent | |
import pymel.core as pm | |
pm.keyTangent(edit=True, weightLock=False, lock=False, outWeight=.01) |
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
sel=pm.ls(sl=True) | |
print sel | |
curveList = pm.keyframe(q=True, sl=True, name=True) | |
print curveList | |
control_xform = pm.selected()[0] | |
curveList = control_xform.inputs() |
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
""" | |
Select Animated Nodes | |
Here’s a quick script I threw together today that will take your selection, check if any of the nodes have animation curves attached to them, and then deselect all the nodes that aren’t animated. Leaving you only with the nodes that are animated. I say nodes because it will keep any node in Maya you have intially selected whether it’d be a transform, a shape, or a nParticle node. So, be careful with your initial selection and you won’t have to worry about what you get out in the end. | |
""" | |
objs = mc.ls(sl=True,dag=True) | |
print objs | |
animated = [] | |
for obj in objs: | |
findAnimCurves = mc.listConnections(obj,source=True,type="animCurve") |
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 pymel.core as pm | |
sel = pm.ls(sl=True) | |
attr_path = '{0}.{1}'.format(sel[0], 'ty') | |
key_frames = pm.keyframe(attr_path, q=True) | |
key_values = pm.keyframe( attr_path, q=True, vc=True) | |
in_tangents = pm.keyTangent( attr_path, q=True, itt=True) | |
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
""" | |
http://blog.cameronleger.com/mel/keyrandomizer/ | |
MAYA KEYFRAME RANDOMIZER | |
This is a Maya python script used for randomizing keyframe values or times. When applied over a range, a different randomization will be applied to each attribute and each key for it. Using the GUI you can select what attributes to modify, whether to modify them in space and/or time, and the ranges for modification. First, copy&paste this into the script editor, select all of it, and save it to your shelf. Then, select the objects you want to adjust their keyframes and run the script. | |
The first two checkboxes are for space / time modification. Spatial Keyframes will modify attribute values for each keyframe. Temporal Keyframes will modify the frame that the keyframes are on. | |
Min / Max Randomness is the amount to be applied to each value. The amount is added, so 0-1 will only produce positive alterations and -1-0 will only produce negative alterations. The value is a floating point number, so 0-1 will always randomly choose a decima |
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
http://blog.cameronleger.com/mel/offsetkeys/ | |
MAYA ITERATIVE KEYFRAME OFFSETTER | |
This is a small MEL script to copy, paste, and offset keyframes iteratively on multiple objects. First, copy the keyframes from the first object. Then, select the rest of the objects to paste the animation to. The offset value is how many frames to offset the animation for each object. The start value is the frame the entire animation should start on. For each object selected in the order that they are selected, it pastes the animation offset by the amount you chose per each object. | |
To use this script, you should paste the following into the MEL section of the Script Window, and then execute the code. Or you could drag the selected code in the MEL tab to the Shelf to create a shelf item for it. | |
if ( `window -exists window` ) | |
deleteUI window; | |
window -title "keyOffset" window; |
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
function findEvenlyDivisibleScaling(animLength) { | |
var even_scales = []; | |
for(i=1; i<100; i++) { | |
var scale = animLength * (i * 0.01); | |
if(scale % 1 === 0) | |
{ | |
even_scales.push(i * 0.01); | |
} |
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
def testFunc( **kwargs ): | |
options = { 'option1' : 'default_value1', | |
'option2' : 'default_value2', | |
'option3' : 'default_value3', } | |
options.update(kwargs) | |
print options | |
testFunc( option1='new_value1', option3='new_value3' ) | |
# {'option2': 'default_value2', 'option3': 'new_value3', 'option1': 'new_value1'} | |
OlderNewer