TCL Commands
xxxxxxxxxx1
GETTING A KNOB’S VALUE OF A SPECIFIC NODE:2
3
#First frame of current read/write:4
[value Read1.first]5
6
#Getting a knob’s value of current node:7
[value this.first_frame]8
9
#Return label value of the input node:10
[value this.size]11
12
#Name of the input node:13
[value this.input0.label]14
15
#Name of the node before the group (Outside):16
[value this.input.name]17
18
#Return 1 if the node is on error otherwise 0:19
[value this.parent.input.name]20
21
#Get the bounding Box from the input of the node:22
[value error]23
24
25
#Here some expression for the Format26
format.x27
format.y28
width29
height30
bbox.x31
bbox.y32
bbox.w33
bbox.h34
35
#Get the format from the input of the node:36
#left boundary37
[value input.bbox.x] 38
#right boundary39
[value input.bbox.r] 40
41
#Get the format from the input of the node:42
#width43
[value input.format.r]44
#height45
[value input.format.t]46
47
#Get the x position of the point #3 of the Bezier1 of the Roto1 node:48
[value Roto1.curves.Bezier1.curve_points.3.main.x]49
50
#Return sample pixel value of the node Add1 reading in the red at position of knob Center:51
[sample Add1 Red Center.x Center.y]52
53
#Get the value of the channel of a node, at a specific pixelcoordinates (e.g.: 10,10):54
[sample [node input] red 10 10]55
56
#---------------------------------------------------------------------57
#SET VALUES58
59
#Setting a knob’s value of a specific node:60
[knob Read1.first 10]61
62
#Setting a variable, without returning that (useful in a textnode):63
[set seq [value Read1.file]; return]64
65
#---------------------------------------------------------------------66
#STRING67
68
#Replace string in current node file knob with regex (string “proj” to “projects” in all occurences):69
[regsub -all "proj" [value [node this].file] "projects"] 70
71
#String map (replace multiple stringpairs) (this returns: xxffffxxyy):72
[string map {"aa" "xx" "bb" "yy"} "aaffffaabb" ]73
74
#Compare strings:75
[string equal [value Text1.message] "bla"]76
77
#Regexp matching:78
[regexp -inline "_v\[0-9]{3}" [value Read2.file]] 79
80
#Evaluating string81
[python os.getenv('rotate') == 'xavierb']82
83
#---------------------------------------------------------------------84
#IF CONDITION85
86
[if {condition} {expr1} else {expr2}]87
88
#Example:89
[if {[value blackpoint]==1} {return 2} {return 3}]90
[if {[value blackpoint]==1} {return True} {return False}]91
[if {[value blackpoint]==1} {return blackpoint} {return whitepoint}]92
[if {[value filter]=="gaussian"} {return filter} {return False}]93
94
#OTHER METHOD95
condition ? then : else96
97
#Example:98
#if (r==1)? return 0: else (return r*2)99
r ==1 ? 0 : r*2100
101
#---------------------------------------------------------------------102
#PATH MANIPULATIONS:103
104
#Filepath without extension:105
[file rootname [value [topnode].file]]106
107
#Filename only:108
[basename [value [topnode].file ]]109
110
#Filename only without extension:111
[basename[file rootname [value [topnode].file]]]112
113
#---------------------------------------------------------------------114
#RELATIVE PATH115
#In the Read node you can use the relative path for your footage/Obj116
117
#In your Read Node in the knob "file", use this:118
119
#Read file "render.exe" in the same folder of your file nuke 120
[python {nuke.script_directory()}]/render.exr121
122
#Read file "render.exe" in the subfolder where your file nuke is 123
[python {nuke.script_directory()}]/folder/render.exr124
125
#Read file "render.exe" in the subfolder of your .nuke folder 126
[python {"/Users/gere/.nuke} ]/folder/render.exr
No Comments