simple scripting

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 03 March 2010   #1
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 March 2010   #2
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 March 2010   #3
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 March 2010   #4
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 March 2010   #5
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 March 2010   #6
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 March 2010   #7
that's something like what i had in mind...but hey, today's lazy sunday
 
Old 03 March 2010   #8
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 March 2010   #9
That's what I had earlier. As time goes by sometimes I just want to change the selected ones. Cheers,

Ft
__________________

 
Old 03 March 2010   #10
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.
 
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 05:35 AM.


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