Home Technical Talk

Maya 3D view double-click detection through MEL

Warheart
polycounter lvl 17
Offline / Send Message
Warheart polycounter lvl 17
Hi, I'm looking to implement a feature in a rig so that the animator can double click on a rig control and it will select all the objects below the selected one in the pickwalk hierarchy. I have all the pickwalk stuff written and I have a function which can be bound to a hotkey but I'd really like it to be able to be called when the object is double-clicked instead (similar to the way it works in biped).

So this is my question: Does anyone know of an easy way to execute a script when an object in the 3D view is double clicked?

I've started looking into timing the second click after a selection change but it seems like a really ugly solution to me (if it's even possible) so I'm wondering if anyone knows of a more elegant approach.

Replies

  • haiddasalami
    Options
    Offline / Send Message
    haiddasalami polycounter lvl 14
    As far as I know, MEL seems to be flag based while what you seem to be looking for is event based (ie Actionscript) and even though there are scriptjobs, I took a look at the documentation and there was no flag for double click. Best bet would be to go the python route though Im just a beginner in MEL so maybe someone more experienced can be of better help.

    EDIT: I know Python can run a separate thread from what Maya though Im iffy about implementation of python in maya though might give you a lead.
  • ivars
    Options
    Offline / Send Message
    ivars polycounter lvl 15
    Seeing as element selection is done by double-clicking, i would assume it's possible to do.... though it wouldn't be the first inconsistency if isn't.
  • Warheart
    Options
    Offline / Send Message
    Warheart polycounter lvl 17
    Yea exactly. What would be ideal would be a callback for double-click in the viewport... but I'm pretty sure I'm not going to be lucky enough that that exists :P Best option so far seems to be timing between selection change (scriptjob) and next click in the viewport. Not entirely sure how to go about that but I'll have a look into it now. Yea Python route might be a good option if it works like that... If I could use a second thread to time and check for the second click or something it might be an easy way to get around locking up maya while the timer loop runs.. This problem is far more annoying than it first seemed.
  • Warheart
    Options
    Offline / Send Message
    Warheart polycounter lvl 17
    @ivars - Yea that's a good point the selection tool does let you double click for edge loops etc. Might have a look and see if I can find where the insides of that tool live.
  • haiddasalami
    Options
    Offline / Send Message
    haiddasalami polycounter lvl 14
    Now you got me all interested :P Gonna install Maya 2011 on mac and see if I can find it
  • haiddasalami
    Options
    Offline / Send Message
    haiddasalami polycounter lvl 14
    So took a looksee at what Maya does when double clicking an edge and this is what I got
     select -r pCube1.e[16] ;
     autoUpdateAttrEd;
     updateAnimLayerEditor("AnimLayerTab");
     statusLineUpdateInputField;
     select -add pCube1.e[14] pCube1.e[16] pCube1.e[18:19] ;
     autoUpdateAttrEd;
     updateAnimLayerEditor("AnimLayerTab");
     statusLineUpdateInputField;
    
    Seems that its not even being called and couldnt even find the select script in maya folders.

    EDIT: I remember that you could double click menu items to create the object and open the attribute edtor. Took a look at the documentation and there is a flag called -doubleClickCommand(-dcc). Guess that's something you can check out...back to work :)
  • Warheart
    Options
    Offline / Send Message
    Warheart polycounter lvl 17
    Yep I had a look at the command echos for that too. Looks like it's not something that gets done at script level. Wonder if the source code for the selection tool is provided so I could add a callback that executes a script and recompile it... getting over my head with this but it's worth a look :D

    Oh and yea I know that some UI elements have double-click callbacks but unfortunately it has to work in the 3D view in this case so I don't think I can make any use of that. Thanks for the input though ^_^
  • haiddasalami
    Options
    Offline / Send Message
    haiddasalami polycounter lvl 14
    Thing is I couldnt even find the selection source code :( A better place to ask will be tech-artist.org.
  • Lamont
    Options
    Online / Send Message
    Lamont polycounter lvl 15
    -doubleClickCommand only applies to shelf buttons. I'd do a script job and detect a double click within a set of tolerances.
  • Warheart
    Options
    Offline / Send Message
    Warheart polycounter lvl 17
    Yep, I think the source code provided is only examples of how to compile plugin versions of stuff like the rotate manipulator. I think doing it that way is probably _possible_ but it's a bit insane. I'd have to pretty much replace the selection tool I think .. and with no source code and without even having VS installed I think I'll look for a simpler but uglier MEL solution if there is one.

    @lamont - yep I know I can't use the UI double click thing. Yea thinking I'll probably go back to try timing clicks.. (ugh)

    If anyone knows how to monitor for a viewport click and not lock up maya while a MEL loop is running (so it can check for a click) that would be useful stuff to know :D

    Going to have to leave this till Monday now but I'll be back then and post anything useful I come up with.
Sign In or Register to comment.