Maya MEL script

Maya MEL script

kimjinwonC42YB
Explorer Explorer
454 Views
1 Reply
Message 1 of 2

Maya MEL script

kimjinwonC42YB
Explorer
Explorer

Hello

I'm going to make a script that adds a specific number to the rotation value z

that Controller a has. I made a script as below. An error has occurred.

 

After this script,

I want to bake that controller to run that script on all frames within the range of the Timeslider.

I kept trying with insufficient knowledge,

but I couldn't get good results. I need your help. Thank you.

 

캡처.PNG

455 Views
1 Reply
Reply (1)
Message 2 of 2

dinofiguera
Collaborator
Collaborator

Hey Man, I am really sorry. I wrote a very long description explaining to you how to write this script.
But after I tried to edit it, it got lost and It would take me too long to write it again.
So I only post you the script and I'm sure you will figure it out.

this script works on every object selected, and runs through the range slider assigning a pre-defined 
value to the Z rotation at each frame. The rotate attribute will also be baked during the process.

 

float $newValue = 8.5;
//rotation value
string $attribute = ".rotateZ";
//attribute affected

string $selectedItems[] = `ls -sl`;

float $minTime = `playbackOptions -q -minTime`;
float $maxTime = `playbackOptions -q -maxTime`;
// get range slider

currentTime -edit $minTime;
//jumps to beginning of range slider before starting

for ($i = $minTime; $i <= $maxTime; $i++)
{
//for every frame within the range slider

float $time = `currentTime -q`;
//gets the current frame

for ($item in $selectedItems)
{
//for every selected objects

float $currentValue = `getAttr ($item + $attribute)`;
setAttr ($item + $attribute) ($currentValue + $newValue);
setKeyframe ($item + $attribute);
// process and bakes the rotation of the selected items

}

currentTime -edit ($time + 1);
//go to the next frame
}

 

Hope this helps,

Cheers

Dino

0 Likes