Well... If you do something like
version = '1' int(version)+1 print version >> '1' The version variable remains intact since you've summed without assigning it to anything. So you must do something like: version = '1' version = int(version)+1 print version >> 2 or version = int( '1' ) version += 1 print version >> 2 Regarding the padding: print 'something_v1.%04d.dpx' % nuke.frame() >> 'something_v1.0045.dpx' Nuke will do this automagically if you name your file correctly while generating the filename for the write node and executing it. On Thu, Mar 29, 2012 at 12:56 PM, Thorsten Kaufmann < [email protected]> wrote: > I am not sure you can put a statement like this into the callback > directly. I guess you'd have a function incrementing the version and**** > > that would be added in the callback.**** > > ** ** > > ** ** > > Regards,**** > > Thorsten**** > > ** ** > > Thorsten Kaufmann > Head of Production > ------------------------------ > > Mackevision Medien Design GmbH > Forststraße 7 > D-70174 Stuttgart > > T +49 711 93 30 48 31 > F +49 711 93 30 48 90 > M +49 151 19 55 55 02 > > [email protected] > http://www.mackevision.de > > Geschäftsführer: Armin Pohl, Joachim Lincke, Karin Suttheimer > HRB 243735 Amtsgericht Stuttgart > > > > *Von:* [email protected] [mailto: > [email protected]] *Im Auftrag von *Jon Wesström > *Gesendet:* Donnerstag, 29. März 2012 17:51 > *An:* Nuke user discussion > *Betreff:* Re: [Nuke-users] A few python questions**** > > ** ** > > Thank you so much, managed to solve the scriptname. > > **** > > I no longer get the TypeError, but (int)version+1 doesn't really seem to > do anything.**** > > If i write: > int(version) + 1**** > > print version**** > > ** ** > > The result will always be 1**** > > ** ** > > But if I write**** > > version = version + 1**** > > print version**** > > ** ** > > It does what I want (adding one number every time i execute)**** > > But I cant put that in the callback, because of the TypeError**** > > ** ** > > What am I missing?**** > > ** ** > > ** ** > > Regarding the framepadding, maybe I'm misunderstanding you, but I don't > think that's quite what I'm after.**** > > ** ** > > In the python script I have to numerical values, frame number & version > number.**** > > I use str(nuke.frame()) to get the frame number, so assuming I'm at frame > 45 printing nuke.frame() = 45.**** > > However, I want it to use, at least four digits, so 45 should be 0045.**** > > The same applies for the version number, which I want to be three digits.* > *** > > ** ** > > I know I can write filname_####.dpx in the writenode, but > again, that's not really what I'm after**** > > ** ** > > ** ** > > ** ** > > I have already looked at nuke.sample, but there doesn't seem to be a way > to fetch the already sampled pixels (shift + ctrl + mouse drag in viewer)* > *** > > having to manually type in x & y coordinates isnt really worth it for me.* > *** > > ** ** > > Again, a huge thanks for you help, I really appreciate it.**** > > ** ** > > On Thu, Mar 29, 2012 at 4:35 PM, Diogo Girondi <[email protected]> > wrote:**** > > To get just the filename you can do something like:**** > > ** ** > > Import os**** > > print os.path.basename( nuke.Root().name() )**** > > ** ** > > Or**** > > ** ** > > nuke.Root().name().split('/')[-1]**** > > ** ** > > You can replace the / for os.sep()**** > > ** ** > > For the TypeError you can simply do int(version)+1 assuming the version > variable is assigned to a numerical character. **** > > ** ** > > To use padded sequences just format your filename string correctly using > either #### or %04d, I suggest you stick with %04d though. **** > > ** ** > > To sample RGBA data look into nuke.sample on the docs. **** > > ** ** > > ** ** > > Cheers,**** > > Diogo**** > > > > On 29/03/2012, at 11:14, Jon Wesström <[email protected]> wrote:**** > > I'm still very new to python/nuke scripting, so these questions might be > dumb, but I'm getting tired of not being able to solve them.**** > > ** ** > > I'm working on a tool that makes it easy to make breakdowns of a script, > you basically select a node, press a button, and nuke renders out a frame. > **** > > ** ** > > That part of the tool is done, but I'm getting stuck on all the stuff that > is generating the filename**** > > ** ** > > 1: When pressing the renderbutton, the script spawns a writenode, puts > text in the file knob, renders the frame and then is deleted **** > > ( > nuke.removeAfterFrameRender(nuke.delete(nuke.toNode('FrameRender'))) ) > **** > > ** ** > > That works fine, but I would also like to add an increment to the > filename, so I figured this would work: nuke.removeAfterFrameRender(version > = version + 1), but it gives me this error: **** > > TypeError: cannot concatenate 'str' and 'int' objects.**** > > I have tried a bunch of different ways to solve it, but nothing is working. > **** > > ** ** > > 2: Is there a way to force python/nuke to display number using a set > amount of increments? > Ex: I would prefer the frame do be written as 0015 in the filename, and > not 15.**** > > ** ** > > 3: Is there a way to access the name of the script?**** > > I know you can write nuke.root().knob('name').getValue(), but that outputs > not only the name, but also the entire filepath.**** > > > 4: Not related to this, but is there any way to access the rgba data that > the viewer sampler samples? > Would like a stickynote that, when created writes down the currently > sampled colors in RGBA. > > If you would like to take a look at the entire script: > http://slexy.org/view/s2gqT5q5Sq > > Any help is greatly appreciated > > /Jon Wesström**** > > _______________________________________________ > Nuke-users mailing list > [email protected], http://forums.thefoundry.co.uk/ > http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users**** > > > _______________________________________________ > Nuke-users mailing list > [email protected], http://forums.thefoundry.co.uk/ > http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users**** > > ** ** > > _______________________________________________ > Nuke-users mailing list > [email protected], http://forums.thefoundry.co.uk/ > http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users >
_______________________________________________ Nuke-users mailing list [email protected], http://forums.thefoundry.co.uk/ http://support.thefoundry.co.uk/cgi-bin/mailman/listinfo/nuke-users
