Thanks Johan and Nathan! These are fantastic workarounds, exactly what I needed.
kind regards, sally On Tue, Jan 17, 2012 at 2:23 PM, Johan Aberg <[email protected]> wrote: > > > This seems to be working as well: > > from PyQt4 import QtGui > cb = QtGui.QApplication.clipboard() > nuke.nodeCopy('%clipboard%') > print cb.text() > > > > > > On 18/01/12 11:06, Nathan Rusch wrote: > > The simplest way to do this would probably be to use Nuke's built-in > serialization via nuke.nodeCopy, as opposed to trying to roll your own using > Node.writeKnobs() and some fancy formatting. Unfortunately, this function > only accepts strings as arguments, rather than file-like Python objects > (side note: in thinking this one over, I actually just submitted a feature > request for this...). > > As a workaround, you can use a tempfile.NamedTemporaryFile instance to get > this done: > > from __future__ import with_statement > import tempfile > > with tempfile.NamedTemporaryFile() as fd: > nuke.nodeCopy(fd) > result = fd.read() > > > The temp file will get deleted when the with block exits (as part of its > close() method), so you shouldn't have to worry about lots of temporary > files showing up on your machine. > > Hope this helps. > > -Nathan > > -----Original Message----- From: Sally Slade > Sent: Tuesday, January 17, 2012 12:52 PM > To: [email protected] > Subject: [Nuke-python] derive TCL node structure from selected nodes? > > hi everyone! > > i need to somehow derive the nodes and their connectivity data (ie: > set & push commands), from a list of selected nuke node objects, > preferably in python. > here is an example of the desired derived data: > > myData = """ > set n11111 [stack 0] > Grade { > name Grade1 > selected true > xpos 0 > ypos 0 > } > push $n11111 > Grade { > name Grade2 > xpos 100 > ypos 100 > } > Merge2 { > inputs 2 > name Merge1 > xpos 200 > ypos 200 > } > """ > > i feel like this is possible to get somehow because Ctrl+C derives > this data and puts it on the clipboard natively in nuke. nuke also > must use something like this in it's "export nodes as script" > function. > so, anyone know how to do this? > > thanks for any advice! > -sally > _______________________________________________ > 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
