Call for Submission
NAB 2012 Best of the Best Show Reel
Submit your work today!
  • 1/3
You are here: Forum Home / Autodesk® Maya® / MEL / HELP: FreezeTransformations is moving my geo??
  RSS 2.0 ATOM  

HELP: FreezeTransformations is moving my geo??
Rate this thread
 
36689
 
Permlink of this thread   Subscribe to this thread
avatar
  • niic
  • Posted: 14 November 2009 06:18 AM
  • Total Posts: 12
  • Joined: 29 July 2007 12:43 PM

Hi all,

I am wondering why the difference between running FreezeTransformations; by itself as opposed to in a script.

select -r Head_CTRL;
FreezeTransformations;

If I run the above by itself in the script editor it works perfectly. It will as expected zero out my transform attributes which is what I want. However if I run it within my script it moves my geo to grid origin and leaves the pivot point snapped to my joint. Not what I want!

Below is a small snippet which is attached to a button in a gui. All I want to do is create a curve, snap it to my joint and delete the constraint, and finally freeze the transforms.

proc BipedHeadSetup() 
{
 
// Create FK Controller
 
curve -"Head_CTRL" -d 3 -p 0 .1 -1.4 -p 1.488862 .2 0  -p 0 0 1.3 -p 1.488862 -.1 0 -p 0 -.1 -1.4 --1.488862 -.1 0 -p 0 0 1.3 --1.488862 .2 0 -k 0 -k 0 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 5 -k 5;
 
closeCurve -ch 1 -ps 0 -rpo 1 -bb 0.5 -bki 0 -p 0.1;
 
 
delete `parentConstraint-skipRotate x -skipRotate y -skipRotate z "spineG" "Head_CTRL"`;

 
select -r Head_CTRL;
 
FreezeTransformations;
}

I turned on Echo all commands and found Maya loads in performFreezeTransformations.mel but this still doesn’t tell me why it is moving the geo instead of freezing my attributes.

Any help in why Maya executes the FreezeTransformations command differently in a script as opposed to by itself would be greatly appreciated.

Thanks,
Nick.



Replies: 0
avatar

have you tried this command ?

makeIdentity -apply true -t 1 -r 1 -s 1 -n 0;


Replies: 0
avatar
  • niic
  • Posted: 16 November 2009 12:53 AM

Yep tried that… that’s the result of the FreezeTransformations procedure. I also found where Maya calls in that global proc and loads it from the performFreezeTransformations.mel in Program Files/Autodesk/Maya2009/Scripts etc.

It doesn’t make sense why a Freeze Transforms moves the actual geo and why when I run the exact same code in my script it acts differently as to when I run it by itself in the editor.

Any help would be awesome!

Cheers
Nick.



Replies: 0
avatar
  • samavan
  • Posted: 16 November 2009 02:53 PM

yeah it will move your object if some components are locked/



Portfolio_small.png

Replies: 0
avatar
  • niic
  • Posted: 18 November 2009 03:40 AM

Hey mate,

...but my curve has nothing locked? The code above is everything that is being compiled. Simply create curve, parentConstrain to joint, delete constraint, Freeze Attributes. That is all I am trying to achieve.

Why does it work if I use FreezeTransformations by itself in the script editor but when I incorporate it into my script it doesn’t. I don’t understand why it is moving my geo in one instance and freezing in another. I am totally lost at what is going!

Cheers
Nick.



Replies: 0
avatar
  • samavan
  • Posted: 18 November 2009 03:04 PM

oh yeah maybe I understand your problem I got the same when doing a manipulator tools.

First important point is to replace the parent function and to do that in this way if you want to positionnate an object on another one :
(NOTE : It will create and delete the constraint at the same time)

delete `pointConstraint -offset 0 0 0 -weight 1 $objectA $objectB`;
delete `orientConstraint -offset 0 0 0 -weight 1 $objectA $objectB`;

About getting the {0,0,0} coordinate for a manipulator (for a skeleton setup ^_^).
Hmmm I also got some problem with that…
To tell the truth you cannot freeze your manipulator and then constraint a bone to this same manipulator because you are “reseting” the transform of your object!…
.... And thsi is very bad in the hiearchy of a skeleton setup.

---> The solution is to add a simple “group” before your manipulator. <---

1 - You create an empty group and positionnate it on your bone with the command I gave on the top.
And you !!! KEEP !!! the right coordinate, do not do a freeze on it.

string $grp = `group -em -n ($shortName + "new group")`;

=======

2 - You create your Head manipulator.
3 - you launch the same previous function to positionnate your manipulator on your bone (delete it at the same time).
4 - you parent the manipulator to the group
5 - you freeze the manipulator and it will resent the component translation, rotationm and scale of your object to ZERO.

=======

6 - you launch a 3rd time the same function I gave but you will constraint the BONE to the CONTROLLER!
(but ou DO NOT delete the constraints this time :D )

======

Conclusion :

Your bones wil not change of position.
Because the controler constraint the bone…
BUT!!!
The controler is child of the group with the right transform....

My english is not very well, but I hope you will understand the technical explanation… o_<

Here is the code fro creating a right manipulator with your curve.
Please note you need to select your bones before to launch the script :

string $selection [] = `ls -sl -l`;

BipedHeadManipulator ($selection[0])


global proc string BipedHeadManipulator (string $bone) 
{

 
// To get the shortname :
 
 
string $temp[] stringToStringArray ($bone"|")
 string $shortName 
$temp[`size $temp` -1];
 
 
// Create FK Controller

 
string $ctrl = `curve -n "Head_CTRL" -d 3 
 -p 0 .1 -1.4 
 -p 1.488862 .2 0  
 -p 0 0 1.3 
 -p 1.488862 -.1 0 
 -p 0 -.1 -1.4 
 -p -1.488862 -.1 0 
 -p 0 0 1.3 
 -p -1.488862 .2 0 
 -k 0 -k 0 -k 0 -k 1 -k 2 -k 3 -k 4 -k 5 -k 5 -k 5
`;

 
closeCurve -ch 1 -ps 0 -rpo 1 -bb 0.5 -bki 0 -p 0.1 $ctrl;

// TO create the Rigging :

 
delete `pointConstraint -offset 0 0 0 -weight 1 $bone $ctrl`;
 
delete `orientConstraint -offset 0 0 0 -weight 1 $bone $ctrl`;
 

 
string $grp = `group -em -n ($shortName + "_Grp")`;

 
delete `pointConstraint -offset 0 0 0 -weight 1 $bone $grp`;
 
delete `orientConstraint -offset 0 0 0 -weight 1 $bone $grp`;

 
string $ctrlBis[] = `parent $ctrl $grp`;

 
pointConstraint -offset 0 0 0 -weight 1 $ctrlBis[0] $bone;
 
orientConstraint -offset 0 0 0 -weight 1 $ctrlBis[0] $bone;


 return 
$ctrl;
}

At the end you will get a warning but this is about you curve… Then good luck ^_^

// Warning: line 27: History will be off for the command since Keep Originals is off and a selected item has no history. //


Portfolio_small.png

Replies: 0




   
  Settings Choose Theme color: