Useful Utilities
Introduction
Various, slightly organized collection of useful tools. Many thanks to those who have put these up.
Modeling
Lz Modeling Tools (luiz elias)
City generation (Brave rabbit)
Texturing
File Texture Manager
Rigging
Marco Giordano's
http://www.creativecrash.com/maya/downloads/scripts-plugins/character/c/mg_toolslite-and-pro-custom-nodes-for-maya-to-enhance-your-rigs
Renaming
Script that will search and replace duplicate node names in Maya?
Duplicate Check script on Creative Crash
http://www.creativecrash.com/maya/downloads/scripts-plugins/modeling/misc/c/duplicate-check
there is a method on MFnDependencyNode called "hasUniqueName". just
iterate over all dag nodes in the scene and ask whether it has a
unique name or not.
def iterNonUniqueNames():
iterNodes = MItDag() #NOTE: only dag objects can have non-unique
names... despite the fact that the hasUniqueName method lives on
MFnDependencyNode (wtf?!)
while not iterNodes.isDone():
mobject = iterNodes.currentItem()
if not MFnDependencyNode( mobject ).hasUniqueName():
yield mobject
iterNodes.next()
(Hamish Mckenzie)
Get rid of all namespaces
From Script Swell, "no questions asked"
Center a Joint in An Edge Loop
On Mel wiki here
//from otto leffler!
SelectEdgeLoopSp;
ConvertSelectionToVertices;
CreateCluster;
select -cl;
Reorder Attributes
Stephen Mann's Smart Reorder-er
Zhen's version (goes up AND down..)
Reset To Default Pose
"custom tools for a single-click character reset that places the control rig in the default pose." (TD Matt)
Traversing Hierarchy
Get the Top Node in a DAG chain, given its child
my first recursion! :)
def getTop(node):
topNode = ''
par = mc.listRelatives(node, p=True)
if par != None:
topNode = getTop(par)
node = par[0]
return topNode
else:
return node
(you can do this with one line of code actually, but then you don't get to use recursion..)
Delete Unnecessary 'Orig' Nodes
string $nodes[] = `ls -dag`;
string $obj;
for($obj in $nodes){
if(`gmatch $obj "*Orig*"`) {
//print($obj);
string $list[] = `listConnections $obj`;
if(size($list)==0){
delete $obj;
}
}
}
(Jeremy Raven)
Clusters
Change cluster orientation from world to local:
//from Jan Berger! bless!
// select a locator and then a mesh and then run this code
string $selection[] = `ls -sl -l `;
cluster -bs 1 -wn $selection[0] $selection[0] $selection[1] ;
Mirror Cluster Weights
Is there any good way to mirror the cluster weight just like thejoint's skincluster? i have wrote one but it's very slow and there aresome bugs, does anybody have a good solution?
have you tried looking at maya's mirror deformer weights?
( its in the bottom of the edit Deformers menu)
(s. mann)
Also, check this out:
http://www.creativecrash.com/maya/downloads/scripts-plugins/character/c/sl_mirrocluster--2
I tested it a little a long while back, and it seemed to do the trick.
(j. patrick)
Actually, here, we developed a mel script that converts weightedDeformers
weights into a skinCluster, then do the mirrors on this copy, then reconvert
the skinCluster weights into the deformer.
Quite fast, and reliable.
Should even be simpler to code and faster in pyhon.
Nicolas
Constraints
How to have two objects be constrained by each other?
Check out the bidirectional constraint from exotools. (C. Vernon)
Constraining object to Nurbs CV
http://www.tokeru.com/t/bin/view/Maya/MayaRigging#NURBS_Curve_CV
Constraining object to Nurbs Surface
pointOnSurface! pointOnSurfaceInfo!
Constraining object to Polygon Surface
http://www.tokeru.com/t/bin/view/Maya/MayaRigging#Polygon_Surface
(this just goes through how to do it with Maya Hair, but there are other ways..)
closestPointOnMesh!
Red9's Free Rigging/Animation Tools
link here
Joints
how would I find the angle between these two joints(see picture). so that I can rotate the second joint and it will align perfectly with the first joint? I want to find the long angle around.
Since you know the vector of the edge being shared by the faces, you can
use vector projection of the joint to find OA and OB. Then you can do acos(
dot( OA, OB ) ) to find the angle. you will need to do checks to see if you
want the long angle or the short angle. The check will be the same as the
check you are using for the joint orientation. Hope i make sense. :)
(J. Neo)
Sets
Manually add an object to deformer set
sets -add "wire2Set" "geo_mushroom_A3_wireTg";
import maya.cmds as mc
sel = mc.ls(sl=1)
for s in sel:
mc.sets(s, add="ffd10Set")
mc.sets(s, add="ffd1Set")
Pivots
Hide all the pivots you turned on earlier and don't remember what they belonged to
Select everything and run:
mc.toggle(state=False, rp=True)
mc.toggle(state=False, sp=True)
Make Parent Rotate Pivot follow Child
this gives me some pointers but its not enough to comprehend :D
http://prilisa.com/2012/01/rolling-egg-rig-v-2.html (sickiziu)
I appreciate your line of thinking, but I think you need to just measure
the distance from last frame and take the vector from that, then do your
rotation calculation. (R. O'Phelan)
Are you trying to avoid expressions?
I generally do it through making the wheel "face fwd" by aligning it along
the path that it just came from. Ie look 1 frame back to determine
direction Then use the distance between current an last points to
determine amount It traveled . Which becomes the distance for a wheel
rotation expression. (S. Mann)
Skinning
Animation
How to Benchmark the FPS during playback
Skeleton Pose tool--to use for updating the rig? Transfer animation from old rig onto skeleton, then back onto new rig?
Copy Animation Script
What's a good one?
PAIE - very easy to use:
http://www.creativecrash.com/maya/downloads/scripts-plugins/animation/c/paie
Playblast with different Animation Values
that allows you to enter a range of values for an attribute then playblast/cache for each variation based on those values so you can quickly see what value for your attribute works best?
If there is no tool for this available, can anyone give me some hints as to how to begin making one? I'm up for making a fairly involved, comprehensive tool.
(FluidEdge)
***
ok, so I have had some luck. What I wrote up last night is geared more towards multiple attributes, and a consistent "step" size and a start and stop number for each attribute.
An option to specify specific values would probably be beneficial too, so I'll mess with that next and see about a gui for it.
just copyPaste and run, it just prints it's current combination of values, but the print statement could easily be swapped out for a function such a playblast command that labels the playblast based on the current attribute values.
(Lucas Morgan)
#("attributeName", step, start, stop)
asd = [["pCube2.translateX", 1, 0, 10], ["pCube2.translateY", 2, 0, 10], ["pCube2.translateZ", 1, 0, 5], ["pCube2.somethingElse", .2, 0, 1]]
originalLen = len(asd)
origAsd = asd
backupAsd = []
whereAreWeStr = "Currently at : "
for item in asd:
backupAsd.append(item[2])
#This var tells the script whether or not to continue iterating on the same attribute, or to move to the next one.
amIfinished = 0
numOfAttr = range(len(asd))
curAttr = len(asd) - 1
#print numOfAttr
#print curAttr
while(amIfinished == 0):
for item in asd:
whereAreWeStr = whereAreWeStr + str(item[2]) + " : "
print whereAreWeStr
whereAreWeStr = "Currently at : "
if(originalLen == 1):
if((asd[numOfAttr[curAttr]][2] + asd[numOfAttr[curAttr]][1]) <= origAsd[numOfAttr[curAttr]][3]):
#print str(asd[numOfAttr[curAttr]][2]) + " of " + str(asd[numOfAttr[curAttr]][0])
asd[numOfAttr[curAttr]][2] = asd[numOfAttr[curAttr]][2] + asd[numOfAttr[curAttr]][1]
else:
amIfinished = 1
elif(curAttr == (len(asd) - 1)):
if((asd[numOfAttr[curAttr]][2] + asd[numOfAttr[curAttr]][1]) <= origAsd[numOfAttr[curAttr]][3]):
#print str(asd[numOfAttr[curAttr]][2]) + " of " + str(asd[numOfAttr[curAttr]][0])
asd[numOfAttr[curAttr]][2] = asd[numOfAttr[curAttr]][2] + asd[numOfAttr[curAttr]][1]
else:
asd[numOfAttr[curAttr]][2] = backupAsd[curAttr]
curAttr = curAttr - 1
elif(curAttr < (len(asd) - 1) and curAttr > 0):
#print str(asd[numOfAttr[curAttr]][2]) + " of " + str(asd[numOfAttr[curAttr]][0])
if((asd[numOfAttr[curAttr]][2] + asd[numOfAttr[curAttr]][1]) <= origAsd[numOfAttr[curAttr]][3]):
asd[numOfAttr[curAttr]][2] = asd[numOfAttr[curAttr]][2] + asd[numOfAttr[curAttr]][1]
curAttr = curAttr + 1
else:
asd[numOfAttr[curAttr]][2] = backupAsd[curAttr]
curAttr = curAttr - 1
elif(curAttr <= 0):
#print str(asd[numOfAttr[curAttr]][2]) + " of " + str(asd[numOfAttr[curAttr]][0])
if((asd[numOfAttr[curAttr]][2] + asd[numOfAttr[curAttr]][1]) <= origAsd[numOfAttr[curAttr]][3]):
asd[numOfAttr[curAttr]][2] = asd[numOfAttr[curAttr]][2] + asd[numOfAttr[curAttr]][1]
curAttr = len(asd) - 1
else:
amIfinished = 1
print "Finished"
Procedural Animaton
Growing Trees (Malcolm Kesson)
Interactive Fractal Modeler (Landon Gray)
GUI
Where is my outliner window???
// check that the outliner window exists
print (`windowPref -exists outlinerPanel1Window` + "\n");
// see where it is
print `windowPref -q -topLeftCorner outlinerPanel1Window`;
// bring it back to the topleft of the screen
window -e -topLeftCorner 50 50 outlinerPanel1Window;
(THNKR)
Hide Arnold Shape Attributes in GUI
Script is here
(Thanks to Stephen Mann)
General
PLAYBACK diagnostic--to tell you how long scene is taking to playback through a certain time period, so that you can use to see if something is making scene play more slowly. (like Son-san's old tool..)
utility to toggle between world and object space would be nice
utility to copy master shelf to local computers:
#!/usr/bin/env python
import subprocess
mayabin="/usr/autodesk/maya2009-x64/bin/maya"
safe_copy_scripts = subprocess.Popen("rsync %s %s" % (your, options),
shell=True)
check = safe_copy_scripts.wait()
if check != 0:
subprocess.Popen(mayabin, shell=True)
#end example
(stefan andersson)
Hotkeys That Will Make Your Life Better
Alt + B: toggle through background colors in the viewport
Ctrl + mmb: slide through an attribute in the channel box more slowly (since just mmb will slide through)
Scripting
This just came up, and maybe someone knows an answer.
you know how the script editor will keep the info saved in it from mayasession to maya session.
we thought saving prefs was a sure bet to keep that information ( as
sometimes you crash, and lose your script)
but apparently hitting the save prefs, does not save that info,
anyone know what is run to save that info out? its run when you close
maya...
thanks
-=s
erdinc May 24 07:57PM +0300 ^
savePrefs; // updates -- > ../prefs/userPrefs.mel
string $scriptEditor = `getPanel -wl "Script Editor"`;
removeScriptEditorPanel $scriptEditor; // updates -- > ../prefs/
scriptEditorTemp/"CommandExecuter" files
cool,
from that I was able to hunt down this...
syncExecuterBackupFiles();
which seems to do exactly, and only what I want.
thanks !
-=s
Rendering
Render Layer Get Info
Say I want to get the per render layer render frame range of all my different render layers (that have been set with overrides).
How can I do that *without actually changing currently active layer*, using Mel, Python or PythonAPI?
////////////////////////////
global proc renderLayerDiagnose()
{
int $currentLayer = `getAttr renderLayerManager.crl`;
string $renderLayers[] = `listConnections -destination 1 -source 0 -plugs 0 renderLayerManager.renderLayerId`;
for ($rl=0; $rl < `size($renderLayers)`; $rl++)
{
int $id = `getAttr ($renderLayers[$rl]+".identification")`;
if ($id == $currentLayer)
{
// do your own thing here....
// e.g. this block prints out the overrides that apply to the current layer
string $overrides[] = `listConnections -destination 0 -source 1 -plugs 1 ($renderLayers[$rl]+".adjs")`;
int $index, $overridesSize;
$overridesSize = `size($overrides)`;
if ($overridesSize!=0)
for ($index=0; $index < $overridesSize; $index++)
{
print ($overrides[$index] + “\t");
print `getAttr ($renderLayers[$rl]+”.adjs["+$index+"].value")`;
print “\n”;
}
else print ("No overrides on “+$renderLayers[$rl]+"\n");
}
}
}
///////////////////////////////////////
Owen
Mayastation
Jason Osipa's Free Maya Tools
Are here, on his website. which is a *real* wiki!
SOuP
What is the SOuP?
So I finally got around to trying SOuP after years of talking about it,
it's exactly what it says on the tin. Houdini SOPs in maya, implemented as
simply as they can possibly be within maya without changing maya itself.
There's not a lot of official docs, but between the massive collection of
examples they have, and blog posts, and video tutorials (and half
remembered Houdini techniques from 2 years ago), it definitely gives me
confidence to pitch on work in maya that I'd otherwise insist has to be
Houdini.
(M. Estela)
Hi Matt, welcome aboard.
A little bit of background info here - SOuP started as an effort to bring
some of Houdini's capabilities in Maya. I, like many other people got tired
of switching for and back between these two packages all the time.
Later on the project started morphing into something that was bigger in
scope than putting the few core nodes that form the backbone of Houdini's
procedural system into Maya. That evolution was initially based on my own
needs (coupled with the much bigger possibilities that the existing at the
time SOuP nodes allowed in Maya), the needs of the guys around me and later
in the game predominantly by the user base out there.
The SOuP project grew much bigger than (i at least ever) expected and
regardless of how one spins it the workflow is demanding. It requires
significant technical background. As a result many people are struggling to
get in for real. The lack of good centralized documentation does not help
the situation.
Hopefully at some point in the near future we will get comprehensive
documentation in place, as Sachin hinted. There is a small group of people
spending time on that.
(P. Shipkov)
Welcome aboard Matt! Please head to soup-dev.com and let me know your
handle on the forums. There will be some improvements to the docs but it
might take some time. Until then keep popping questions on the forums.
Cheers,
Sachin