Invoke Mel command "move" on custom manipulator like native one

Invoke Mel command "move" on custom manipulator like native one

143110913
Enthusiast Enthusiast
235 Views
1 Reply
Message 1 of 2

Invoke Mel command "move" on custom manipulator like native one

143110913
Enthusiast
Enthusiast

Hello,

 

I am working on a custom "kFreePointTriadManip" manipulator and trying to make it behave as close to the native maya one.

 

On the sdk I noticed the "moveManip" example invokes the setAttr command whenever it's moved instead of the

"move" MEL command like the original.

 

This makes it harder to do other actions such as moving multiple objects and apply a relative offset to all of them. (Like the original).

 

I think the correct way of implementing it would be through a "MPxToolCommand" but since "move" is already implemented I wonder if I can just do MGlobal::executeCommand and that will take care of the relative offset and the undo queue, among other things that make it closer to the original implementation.

 

I feel a bit lost and unsure about how to proceed so any insight would be greatly appreciated,

 

thank you!

0 Likes
236 Views
1 Reply
Reply (1)
Message 2 of 2

jmreinhart
Advisor
Advisor

MGlobal::executeCommand("move ...  undoEnabled = true") would move the selection, and would add an entry to the undo queue.

 

The "move" is essentially an MPxToolCommand. 

 

There is a difference between using the move command, and creating your own tool command that replicates its behavior. For vanilla move, you call it with a string command, so any data you want to provide to the command would need to be done using flags or object lists. This is slower because Maya has to process the command as a string every time.

 

If you made your own MPxToolCommand you would be able to pass information from your MPxContext to the MPxToolCommand directly (as API objects) which is faster because everything is compiled C++.

Check the doRelease section of this code for an example of this:

https://help.autodesk.com/view/MAYAUL/2017/ENU/?guid=__cpp_ref_helix_tool_2helix_tool_8cpp_example_h... 

 

Out of curiosity, why are you trying to recreate the default triad manip? Is there some behavior you want to add to it?

0 Likes