Community
Maya Programming
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya SDK topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to get the selected axis handle of a manipulator?

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
mcw0
224 Views, 2 Replies

How to get the selected axis handle of a manipulator?

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?

2 REPLIES 2
Message 2 of 3
brentmc
in reply to: mcw0

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"; 
}
Brent McPherson
Principle Engineer
Message 3 of 3
Kahylan
in reply to: mcw0

Whoops I see this already got answered better by @brentmc

 

Nevermind 🙂

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report