Understanding the nuke script syntax

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 05 May 2010   #1
Understanding the nuke script syntax

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.
__________________
Manuel Macha
website: www.manuelmacha.de

 
Old 06 June 2010   #2
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
 
Old 06 June 2010   #3
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?
__________________
Manuel Macha
website: www.manuelmacha.de

 
Old 06 June 2010   #4
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.
 
Old 06 June 2010   #5
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.
 
Old 06 June 2010   #6
Originally Posted by alkali22: 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.

Originally Posted by alkali22: 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!!!
__________________
Manuel Macha
website: www.manuelmacha.de

 
Old 06 June 2010   #7
Originally Posted by ManuelM: 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.

Quote: 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').
 
Old 06 June 2010   #8
Originally Posted by alkali22: 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
__________________
Manuel Macha
website: www.manuelmacha.de

 
Old 06 June 2010   #9
you can call nuke in python command line mode from maya, no worries, done it before.
 
Old 06 June 2010   #10
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.
 
Old 07 July 2010   #11
Originally Posted by ndeboar: 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
__________________
"The knack of flying lies in knowing how to throw oneself at the ground, and miss..."
 
Old 07 July 2010   #12
is there a way for repairing a corrupt nuke project file?
 
Old 08 August 2010   #13
spawning a nuke commandline can be way simplified using nukeprocess for example:

http://francoislord.com/blog/comput.../nukeprocess_74

Regards,
Thorsten
 
Old 08 August 2010   #14
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 12:52 AM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.