Template:Relative Paths

From RMIT Visual Effects
Jump to: navigation, search

An absolute path is one that specifies the location of the file with respect to the computor e.g. My_Computer/school/lesson_one/asset.JPG. A relative path is one that defines the location relative to a file or a folder.

When reading and writing files, this course expects you to (as much as possible) use paths that are relative to the Nuke file. An absolute path 'breaks' when the project folder is moved to a new computor, and each filepath will then have to be manually repaired. A relative path, on the other hand, is far more durable.

There are two flavours of relative paths: those that look 'downstream' (i.e. into the same folder in which the Nuke file is located, or other folders within it) or 'upstream' (i.e. in the parent folders of the folders in which the Nuke file is located).

Upstream and downstream, defined as relative to the Nuke file.

For downstream, the following relative filepath is recommend. This writes or reads into a folder called 'sources', which is located in the same folder as the Nuke file. The image below illustrates this relationship.

[file dirname [value root.name]]/sources/Asset_Name.JPG.
The destination folder of the downstream relative path.

For upstream, the following relative filepath is recommend. This writes or reads into a folder called 'comp-out', which is located 'upstream' to the Nuke file. The image below illustrates this relationship. To go further upstream, the value end-n needs to be increased.

[join [lrange [split [file dirname [knob root.name]] "/"] 0 end-1] "/"]/comp-out/01_01_qua_v1.jpg
The destination folder of the upstream relative path.

If by chance, you are keeping the footage on a network drive far away from your Nuke script, then the relative path method won't work as there will be a 'breakage' between the Nuke file and the source/write file. Instead of manually changing each node, you can configure a NoOp node so that it is referenced by the Read and Write nodes. The snippet below explains how this is done.

Press 'Expand' and select and copy everything below this line, then paste into the Nuke node graph.

set cut_paste_input [stack 0]
version 9.0 v7
StickyNote {
 inputs 0
 name StickyNote7
 label "<pre><b><-- This Read node refferences the filepath value in the node 'Project_Path' (which is an adapted NoOp node) \n\nInstructions for use: \n\n1)  Paste 'Project_Path' into your script.                   \n\n1)  In all your Read and Write nodes, substitute \\\[value Project_Path.filepath] for everything that preceds the filename.\n\n2)  In 'file path' of 'Project_Path', navigate to your sources folder\n\nAll Read and Write nodes will now call upon 'file path' of 'Project_Path' when looking for the 'sources' folder."
 selected true
 xpos -4012
 ypos 65
}
push $cut_paste_input
NoOp {
 name Project_Path
 label "\nPlace in this node the file\npath of your project.   "
 note_font "Verdana Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold Bold"
 note_font_size 9
 note_font_color 0xff
 selected true
 xpos -4111
 ypos -92
 addUserKnob {20 User}
 addUserKnob {2 filepath l "file path"}
 filepath /Volumes/Internal_02/School/RMIT_VFX/lessons/lesson_01/01_01_qua/comp/_setup/sources/
 addUserKnob {26 ""}
 addUserKnob {26 directions l Directions: -STARTLINE T "Place here the path of 'top level' folder of your \nproject. If you don't know it drop the folder \ninto the node script and copy it from there \n(it will be in the file parameter of one the \nresulting read nodes)"}
}
Read {
 inputs 0
 file "\[value Project_Path.filepath]file_name.jpg"
 format "1920 1080 0 0 1920 1080 1 HD_1080"
 origset true
 version 1
 name Read3
 selected true
 xpos -4112
 ypos 55
}
 

For a fuller and more comprehensive look at file paths, have a look at this excellent pdf from the excellent Benjamin Seide.