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 03-05-2010, 01:22 AM   #1
ftaswin
tick tick tick
 
ftaswin's Avatar
portfolio
ft
3d
Sydney, Australia
 
Join Date: Oct 2004
Posts: 766
simple scripting

Hi,

I need to convert lots of exr squences to tiff16.

- How can I change multiple attributes on similar nodes at once?
- How can I link the file path on the read nodes to write nodes but replacing exr with tif?

This way I can copy and paste 1 node and swap the read node and i'm all set to go.

I'm curious of how to do


Ft it in scripting as well. I can do it easily with mel but Nuke is a whole new ball game for me. Thanks
__________________

 
Old 03-05-2010, 08:15 PM   #2
thatoneguy
Interesting User Title
 
thatoneguy's Avatar
portfolio
Gavin Greenwalt
Exec. VP of Pixel Mergers and Acquisitions
Straightface Studios
Seattle, USA
 
Join Date: Jan 2005
Posts: 2,332
Courtesty of Alkali22

Code:
for node in nuke.selectedNodes(): node["##KNOBNAME##"].setValue(##VALUE##)


Code:
for node in nuke.selectedNodes(): node["##KNOBNAME##"].setExpression("##EXPRESSION##")
 
Old 03-06-2010, 12:48 PM   #3
ftaswin
tick tick tick
 
ftaswin's Avatar
portfolio
ft
3d
Sydney, Australia
 
Join Date: Oct 2004
Posts: 766
Thank youuuu

That's very handy...

One more major one for me:
What's the syntax to:
-Get the input node's file attribute
-And then replace exr to tif at the same time

Thank you all

ft
__________________

 
Old 03-06-2010, 09:15 PM   #4
ChristopherP
Frequenter
portfolio
Dude Dude
United%2BStates
 
Join Date: Oct 2002
Posts: 199
maybe it's not not exactly what you needed from your original question, but at least it should get you started . it might also not be the prettiest code ever since i also just started looking more into nuke scripting... also commented all of it for clarity.
if anyone knows a quicker way or finds errors, let me know

Code:
#import a python module so we can do the search&replace stuff import re #select all nodes in the root graph nuke.selectAll() #loop through all selected read nodes to for n in nuke.selectedNodes('Read'): #get the full file and proxy paths tmpDir = n.knob('file').value() tmpProxyDir = n.knob('proxy').value() # print the result for confirmation print tmpDir print tmpProxyDir # replace .exr with .tif in the file and proxy paths replFile = re.sub('.exr', '.tif', tmpDir) replProxy = re.sub('.exr', '.tif', tmpProxyDir) # set the new file and proxy paths n.knob('file').setValue(replFile) n.knob('proxy').setValue(replProxy)
 
Old 03-07-2010, 10:33 AM   #5
ftaswin
tick tick tick
 
ftaswin's Avatar
portfolio
ft
3d
Sydney, Australia
 
Join Date: Oct 2004
Posts: 766
Thanks Chris,

That was the best explanation I got so far.

But the node I want to replace from exr to tif is write node, not the read node itself. And the write node should be able to capture it's parent's file attribute.

Any takers? Thanks
__________________

 
Old 03-07-2010, 01:46 PM   #6
ftaswin
tick tick tick
 
ftaswin's Avatar
portfolio
ft
3d
Sydney, Australia
 
Join Date: Oct 2004
Posts: 766
Done.

Thanks Chris...
Oh, and unless anyone has a better suggestion? Feel free to improve, Cheers,

Ft



Code:
#import a python module so we can do the search&replace stuff import re #select all nodes in the root graph nuke.selectAll() #loop through all selected read nodes to for n in nuke.selectedNodes('Read'): #get the full file and proxy paths tmpDir = n.knob('file').value() tmpProxyDir = n.knob('proxy').value() # print the result for confirmation print tmpDir print tmpProxyDir # replace .exr with .tif in the file and proxy paths replFile = re.sub('.tif', '.jpg', tmpDir) replProxy = re.sub('.tif', '.jpg', tmpProxyDir) r = nuke.createNode('Write') r.setInput(0,n) r.knob('file').setValue(replFile) r["file_type"].setValue("tiff") r["datatype"].setValue("16_bit") r["channels"].setValue("rgba") r["colorspace"].setValue("linear") r["compression"].setValue("none")
__________________

 
Old 03-07-2010, 02:31 PM   #7
ChristopherP
Frequenter
portfolio
Dude Dude
United%2BStates
 
Join Date: Oct 2002
Posts: 199
that's something like what i had in mind...but hey, today's lazy sunday
 
Old 03-10-2010, 09:57 PM   #8
jorx
Compositing TD in NZ
portfolio
Jordan Olson
Compositing technical director
New Zealand
 
Join Date: Nov 2004
Posts: 132
Slight simplification; rather then manipulating the selection, you could try nuke.allNodes. A string argument will define the node type to return. For example:

nuke.allNodes('Read') # Result: [<Read1 at 0x0000000004E89470>]


nuke.allNodes('Write')
# Result: [<Write1 at 0x0000000004E89370>]
 
Old 03-11-2010, 01:01 AM   #9
ftaswin
tick tick tick
 
ftaswin's Avatar
portfolio
ft
3d
Sydney, Australia
 
Join Date: Oct 2004
Posts: 766
That's what I had earlier. As time goes by sometimes I just want to change the selected ones. Cheers,

Ft
__________________

 
Old 03-11-2010, 01:01 AM   #10
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,481
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 04:46 AM.


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