I am writing a custom script for precisely changing the rotation values using custom hotkeys.
What I want to do is, when I press some_key, I want the selected channel box attribute to increment/decrement by some value
To get the selected channel box attribute, I am using
string $selCBAttr[] = `selectedChannelBoxAttributes`;
But the problem is, it only returns a string and I don't know how to use that to make changes in the channel box.
My current code looks something like this, which I'll map to maybe Shift+Left
//print selected attribute in channelBox
string $selCBAttr[] = `selectedChannelBoxAttributes`;
print $selCBAttr;
if ('selectedChannelBoxAttributes' == "rx")
{
rotate -r -eu -fo -1 0 0 ;
}
else if ('selectedChannelBoxAttributes' == "ry")
{
rotate -r -eu -fo 0 -1 0 ;
}
else if ('selectedChannelBoxAttributes' == "rz")
{
rotate -r -eu -fo 0 0 -1 ;
}
and the values will change from -1 to 1 for Shift+Right.
When I run the above code, I get the following errors:
// Warning: string $selCBAttr[] = `selectedChannelBoxAttributes`;
//
// Warning: Line 2.53 : Redeclaration of variable "$selCBAttr" shadows previous declaration at line 1. Previous value will be overwritten by explicit initializer. //
// Error: if ('selectedChannelBoxAttributes' == "rx")
//
// Error: Line 6.5: Syntax error //
// Error: }
//
// Error: Line 9.1: Syntax error //
// Error: }
//
// Error: Line 13.1: Syntax error //
// Error: }; //
// Error: Line 17.1: Syntax error //
So how do I so this in Maya?
# Save selected channel attributes to a string array
string $selCBAttr[] = `selectedChannelBoxAttributes`;
# Check if "rx" selected
if (stringArrayContains("rx", $selCBAttr)) {
rotate -r -eu -fo -1 0 0 ;
}
# Check if "ry" selected
if (stringArrayContains("ry", $selCBAttr)) {
rotate -r -eu -fo 0 -1 0 ;
}
# Check if "rz" selected
if (stringArrayContains("rz", $selCBAttr)) {
rotate -r -eu -fo 0 0 -1 ;
}