I wrote something similar, which works on nodes with hidden inputs. This stores the input node in a knob on the node instead of in a temporary NoOp.
Perhaps it will be useful to reference: https://gist.github.com/jedypod/29187fa8c82bbbf4bf5e On Fri, Mar 20, 2015 at 3:33 PM, Nathan Rusch <[email protected]> wrote: > Or better yet, use a central file. > > > *From:* Gustaf Nilsson <[email protected]> > *Sent:* Friday, March 20, 2015 11:11 AM > *To:* Nuke Python discussion <[email protected]> > *Subject:* Re: [Nuke-python] node onCreate doesnt perform as expected > > thanks. that is a workaround i suppose. > the disadvantage is that i need to edit menu.py on every computer but such > is life. > > On Thu, Mar 19, 2015 at 6:09 PM, Kim Ranzani <[email protected]> > wrote: > >> Hey Gustaf, >> >> I wrote something similar long time ago, I just created 2 functions for >> copy and paste and assigned those to a hot key. You'll probably want to >> rewrite it a bit better (really old script) but it works for copying the >> nodes while keeping the original connections. Hope it helps... >> >> Kim >> >> >> import nuke >> >> def copy(): >> nodesToCopy = {} >> for node in nuke.selectedNodes(): >> currentNodes={node:node.dependencies()} >> nodesToCopy.update(currentNodes) >> node.setSelected(False) >> copiedNodes=nodesToCopy >> >> return copiedNodes >> >> def paste(nodesToPaste): >> if len(nodesToPaste)>0: >> for node in nodesToPaste.keys(): >> node.setSelected(True) >> nuke.nodeCopy(nukescripts.cut_paste_file()) >> node.setSelected(False) >> b=nuke.nodePaste(nukescripts.cut_paste_file()) >> for i in range(node.inputs()): >> if node.inputs()==0: >> b.setInput(i,none) >> else: >> b.setInput(i,node.input(i)) >> b.setSelected(False) >> nodesToPaste.clear() >> else: >> nuke.message('Nothing has been Copied! use Edit - copy with >> inputs ! ') >> >> >> 2015-03-19 16:55 GMT+00:00 Andy Nicholas <[email protected]>: >> >>> Yep, there's a script on Nukepedia that does it for Postage Stamp nodes, >>> although it seems a little buggy. Probably best to roll your own, but it's >>> here if you want to try it: >>> >>> http://www.nukepedia.com/python/nodegraph/postagestamp-copy/paste-fix >>> >>> Cheers, >>> Andy >>> >>> >>> On 19/03/2015 16:41, Charles Taylor wrote: >>> >>> I believe a better approach is to co-opt the Paste function with your >>> own function that looks for the special knob, and, if it finds it, deals >>> with it appropriately. >>> >>> On 03/19/2015 12:06 PM, Gustaf Nilsson wrote: >>> >>> Hello >>> >>> i want to create a noop node that when i copy/paste it, it will keep the >>> input of the original node. >>> >>> to do this i thought i would store the input name in a text knob (called >>> "tunnel") and connect it with the onCreate trigger. >>> >>> >>> >>> >>> nuke.selectedNode()["onCreate"].setValue("nuke.thisNode().setInput(0,nuke.toNode(nuke.thisNode()['tunnel'].getValue()))") >>> >>> >>> what am i missing? >>> >>> kbye >>> >>> -- >>> ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ >>> >>> >>> _______________________________________________ >>> Nuke-python mailing [email protected], >>> http://forums.thefoundry.co.uk/http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python >>> >>> >>> >>> >>> _______________________________________________ >>> Nuke-python mailing [email protected], >>> http://forums.thefoundry.co.uk/http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python >>> >>> >>> >>> _______________________________________________ >>> Nuke-python mailing list >>> [email protected], http://forums.thefoundry.co.uk/ >>> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python >>> >>> >> >> _______________________________________________ >> Nuke-python mailing list >> [email protected], http://forums.thefoundry.co.uk/ >> http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python >> >> > > > -- > ■ ■ ■ ■ ■ ■ ■ ■ ■ ■ > > ------------------------------ > _______________________________________________ > Nuke-python mailing list > [email protected], http://forums.thefoundry.co.uk/ > http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python > > > _______________________________________________ > Nuke-python mailing list > [email protected], http://forums.thefoundry.co.uk/ > http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python > >
_______________________________________________ Nuke-python mailing list [email protected], http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-python
