PDA

View Full Version : Understanding the nuke script syntax


ManuelM
05-31-2010, 05:12 AM
Hi,

I'm currently working on a tool that creates a .nk file based on the render passes in my 3d application and I'm having some problems to understand the way how nuke is connecting nodes. Let's say I have 3 inputs like this:

Constant {
inputs 0
channels rgb
color {1 0 0 0}
name Constant1
xpos -150
ypos -298
}
CheckerBoard2 {
inputs 0
name CheckerBoard1
xpos 70
ypos -298
}
ColorWheel {
inputs 0
gamma 0.45
name ColorWheel1
xpos 290
ypos -298
}

Now let's try to connect those nodes with some grade and merge operators:

CheckerBoard2 {
inputs 0
name CheckerBoard1
xpos 70
ypos -298
}
Grade {
name Grade2
xpos 70
ypos -224
}
set Nd0fbe1d0 [stack 0]
ColorWheel {
inputs 0
gamma 0.45
name ColorWheel1
xpos 290
ypos -298
}
Grade {
name Grade3
xpos 290
ypos -224
}
Merge2 {
inputs 2
name Merge2
xpos 161
ypos -145
}
Constant {
inputs 0
channels rgb
color {1 0 0 0}
name Constant1
xpos -150
ypos -298
}
Grade {
name Grade1
xpos -150
ypos -224
}
push $Nd0fbe1d0
Merge2 {
inputs 2
name Merge1
xpos -47
ypos -143
}

I'm having problems with understanding the following lines:
set Nd0fbe1d0 [stack 0]
push $Nd0fbe1d0
What exactly does it mean? Is it pointing to some location in memory?
And is there a workaround for this like:
input1 Grade1
input2 CheckerBoard2

Another option would be to automatically run some code that connects the nodes when the nuke file is opened for the first time, but I have no idea how to do that.
Any suggestions?

regards,
m.

pingking
06-01-2010, 10:53 AM
i can't tell you how to read or recreate the snytax of the .nk file

but i would try to build a template script and put some variables in the filename which will be then replaced with the actuall filenames (you can do it simply by a search and replace or by running nuke from commandline)

or you building a python script which runs from inside nuke, assuming you have a definde folderstructure, it asks for a root folder and builds the script

ManuelM
06-02-2010, 06:16 AM
hey, thanks a lot for your suggestions.

unfortunately using a template script and just replacing the paths won't work as the script is being generated based on the shot's requirements.
in one shot i might have only two render passes with a diffuse and specular channel but then in another shot i might have 10 or 20 passes with several aov's each and the tool that i'm trying to build must be flexible enough to handling this without any hiccups.


Does someone else know exactly what's happening under the hood when there's lines like these in the script?

set Nd0fbe1d0 [stack 0]

push $Nd0fbe1d0
Are those some randomnly generated ID's, pointers to some internal nuke data structure... I'm a bit lost here?

ndeboar
06-02-2010, 07:00 AM
Nuke has really good python support, you can call Nuke in Python Command line mode and create comps on the fly, way easier syntax than doing it like this. The check out setting up nuke for VFX supervisors in the docs.

alkali22
06-02-2010, 05:09 PM
The "set" calls store the previous node in a variable so it can be referenced for connection later (via the "push $<something>" call). "push 0" clears the stack so that the next node is not automatically connected to the previous one (credit to Frank Reuter for confirming that).

However, as ndeboar mentioned, you will be much better off using a Python constructor to build and save your script. Trying to match the .nk syntax exactly will almost certainly turn out to be unreliable somewhere along the line.

ManuelM
06-03-2010, 05:06 AM
The "set" calls store the previous node in a variable so it can be referenced for connection later (via the "push $<something>" call). "push 0" clears the stack so that the next node is not automatically connected to the previous one

Ok great, I'll definitely test this. Thanks a lot.

However, as ndeboar mentioned, you will be much better off using a Python constructor to build and save your script. Trying to match the .nk syntax exactly will almost certainly turn out to be unreliable somewhere along the line.

I'm aware that this would be the better way to go and I'm definitely planning to ultimately switch to that methodology.
One advantage that I see with my method though is that if I build the nuke script from a procedure within maya, that procedure can look up all kinds of things in the scene and tailor the script to the requirements of each scene: How many and what characters in which render passes, how many props and are they visible in a pass or do they only cast shadows... are there fx layers... are there passes that are So in order to reach that kind if complexity I'd have to write out that information somehow and then pass it on to the python constructor that runs from nuke...

also are there any nuke forums that are frequented a bit more than this one. I'm particularly looking for a forum where I can get great technical advice (scripting, automization)

thanks for your help guys!!!

alkali22
06-03-2010, 06:09 AM
One advantage that I see with my method though is that if I build the nuke script from a procedure within maya, that procedure can look up all kinds of things in the scene and tailor the script to the requirements of each scene: How many and what characters in which render passes, how many props and are they visible in a pass or do they only cast shadows... are there fx layers... are there passes that are So in order to reach that kind if complexity I'd have to write out that information somehow and then pass it on to the python constructor that runs from nuke...


This is true, but depending on how much success you have with hard-coding .nk files directly from Maya and how frequently you do it, it might almost be more worth your while to come up with your own data interchange file format (something tag-based like XML seems to make sense) and write a Python module to parse everything it finds and build the Nuke script accordingly.


also are there any nuke forums that are frequented a bit more than this one. I'm particularly looking for a forum where I can get great technical advice (scripting, automization)

VFXTalk is a much more well-populated and active Nuke resource; the next level would be the Nuke mailing lists (open Nuke, then 'Help'->'Mailing Lists').

ManuelM
06-03-2010, 06:20 AM
VFXTalk is a much more well-populated and active Nuke resource; the next level would be the Nuke mailing lists (open Nuke, then 'Help'->'Mailing Lists').

Thanks :beer:

ndeboar
06-04-2010, 12:12 AM
you can call nuke in python command line mode from maya, no worries, done it before.

alkali22
06-04-2010, 12:30 AM
That's true... I didn't think of that. You could start Nuke in terminal mode as a subprocess of Maya's Python interpreter, and then pass signals to it based on your scene's contents.

TinuZ
07-13-2010, 04:53 PM
you can call nuke in python command line mode from maya, no worries, done it before.

could you please elaborate on that?
or maybe give a small example on how to do that? :)
thnx in advance

KC-ANIS
07-27-2010, 10:59 AM
is there a way for repairing a corrupt nuke project file?

instinct-vfx
08-03-2010, 09:47 AM
spawning a nuke commandline can be way simplified using nukeprocess for example:

http://francoislord.com/blog/computer-graphics/nuke/nukeprocess_74

Regards,
Thorsten

CGTalk Moderation
08-03-2010, 09:47 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.