both those examples work for me but it does seem like the onCreate callback
can't change the knobs on creation. Same for knobChanged.
I'd report it as a bug.
On Apr 25, 2011, at 2:48 AM, John RA Benson wrote:
> Not helping, but this looks like a bug because this makes no sense at all : i
> happened to try your snippet with a Camera node selected (and then some other
> 3D nodes) and it did work as expected. When the blur is the selected node, it
> doesn't. Why would getting a ypos from a 3D node be any different than any
> other node?
>
>
> nuke.createNode('Camera2')
> theSelectedNode = nuke.selectedNode()
> theYpos = theSelectedNode.ypos()
> theYpos +=1000
> theNewNode = nuke.createNode("Blur")
> theNewNode['ypos'].setValue(theYpos)
> nuke.tprint( 'offset from camera ypos.value(): %s' %
> theNewNode['ypos'].value())
> nuke.tprint( 'offset from camera ypos(): %s' % theNewNode.ypos())
> # both values match and the blur accepted the setValue
>
> nuke.createNode('Blur')
> theSelectedNode = nuke.selectedNode()
> theYpos = theSelectedNode.ypos()
> theYpos +=1000
> theNewNode = nuke.createNode("Blur")
> theNewNode['ypos'].setValue(theYpos)
> nuke.tprint( 'offset from Blur ypos.value(): %s' % theNewNode['ypos'].value())
> nuke.tprint( 'offset from Blur ypos(): %s' % theNewNode.ypos())
> # values do not match and the new blur is located at the ypos() position, not
> the reported ['ypos'].value() position
>
> Cheers
> JRAB
>
> On Apr 24, 2011, at 1:57 PM, Pete O'Connell wrote:
>
>> Hi Frank. Well I think the problem I am running in to here is that
>> nuke.createNode doesn't seem to allow knobs to be changed immediately after
>> it's creation. Like in the code below, the node doesn't hop down 1000 units
>> as I would expect it to.
>> #########################
>> theSelectedNode = nuke.selectedNode()
>> theYpos = theSelectedNode['ypos'].value()
>> theNewNode = nuke.createNode("Blur")
>> theNewNode['ypos'].setValue(theYpos+1000)
>> ##############################
>>
>> Using nuke.nodes seems more promising because at least it isn't doing
>> anything under the hood but at the same time it will be harder to
>> implement.
>> Thanks for the idea of using node.screenWidth
>> Pete
>>
>>
>> On Sat, Apr 23, 2011 at 12:35 PM, Frank Rueter <[email protected]> wrote:
>> I haven't looked at suggestions in this thread but my gut feeling would be
>> to try and adjust the node positions through the onUserCreate callback using
>> node.xpos, node.ypos, node.screenWidth and screenHeight and of course the
>> grid settings from the prefs.
>>
>>
>> On Apr 22, 2011, at 11:47 PM, Pete O'Connell wrote:
>>
>>> Hi Ben thanks for your script. I am not so much concerned with overlapping
>>> as I am with having every node be always on the grid. This seems to be
>>> especially tricky when nodes are being created. Like in this image:
>>>
>>> Pete
>>>
>>>
>>>
>>> On Thu, Apr 21, 2011 at 8:43 PM, Ben Dickson <[email protected]> wrote:
>>> Ahh.. You could possibly traverse down the tree, offsetting nodes that
>>> overlap..
>>>
>>> Something like this:
>>>
>>> from math import sqrt
>>>
>>> mindist = 30
>>> def avoid_overlapping(startnode, offset = mindist):
>>> sx, sy = startnode.xpos(), startnode.ypos()
>>> for n in startnode.dependent():
>>> nx, ny = n.xpos(), n.ypos()
>>> if sqrt((nx - sx)**2 + (ny - sy)**2) < mindist:
>>> print "Node %s is too close, it's being moved by %s"%(
>>> n.name(), offset)
>>> n.setYpos(n.ypos() + offset)
>>> offset += mindist
>>> avoid_overlapping(n, offset = offset)
>>>
>>> avoid_overlapping(nuke.selectedNode())
>>>
>>>
>>> If you arrange up a bunch of nodes so they overlap, then select the
>>> top-most node, the code should shove them apart.. Doesn't handle some
>>> things too well (nodes overlapping horizontally), but seems to do a
>>> decent job, and should probably incorporate the node's screenheight for
>>> tall nodes
>>>
>>>
>>> Pete O'Connell wrote:
>>> > Hi Ben. That code still doesn't solve the problem of creating nodes when
>>> > other nodes are selected, so for example if in the dag I hit the letter
>>> > "b" seven times, each subsequent blur node lands further and further off
>>> > the grid in y. I find myself having to reposition my nodes a lot because
>>> > of this.
>>> > Know what I mean?
>>> > pete
>>> >
>>> > On Thu, Apr 14, 2011 at 1:52 PM, Ben Dickson <[email protected]
>>> > <mailto:[email protected]>> wrote:
>>> >
>>> > You can press \ and it'll auto-snap all (or all selected) nodes to
>>> > the grid.
>>> >
>>> > Programatically, is the snap to grid code in the nukescripts code
>>> > somewhere? If not, I guess you could make a snap-to-grid function
>>> > quite
>>> > easily.. Something like:
>>> >
>>> > node = nuke.selectedNode()
>>> > gridsize = 50 # could be grabbed from preferences
>>> >
>>> > orig_y = node.ypos()
>>> > new_y = round(float(orig_y) / gridsize) * gridsize
>>> > node.setYpos(new_y)
>>> >
>>> > Pete O'Connell wrote:
>>> > > Well it seemd to be a bit more complicated... If I use Nathan's
>>> > script
>>> > > and make a blur node with, it snaps to the grid, but if I make a
>>> > second
>>> > > blur node with the first blur still selected, it isn't snapped to
>>> > the
>>> > > grid and that one I have to repo by hand. The second blur seems to
>>> > be
>>> > > positioned a relative amount offset under the first node. I am
>>> > trying to
>>> > > reduce all the repositioning I have to do in the dag throughout
>>> > the day.
>>> > > Isn't there a way to have every node always be forced onto the
>>> > grid. I
>>> > > am also trying to avoid that situation where one node is directly
>>> > on top
>>> > > of another after snapping (by making sure that eveything is
>>> > initially on
>>> > > the grid).
>>> > >
>>> > > Did I miss this page in the manual?
>>> > > Pete
>>> > >
>>> > >
>>> > > On Tue, Apr 12, 2011 at 5:30 PM, Pete O'Connell
>>> > <[email protected] <mailto:[email protected]>
>>> > > <mailto:[email protected] <mailto:[email protected]>>>
>>> > wrote:
>>> > >
>>> > > That works!
>>> > >
>>> > > Thanks Nathan
>>> > > Pete
>>> > >
>>> > >
>>> > > On Tue, Apr 12, 2011 at 5:22 PM, Nathan Rusch
>>> > > <[email protected] <mailto:[email protected]>
>>> > <mailto:[email protected] <mailto:[email protected]>>>
>>> > wrote:
>>> > >
>>> > > What about just using the .autoplace() node method?
>>> > >
>>> > > def apCreated():
>>> > > nuke.thisNode().autoplace()
>>> > >
>>> > > nuke.addOnUserCreate(apCreated)
>>> > >
>>> > > -Nathan
>>> > >
>>> > >
>>> > > *From:* Pete O'Connell <mailto:[email protected]
>>> > <mailto:[email protected]>>
>>> > > *Sent:* Monday, April 11, 2011 6:39 PM
>>> > > *To:* [email protected]
>>> > <mailto:[email protected]>
>>> > > <mailto:[email protected]
>>> > <mailto:[email protected]>>
>>> > > *Subject:* [Nuke-python] snap to grid on user create?
>>> > >
>>> > > Hello Nuke python enthusiasts. I am trying to have every
>>> > node I
>>> > > create be snapped to the grid as I create them. It is
>>> > proving
>>> > > trickier thatn I thought.
>>> > > I have been working on variations on the code below which
>>> > > doesn't work I assume because the node becomes selected
>>> > after it
>>> > > is created. Maybe the node needs to be an argument to the
>>> > > autosnap function?
>>> > >
>>> > > ################################################3
>>> > > import nuke
>>> > > def autoplaceSnapSelectedNodesOnUserCreate():
>>> > > m = nuke.selectedNodes()
>>> > > for i in m:
>>> > > nuke.autoplaceSnap(i)
>>> > > if __name__ == '__main__':
>>> > > autoplaceSnapSelectedNodesOnUserCreate()
>>> > >
>>> > >
>>> > > nuke.addOnUserCreate(autoplaceSnapSelectedNodesOnUserCreate)
>>> > >
>>> >
>>> > ########################################################################
>>> > >
>>> > > Any Suggestions would be greatly appreciated
>>> > > Pete
>>> > >
>>> > >
>>> >
>>> > ------------------------------------------------------------------------
>>> > > _______________________________________________
>>> > > Nuke-python mailing list
>>> > > [email protected]
>>> > <mailto:[email protected]>
>>> > > <mailto:[email protected]
>>> > <mailto:[email protected]>>
>>> > >
>>> > http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>>> > >
>>> > > _______________________________________________
>>> > > Nuke-python mailing list
>>> > > [email protected]
>>> > <mailto:[email protected]>
>>> > > <mailto:[email protected]
>>> > <mailto:[email protected]>>
>>> > >
>>> > http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>>> > >
>>> > >
>>> > >
>>> > >
>>> > > --
>>> > > Pete
>>> > >
>>> > >
>>> > >
>>> > >
>>> > > --
>>> > > Pete
>>> > >
>>> > >
>>> > >
>>> >
>>> > ------------------------------------------------------------------------
>>> > >
>>> > > _______________________________________________
>>> > > Nuke-python mailing list
>>> > > [email protected]
>>> > <mailto:[email protected]>
>>> > > http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>>> >
>>> > --
>>> > 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
>>> > [email protected]
>>> > <mailto:[email protected]>
>>> > http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>>> >
>>> >
>>> >
>>> >
>>> > --
>>> > Pete
>>> >
>>> >
>>> > ------------------------------------------------------------------------
>>> >
>>> > _______________________________________________
>>> > Nuke-python mailing list
>>> > [email protected]
>>> > 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://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>>>
>>>
>>>
>>> --
>>> Pete
>>> <nukeNodeCreationExample.png>_______________________________________________
>>>
>>> Nuke-python mailing list
>>> [email protected]
>>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>>
>>
>> _______________________________________________
>> Nuke-python mailing list
>> [email protected]
>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>>
>>
>>
>>
>> --
>> Pete
>> _______________________________________________
>> Nuke-python mailing list
>> [email protected]
>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
>
> _______________________________________________
> Nuke-python mailing list
> [email protected]
> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
_______________________________________________
Nuke-python mailing list
[email protected]
http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python