Mirroring animation timing using tcl
To mirror your animation curves, you can use some simple expressions. Let’s say you animated an object from frame 0-50, and now you want to mirror it to frame 51-100.
Just write the following in your specific knob:
1 |
curve(frame >= 50 ? 50-(frame-50): frame) |
This uses the command:
1 |
curve(x) |
which will hold the animation on frame x. So what the above example does, it checks if the current frame is 50 or above. If this is true, it frameholds 50-(frame-50), which at frame 52 for example is …
1 2 3 |
50-(52-50) 50-2 48 |
So on frame 52, it frameholds frame 48. If the frame is under 50, is just gives you your current animated value.
This is pretty useful for creating walk-arounds or anything symmetrical, when you’re too lazy to animate everything. :-)
Restrict number of decimals when working with float and tcl
Say, you need to animate a number and want one decimal. You link a text node to a floating point slider to get the job done, however, it will output a never-ending string of digits that nobody really cares about. You can format this, however. Have no fear.
1 |
[format "%.1f" [value animator.kgloss]] |
Copying rendered files to a different folder via python
If you do some versioning on a shot, and want to keep those files in your version-folders, but also want to have a folder that always contains the latest renders, you can do this with python, and don’t have to add a second Write-node in your script.
Just add the following in the after each frame field in your Write-Node.
1 2 3 4 5 6 7 |
import shutil srcFile = nuke.thisNode()['file'].evaluate() folder = os.path.join(path(srcFile).parent.parent) target = os.path.basename(srcFile) destFile = str(folder + "/VLATEST/" + target) if not os.path.isdir(os.path.dirname(destFile)): os.makedirs(os.path.dirname(destFile)) shutil.copy2(srcFile, destFile) |
What this does is the following:
It thinks you render everything in your e.g. “…/output/001/…” – folder.
Then it splits the path and exchanges the 001 by “VLATEST”. If this folder doesn’t exist, it creates the folder.
Then it copies everything over via shutil.copy2().
This script assumes that you don’t have versioning on the filename at the moment. If you want to edit this, you have to adjust your destFile.
Creating Procedural Textures via UV-Map with Expression-Node
To create cool procedural textures in nuke, there is a pretty simple way to do that, all you need is an input image, a STMap-node and an Expression-node. (more…)
Create render folders if they do not exist
To prevent your write nodes throwing “no such file or directory” errors, paste this bit of code into the python – before render section of the write:
1 2 3 |
import os if not os.path.isdir(os.path.dirname(nuke.thisNode()['file'].evaluate())): os.makedirs(os.path.dirname(nuke.thisNode()['file'].evaluate())) |
Split and use topnode’s filename
For file conversions or prep-jobs, if you want to use the original input’s filename in the final write node, you can use the following snippet of code.
1 |
/[join [lrange [split [file dirname [value [topnode].file] ] "/"] 1 6] "/"]/2D/PRERENDER/[lrange [split [file dirname [value [topnode].file] ] "/"] 9 9]_DENOISED/[lindex [split [file tail [knob [topnode].file]] .] 0]_denoised_v02.%04d[file extension [knob [topnode].file]] |
random() function in tcl
Well. It goes like this:
1 |
(random(seed, frame * frequency) * amplitude ) + offset |
expoglow
Simple setup of blur nodes with exponentially increasing size, added back to the input successively. State: production-tested. expoglow features a pre- and post-grade section, colour shift settings and a mask input, that behaves the way it should – masking the input, not the glow itself. (more…)
Copy files on os level via python
This script copies the file of a Read node to a specific folder.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
import shutil import os readNode = nuke.toNode('Read12') path = readNode["file"].getValue() destfolder = "C:/Users/sschweiger/Desktop/test/" srcfolder = path.split("/")[-2] srcname = path.split("/")[-1] srcSize = os.path.getsize(path) if not os.path.isfile(destfolder): nuke.message('Copypocess for Videofile '+path.split("/")[-1]+' will start after klicking "OK"!'+' Wait for Message before continue!') shutil.copy2(path, destfolder) destSize = os.path.getsize(destfolder+srcname) x=0 while (x!=1): if srcSize==destSize: x=1 else: x=0 nuke.message('Copied sucsessfully!') |
Welcome
Howdy, stranger.
This is a collection of tips and tricks, code snippets and home-brewed gizmos, set up as a personal go-to library among friends. Feel free to browse and use whatever you find here. If you know something that’s missing in this database and would like to contribute, you can simply shoot me an e-mail to julian@yellow-ant.net. I’ll make sure to give you proper credit.
Resident contributors: [php snippet=1]