Hello all! I'm taking my first steps into MEL scripting for work, I've done things in other languages before but new to MEL. I only needed some basic stuff and it seemed as I was testing each line of this code separately, they all work fine, but I run the whole script and it seems to either do things in the wrong order or just ignores setting the pivot points to 0,0,0. Would anyone know why this is? And if so, how would I make these commands run in the order that they are in the script? Thanks!
EDIT:: Scratch that! I found that it's not setting the World Scale Pivot or Local Scale Pivot to 0. How would one do that?
//Selects everything in the scene
select -all;
//Sets pivots to 0
xform -ws -a -rp 0 0 0;
//Freezes all transforms to 0
performFreezeTransformations(0);
//Scales to 0.01 on all axis
scale -xyz 0.01 0.01 0.01;
//Freezes all transforms to 0
performFreezeTransformations(0);
Replies
xform -ws -a -piv 0 0 0;
the -piv does rotation and scale pivot in one go,
You should also be able to remove one of those Freeze Transformation commands by making your scale of .01 relative (ignoring current scale values). Assuming this is just to scale down all your models, I'd also recommend deleting history or you could get some funky results when transforming things you might have missed deleting history on; using a select -all command will also select history nodes.
Thanks for the suggestions Bartalon, I'll have to try things out and see what does what. At the moment the reason for this simple script is because most people where I work use Max and our game engine of choice is Unity, but I prefer models being clean and at the correct scale which is seemingly hard to do when going from Max to Unity. So I open up the .FBX and do this process quite regularly to make sure everything is at the right scale and no random rotations/pivot locations etc. They're all static assets so there's no worry of joints and history but I can imagine I'll need to look into it for another time.
I've even written a C# script for importing models in Unity for the first time setting scalefactor and material folder locations and other settings~ Automating as much as I can.
Thanks again for the help guys!