defineDevPath.py
Apr 1, 2017 - The pymel version of the ls-command seems to ignore the long parameter, while the maya.cmds version works correctly: import m.
import sys |
devPath ='/Users/ev/Documents/projects/maya/' |
if devPath notin sys.path: sys.path.insert(0, devPath) |
for path in sys.path: |
print path |
fromRGB.multiSnap.multiSnap import MultiSnap_ui |
currentClassPath = sys.modules[MultiSnap_ui.__module__] |
ev_utils.py
'' |
Simply creates a locator at each selected object |
'' |
import maya.cmds as cmds |
nodes = cmds.ls(sl=True, type='transform') |
for node in nodes: |
pos = cmds.xform(node, q=True, t=True, ws=True) |
loc = cmds.spaceLocator() |
cmds.xform(loc, t=pos) |
print('%s => %s'% (node, loc, pos)) |
# Create Select Command |
import maya.cmds as cmds |
nodes = cmds.ls(sl=True, type='transform') |
print('cmds.select(%s, r=True)'% (nodes)) |
#Open New Maya |
from subprocess import call |
appPath ='/Applications/Autodesk/maya2014/Maya.app' |
call(['open -n '+ appPath], shell=True) |
# Scale Given objects by value |
import maya.cmds as cmds |
defscaleMult(objs, mult): |
sMtx = cmds.xform(objs,q=True, r=True, scale=True) |
x = sMtx[0] * mult |
y = sMtx[1] * mult |
z = sMtx[2] * mult |
cmds.xform(objs, scale=(x, y, z)) |
scaleMult('RRM_MAIN', 0.01) |
# Return frame data |
import maya.cmds as cmds |
import maya.mel as mel |
defget_fdata(): |
aPlayBackSliderPython = mel.eval('$tmpVar=$gPlayBackSlider') |
selection = cmds.ls(sl=True) |
selectionActvive = cmds.timeControl(aPlayBackSliderPython, query=True, rangeVisible=True) |
range= cmds.timeControl(aPlayBackSliderPython, query=True, rangeArray=True) |
fdata = {} |
fdata['f'] = cmds.currentTime( query=True ) |
fdata['fs'] = cmds.playbackOptions(query=True, min=True) |
fdata['fe'] = cmds.playbackOptions(query=True, max=True) |
fdata['sf'] = selectionActvive |
fdata['sfs'] =range[0] |
fdata['sfe'] =range[1] |
return fdata |
import maya.cmds as cmds |
defgetSelectedChannels() |
return cmds.channelBox('mainChannelBox', q=True, sma=True) |
frame_selectedPaintWeightsInfluences.py
# Frame Selected PaintWeight Influences |
import maya.cmds as cmds |
curSel = cmds.ls(selection=True) |
pwSelectedInfluences = maya.mel.eval('$temp=$gArtSkinOrderedInfluenceSelectionList') |
cmds.select(pwSelectedInfluences, r=True) |
cmds.viewFit() |
cmds.select(curSel, r=True) |
frameSelect.mel
FrameSelected; |
fitPanel -selected; |
animView -startTime (`playbackOptions -query -minTime` - 1) -endTime (`playbackOptions -query -maxTime` + 1) graphEditor1GraphEd; |
frameSelect.py
# Frame Curve Editor |
defframeGraphEditor(): |
fs = cmds.playbackOptions(q=True, minTime=True) -1 |
fe = cmds.playbackOptions(q=True, maxTime=True) +1 |
cmds.animView('graphEditor1GraphEd', startTime= fs, endTime= fe) |
insertKey.mel
global proc gecco_insertKey () { |
string $curves[] = `keyframe -q -sl -name`; // get all selected curves |
float $time = `currentTime -q`; // get the current frame |
for($i=0; $i < size($curves); $i++) { |
setKeyframe -insert -time $time $curves[$i]; |
} |
} |
insertKey.py
# Replaces 'Add Key' functionality with more desired insertKey |
import maya.cmds as cmds |
definsertKey (): |
curFrame = cmds.currentTime(query=True) |
curves = cmds.keyframe(query=True, sl=True, name=True) or [] |
unkeyed = [] |
# If no keys/curves selected in graph editor, look to channel box selection |
iflen(curves) 0: |
objs = cmds.channelBox('mainChannelBox', query=True, mainObjectList=True) or [] |
attrs = cmds.channelBox('mainChannelBox', query=True, sma=True) or [] |
for obj in objs: |
for attr in attrs: |
attrFull = obj+'.'+attr |
keyCount = cmds.keyframe(attrFull, query=True, keyframeCount=True ) |
if keyCount > f: |
curves.append(attrFull) |
else: |
unkeyed.append(attrFull) |
# Insert Key on curves with existing keys. |
iflen(curves) >0: |
cmds.setKeyframe(curves, insert=True, time=curFrame) |
# Add key on attributes with no keys |
iflen(unkeyed) >0: |
cmds.setKeyframe(unkeyed, time=curFrame) |
![Maya Python Ls Maya Python Ls](http://zurbrigg.com/images/training/beginning_python_for_maya_teaser.png)
poly2icon.py
'' |
This script generates a nurbs curve object, from a given polygon object's edges |
# Examples |
## A) Entering Data Manually |
poly2icon('myPolyObject', 'myNewIcon') |
## B) Using first-selected object and prompting user for icon name |
obj = cmds.ls(sl=True)[0] |
poly2icon(obj, prompt4name()) |
'' |
import maya.cmds as cmds |
defprompt4name(): |
result = cmds.promptDialog( |
title='Name Your New Object', |
message='Enter Name:', |
button=['OK', 'Cancel'], |
defaultButton='OK', |
cancelButton='Cancel', |
dismissString='Cancel') |
if result 'OK': |
return cmds.promptDialog(query=True, text=True) |
defpoly2icon(geom, newName): |
name ='' |
crvs = [] |
shapes = [] |
edgeCount = cmds.polyEvaluate(geom, edge=True) |
objPivots = cmds.xform(geom, q=True, rp=True, ws=True) |
# Create linear curves from edges |
for idx inrange(0, edgeCount): |
edge ='%s.e[%s]'% (geom, idx) |
crv = cmds.polyToCurve(edge, form=0, degree=1)[0]; |
crvs.append(crv) |
shape = cmds.listRelatives(crv, shapes=True) |
shapes.append(shape) |
# Parent all shapes under first shape |
if idx >0: |
cmds.parent(shape, crvs[0], relative=True, shape=True) |
name = crvs[0] |
# Remove Useless Transform Nodes |
for idx inrange(1, edgeCount): |
cmds.delete(crvs[idx]) |
# Match Geom Pivot |
cmds.xform(name, pivots=objPivots) |
# Delete History |
cmds.delete(name, ch=True) |
# Name Object |
if newName !='': |
cmds.rename(name, newName) |
name = newName |
return name; |
RRM_utils.py
'' |
This fixes a RRM bug (v1.4.7) where saved RRM setups do not preserve a |
module's 'pinned' status. |
'' |
import maya.cmds as cmds |
import maya.mel |
defRRM_fixPinBug(objs): |
for obj in objs: |
trans = cmds.xform(obj,q=True, r=True, translation=True) |
maya.mel.eval('RRM_PinProxies(1, 0);') |
cmds.xform(obj, translation=trans) |
maya.mel.eval('RRM_PinProxies(0, 1);') |
#Example Usage |
objs = cmds.ls( selection=True ) |
RRM_fixPinBug(objs) |
'' |
This prints out a list of each RRM module which are currently pinned |
'' |
# Check Pinned Status |
import maya.cmds as cmds |
import maya.mel |
defRRM_selectParents(): |
parents = cmds.ls( 'RRM*Parent' ) |
for obj in parents: |
val = cmds.getAttr(obj +'.pinned') |
print('%s : %s') % (obj, val) |
RRM_selectParents() |
timeSlider_undoIgnore.mel
// Timeslider |
timeControl -edit -pressCommand 'undoInfo -stateWithoutFlush off;' -releaseCommand 'undoInfo -stateWithoutFlush on;' $gPlayBackSlider |
// Hotkeys |
// http://www.ricardoayasta.com/2012/02/stop-undo-ing-scrub-time-slider-in-maya.html |
// Next Frame (Alt + .) |
undoInfo -stateWithoutFlush off; |
currentTime ( `currentTime -q` + 1 ); |
undoInfo -stateWithoutFlush on; |
// Previous frame (Alt + ,) |
undoInfo -stateWithoutFlush off; |
currentTime ( `currentTime -q` - 1 ); |
undoInfo -stateWithoutFlush on; |
// Next Key (.) |
undoInfo -stateWithoutFlush off; |
currentTime -edit `findKeyframe -timeSlider -which next`; |
undoInfo -stateWithoutFlush on; |
// Previous Key (,) |
undoInfo -stateWithoutFlush off; |
currentTime -edit `findKeyframe -timeSlider -which previous`; |
undoInfo -stateWithoutFlush on; |
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment