I have an object selected and I'm in the rotate tool. I run the following commands.
string $ctx = `currentCtx`;
The result is "RotateSuperContext". I then wanted to query which axis is selected.
manipRotateContext -q -ah $ctx;
And I get this error.
// Error: line 1: manipRotateContext: Object 'RotateSuperContext' not found. //
How do I get the selected axis handle?
Solved! Go to Solution.
Solved by brentmc. Go to Solution.
Hi,
First, super contexts are special in Maya and you would need to query the super context to get the actual tool name like this.
string $curContext = `currentCtx`;
string $curTool = (`superCtx -exists $curContext` ? `superCtx -q $curContext` : $curContext);
Second, the flag you want to query on the manipRotateContext is -currentActiveHandle / -cah
However, most Mel code in Maya just checks explicitly for the scale/rotate/move contexts using something like this since there is only a single context and they are called Move/Rotate/Scale.
int $activeHandle = -1;
string $curContext = `currentCtx`;
string $curTool = (`superCtx -exists $curContext` ? `superCtx -q $curContext` : $curContext);
if ($curTool == "Move") {
$activeHandle = `manipMoveContext -q -currentActiveHandle $curTool`;
} else if ($curTool == "Rotate") {
$activeHandle = `manipRotateContext -q -currentActiveHandle $curTool`;
} else if ($curTool == "Scale") {
$activeHandle = `manipScaleContext -q -currentActiveHandle $curTool`;
}
if ($activeHandle == 0) {
print "X handle is active";
} else if ($activeHandle == 1) {
print "Y handle is active";
} else if ($activeHandle == 2) {
print "Z handle is active";
} else if ($activeHandle == -1) {
print "No active transform tool";
} else {
print "Some other handle is active";
}
Can't find what you're looking for? Ask the community or share your knowledge.