CGTalk > Software > Compositing Software > The Foundry Nuke
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 05-31-2010, 05:12 AM   #1
ManuelM
Lord of the posts
 
ManuelM's Avatar
portfolio
Manuel Macha
Shadowcaster
Animal Logic
Sydney, Australia
 
Join Date: Feb 2002
Posts: 630
Send a message via ICQ to ManuelM Send a message via AIM to ManuelM Send a message via MSN to ManuelM Send a message via Yahoo to ManuelM
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:

Code:
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:

Code:
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:
Code:
set Nd0fbe1d0 [stack 0]

Code:
push $Nd0fbe1d0

What exactly does it mean? Is it pointing to some location in memory?
And is there a workaround for this like:
Code:
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-01-2010, 10:53 AM   #2
pingking
Expert
portfolio
michael vorberg
digital compositor
freelance
stuttgart, Germany
 
Join Date: Sep 2009
Posts: 634
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-02-2010, 06:16 AM   #3
ManuelM
Lord of the posts
 
ManuelM's Avatar
portfolio
Manuel Macha
Shadowcaster
Animal Logic
Sydney, Australia
 
Join Date: Feb 2002
Posts: 630
Send a message via ICQ to ManuelM Send a message via AIM to ManuelM Send a message via MSN to ManuelM Send a message via Yahoo to ManuelM
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-02-2010, 07:00 AM   #4
ndeboar
Lord of the posts
 
ndeboar's Avatar
CGSociety Member
portfolio
Nick Deboar
Lighting TD
AU
 
Join Date: Nov 2004
Posts: 1,184
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-02-2010, 05:09 PM   #5
alkali22
import nuke
portfolio
Nathan
Pipeline TD
Los Angeles, USA
 
Join Date: Feb 2009
Posts: 62
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-03-2010, 05:06 AM   #6
ManuelM
Lord of the posts
 
ManuelM's Avatar
portfolio
Manuel Macha
Shadowcaster
Animal Logic
Sydney, Australia
 
Join Date: Feb 2002
Posts: 630
Send a message via ICQ to ManuelM Send a message via AIM to ManuelM Send a message via MSN to ManuelM Send a message via Yahoo to ManuelM
Quote:
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.

Quote:
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-03-2010, 06:09 AM   #7
alkali22
import nuke
portfolio
Nathan
Pipeline TD
Los Angeles, USA
 
Join Date: Feb 2009
Posts: 62
Quote:
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-03-2010, 06:20 AM   #8
ManuelM
Lord of the posts
 
ManuelM's Avatar
portfolio
Manuel Macha
Shadowcaster
Animal Logic
Sydney, Australia
 
Join Date: Feb 2002
Posts: 630
Send a message via ICQ to ManuelM Send a message via AIM to ManuelM Send a message via MSN to ManuelM Send a message via Yahoo to ManuelM
Quote:
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-04-2010, 12:12 AM   #9
ndeboar
Lord of the posts
 
ndeboar's Avatar
CGSociety Member
portfolio
Nick Deboar
Lighting TD
AU
 
Join Date: Nov 2004
Posts: 1,184
you can call nuke in python command line mode from maya, no worries, done it before.
 
Old 06-04-2010, 12:30 AM   #10
alkali22
import nuke
portfolio
Nathan
Pipeline TD
Los Angeles, USA
 
Join Date: Feb 2009
Posts: 62
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-13-2010, 04:53 PM   #11
TinuZ
Proud Pastafarian
 
TinuZ's Avatar
Martijn Grootendorst
Senior 3D-Artist
mediamonks
Amsterdam, NL
 
Join Date: Nov 2003
Posts: 20
Quote:
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-27-2010, 10:59 AM   #12
KC-ANIS
New Member
portfolio
mezar
Tunisia
 
Join Date: Jul 2010
Posts: 2
is there a way for repairing a corrupt nuke project file?
 
Old 08-03-2010, 09:47 AM   #13
instinct-vfx
Techdepp
 
instinct-vfx's Avatar
Thorsten Kaufmann
Production Pipeline Architect
Mackevision
Stuttgart, Germany, Germany
 
Join Date: Jun 2003
Posts: 456
spawning a nuke commandline can be way simplified using nukeprocess for example:

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

Regards,
Thorsten
 
Old 08-03-2010, 09:47 AM   #14
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,480
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


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 05:36 AM.


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