This is a simple plug-in command to copy skin weights from one object to another with some significant restrictions:
- The meshes must be exactly mirrors of each other vertex-number wise. This plugin simply uses the vertex numbers of the mesh so each vertex of object A must have a corresponding vertex on object B.
- The joint names must be somehow side-differentiated e.g. L_joint and R_joint or left_side_arm_JNT and right_side_arm_JNT or you must somehow be able to map one side of joint names to the other.
This has mostly been useful when dealing with hands, you skin one and then you have to copy the weights over, but sometimes maya does a lousy job. This plug-in is pretty much like going in the component editor and copying each value for each vertex between meshes (which would be insane to do by hand).
Note: this is not a very fast script (I was trying to learn the Maya API while writing this) so give it some time to work through dense meshes.
If you have questions or comments just either send me an email or comment below.
- Select the object with the correct weights.
- Select the object with the incorrect weights.
- Run the command e.g. ‘sjtCopySkinWeights -s “L_” -r “R_”‘
This command accepts two arguments -search/-s and -replace/-r and each argument requires a string to follow it that tells the plugin how to map the right joint names to the left ones. Yes it works kind of backwards. The command first constructs a list of all the influences on the first object, then it goes over every vertex on the other object and tries to map it’s influences to the ones in the influence-list from the first object.
On one side the joints are called L_….._JNT and the other R_……_JNT the proper arguments for this command to work would be (MEL syntax):
sjtCopySkinWeights -s "L_" -r "R_"
(if no arguments are givien, this is the default search pattern)
This would also have worked (since the search strings can be regular expressions):
sjtCopySkinWeights -s "L_" -r "^[rR]_"
This would allow the right side joints to be named either R_…._JNT or r_…._JNT Just remember the regular expression should go with the -r flag, the -s flag is just used to replace the match from the -r flag with.
To test the command immediately you can load up th test file included in the zip download ‘copyWeights_example.ma’. First try scrubbing in the timeline to see the difference in weighting. The right side (pCube1) bends in the middle but the left side(pCube2) does not. To copy the weights from pCube1 to pCube2 first load the plugin, select pCube1 then pCube2 and type (MEL syntax):
into the command line (or script editor) and then the weights will have been copied from pCube1 to pCube2. Voila.
This is a tiny snippet I threw together today to speed up selecting the object that was controlling my selected object. In this case the object that was being controlled was a curve, but the constraining object (controlling the curve) was an invisible transform node, so instead of going through the hypergraph I wrote this:
import maya.cmds as mc
selection = mc.ls(sl=1)
toSelect = 
for item in selection:
constraint = mc.listConnections( item+'.parentInverseMatrix', d=1, s=0,type='constraint')
constraint = constraint
src = mc.listConnections(constraint+'.target.targetParentMatrix', d=0, s=1)
Note: this allows you to select multiple constrained objects and this will try and find the driving objects, this does not handle multiple constraints or anything fancy like that. Enjoy
Well, this place sure has been quiet for the last few months. Might have something to do with having a 14 month old son coupled with working on Thor.
Recently I’ve mostly been making some handy tools for Maya. One thing I learned is that if you playblast from maya using the x264 codec you simply need to remux the file and package it in an mp4 container and then you got yourself a nice quicktime-playing h264 playblast. Very handy stuff.
Busy times. Who knows when i’ll post something again. The supsense is probably unbearable.
As always you can catch my slighly more frequent posts on twitter.
Here’s a little mel snippet that I found occasionally useful while animating, all these commands do is add (or subtract) 360 from a keyframe value – which is perfect for those rotational values that need to come down (or go up).
Anyway, to add 360 degrees:
keyframe -e -r -vc 360;
Subtract 360 degrees:
keyframe -e -r -vc -360;
I’ve found this useful in certain cases (gimbal lock?). And hopefully someone can find this useful as well.
While I was making friends? I wrote some useful maya scripts that did all sorts of tedious things (like creating 100 bend deformers and controlling them with one control and a dash of randomness). I’ve decided to put some of those scripts online and you can find them on the new Maya scripts page ( there only two there right now ).
Some of those scripts are written in Python, some in Mel, although I do like Python way more then Mel (somehow using backticks as an integral part of a programming language doesn’t strike me as a good idea).
Just a little Maya tip here if you have Maya 8.5 or later.
If you need to make some calculations and don’t want to go find your calculator of choice you can use Maya to calculate stuff for you. First, make sure you have python active in the command line (bottom left text field).
If it says MEL, just click it and it should switch to Python
Then you just type in what you want calculated, for example if you type in “4+4″ and then hit control-enter, then the results pops up in the command response window. Easy.
To use Python as your calculator you have to remember that if you are using division remember to type the number you want to divide as a decimal number (like 5.0 instead of 5) otherwise you’ll get a rounded down result. 5/2 gives you 2 and 5.0/2 gives you 2.5. This obviously doesn’t matter if you are adding, multiplying or subtracting.
Well, it’s been pretty quiet around here for the last couple of weeks (months?) but now something happens; a new mel script.
sjtNotes is a supersimple script that simply allows you to have some notes inside your scene that are saved along with your scene file. The script is ridiculously simple and opens this window:
Then you type your notes and hit “Save & close” and then run the script again and edit those notes and again save and close. You get the drift …
Anyway, here’s the link to this awesome script:
If there is anything wrong with this script or you actually can use this then please let me know.
In other news I’m just busy working on my demo reel at VFS mostly spending my time rigging and learning stuff about maya that I didn’t know, like the deformation order, which I like a lot and has saved my ass on one occasion. Oh, and I’m dabbling with RenderMan, it. is. awesome. (so far at least).
For those who have used XSI for anything have most likely encountered the very useful “Match translation” tool (and it’s variants). This tool exists in Maya but according to some it doesn’t work very well especially when within a hierarchy. So a solution was to constrain the object you want to move to the object that we want to match the translation to and then, in the outliner, delete the constraint.
This obviously is very tedious especially if you want to this many times. So I decided to try creating my first mel scripts and created a set of scripts in a custom shelf that do this automatically. Here is the “Match translation” script:
$nodes = `selectedNodes`;
pointConstraint -name tmpconstraint -offset 0 0 0 -weight 1;
select -r tmpconstraint;
This script simply automates the steps listed above and the other variants (translation+orientation, orientation, scale) all work in almost the same way.
These scripts work like this: you first pick the object that you want to match the translation to and second select the object you want to move and then hit one of the shelf buttons. Simple right?
I like to use these script as marking menus and on that note I was thinking about creating a tutorial that shows how to add custom marking menus, since I guess that some people simply don’t know how to do that (but many of you do). That tutorial will hopefully be up soon.
Anyway, you can find the script here and to install it you simply place it in
/Users//Library/Preferences/Autodesk/maya/8.5/prefs/shelves (on a mac)
and I can’t remember where to place it on other platforms.