A good point, there's definitely other ways around the problem. The idea was based on a tool someone here wrote for Houdini - it seemed useful, and I wanted to see how well it'd work in Nuke.

Might have worked, or maybe not.. but regardless, being able to query the cursor location has other interesting uses (one random example: being able to do custom drawing on the nodegraph, I have the drawing part working, but again encountered the same stumbling block of turning screen coordinates into nodegraph space - https://gist.github.com/dbr/5167728 )

On 04/07/13 13:55, Nico Dufort wrote:
Select/Cut/Click DAG/Paste to where you clicked does not work for
you/your artists?

Not being a smart ass, but since the click on your DAG already dictates
where nodes can be created/pasted, why not go simple...


On Wed, Jul 3, 2013 at 8:46 PM, Ben Dickson <[email protected]
<mailto:[email protected]>> wrote:

    Is there any way to get the location of the cursor in the node graph?

    There's a few reasons this would be useful, but.. currently I'm
    trying to write a tool where you select a bunch of nodes, press a
    button and have those nodes be moved to the mouse location -
    theoretically making it easier to move nodes around while zoomed


    I tried creating a node with nuke.createNode(), and querying it's
    location.. but this isn't reliable: if I click first then it works,
    but subsequent runs create the temp node just below the previous
    location, no where near the mouse


    def thing():
         selection = nuke.selectedNodes()
         [n.setSelected(False) for n in selection]

         # Get mouse position
         n = nuke.createNode("NoOp")
         x, y = (n.xpos(), n.ypos())
         nuke.delete(n)

         # Restore selection
         [n.setSelected(True) for n in selection]

         # Do something interesting with mouse position
         b = nuke.nodes.Blur()
         b.setXYpos(x, y)

    nuke.menu("Nodes").addCommand(__"thing", thing, "alt+a")


    Only other way I can think of is with PySide: you could get the
    mouse coordinates, and using the DAG widget get "widget space"
    coordinates.. but I can't think of a way to transform these into
    nodegraph coordinates (maybe impossible without changes to Nuke, at
    which point it would be just as easy to add a "getMouseCoordinates"
    method)
    --
    ben dickson
    2D TD | [email protected] <mailto:[email protected]>
    rising sun pictures | www.rsp.com.au <http://www.rsp.com.au>
    _________________________________________________
    Nuke-python mailing list
    Nuke-python@support.__thefoundry.co.uk
    <mailto:[email protected]>,
    http://forums.thefoundry.co.__uk/ <http://forums.thefoundry.co.uk/>
    http://support.thefoundry.co.__uk/cgi-bin/mailman/listinfo/__nuke-python
    <http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python>




--
"Attention, attention. Here and now, boys," the mynah repeated. "Here
and now, boys."


_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

--
ben dickson
2D TD | [email protected]
rising sun pictures | www.rsp.com.au
_______________________________________________
Nuke-python mailing list
[email protected], http://forums.thefoundry.co.uk/
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python

Reply via email to