[maya] Scaling Rigs

We needed to scale a bunch of rigs and animations down in Maya, and had some success doing it by modifying the .ma text files directly. Thought I’d share this as I’m proud it actually worked, and haven’t seen this solution before.

It’s a straight forward process. There are about 25 different attribute types that define the final size of something in the .ma text, and you can literally scale those value as needed to adjust the size of a complete rig/mesh. There will be rig-type specific attributes that are harder to find, but in my case it was just one or two attributes that defined the default ik stretch length. It took about 5 days to find all the attributes, and figure out the correct regex patterns to catch them all. One thing I didn’t address was scaling the animation files. Those were easier to do in Maya, just by using the pm.scaleKey command. The animation curve tangents were a big puzzle to figure out, and in the end it was easier to scale in Maya instead of modifying the tangent text directly.

It was a bit of a time investment up front, but worth it if you have a large number of assets to bust through.

I’ve modified ma files directly before when having to make path changes on a large number of assets. It works nicely and is much faster than a script which loads them in maya and makes the changes there.

When reading your post I was thinking it may be useful to others if you shared the regex you used for modifying those “25 different attribute types” if you are able to?

The problem you were solving sounds to me like something I’d prefer to do in the exporter with a scale factor that could be passed in from script (assuming the reason for needing to scale was moving assets between game codebases or something similar).

What exporter are you using? I’m curious how you’d do it. We basically wanted the equivalent of “freeze/reset transforms”, so there would be no scale factor on any art. The regex patterns are relatively simple and all similar, like

find_me_radius = ‘setAttr “.r” (?P<nums>([0-9]|-|.|));’

would find anything like this:

setAttr “.r” -2.77;

then store the number, and a function would scale the number(s), and return the modified string as

setAttr “.r” -.0277;

or whatever the scale needed to be.