wrote a renderinbackground script.

Source: Internet
Author: User

A Department leader needs a tool for batch rendering in nuke, while the render in background function in Nuke can be executed simultaneously with multiple render tasks, so I consider using this method.

During debugging, it was found that Renderinbackground's management of memory was worrying, so I added the parameters to control the memory consumption when multitasking was rendered. This function is very quick to write, and after writing it has to consider artist habits, it is not a good idea to put this function into a separate node in the toolbar, artist will be troublesome, so I decided to integrate this function on the write node. This is the result of the final execution:write node more than a paging, artist used very handy, but this function is limited by computer computing and memory capacity, after all, is a single-machine to perform multi-tasking, resources are tight, engineering simple, this function has advantages, engineering complex, memory tight, this function is chicken.
Talk was cheap,show you the code:
#####################################################################
Def renderinbackground ():
node = Nuke.thisnode ()
If Node.knob (' User '):
print ' exist '
Else
KNOB_TK = nuke. Tab_knob (' User ', ' renderinbackground ')
Node.addknob (KNOB_TK)
If Node.knob (' Information '):
print ' exist '
Else
KNOB_TK2 = nuke. Text_knob (' Information ', ' Info: ')
Knob_tk2.setvalue ("Sure your setting didn ' t overflow available memory,so enough memory is necessary.")
Node.addknob (KNOB_TK2)
If Node.knob (' Firstframe_1 '):
print ' exist '
Else
KNOB_FF = nuke. Int_knob (' firstframe_1 ', ' firstframe ')
Knob_ff.setvalue (1001)
Node.addknob (KNOB_FF)
Knob_ff.settooltip (' entry first frame of render range ')
If Node.knob (' Lastframe_1 '):
print ' exist '
Else
KNOB_LF = nuke. Int_knob (' lastframe_1 ', ' lastframe ')
Knob_lf.setvalue (1100)
Node.addknob (KNOB_LF)
Knob_lf.settooltip (' entry last frame of render range ')
If Node.knob (' Splitnum '):
print ' exist '
Else
KNOB_SN = nuke. Int_knob (' Splitnum ', ' splitnum ')
Knob_sn.setvalue (2)
Node.addknob (KNOB_SN)
Knob_sn.settooltip (' entry number of splited Framerange ')
If Node.knob (' MaxThreads '):
print ' exist '
Else
KNOB_MT = nuke. Int_knob (' MaxThreads ', ' maxthreads ')
Knob_mt.setvalue (4)
Node.addknob (KNOB_MT)
If Node.knob (' MaxCache '):
print ' exist '
Else
KNOB_MC = nuke. Int_knob (' MaxCache ', ' MaxCache ')
Knob_mc.setvalue (2000)
Node.addknob (KNOB_MC)
If Node.knob (' unnamed '):
print ' exist '
Else
Knob_tt = nuke. Text_knob (' unnamed ', ')
Node.addknob (KNOB_TT)
If Node.knob (' Renderinbackground '):
print ' exist '
Else
Knob_py = nuke. Pyscript_knob (' Renderinbackground ', ' renderinbackground ')
Node.addknob (knob_py)
Knob_py.setcommand ("Import Time"
If Nuke.thisnode (). Knob (' file '). Value (). Find (':/') = =-1:
Nuke.message (' file is empty ')
Else
If Os.path.exists (Os.path.dirname (Nuke.thisnode (). Knob (' file '). Value ())) ==true:
Print Nuke.thisnode (). Knob (' file '). Value ()
Else
Os.makedirs (Os.path.dirname (Nuke.thisnode (). Knob (' file '). Value ()))

firstframe_2 = Int (Nuke.thisnode (). Knob (' firstframe_1 '). Value ())
lastframe_2 = Int (Nuke.thisnode (). Knob (' lastframe_1 '). Value ())
splitnum_2 = Int (Nuke.thisnode (). Knob (' Splitnum '). Value ())

subrange = Int ((lastframe_2 + 1-firstframe_2)/splitnum_2)

MaxThreads = Nuke.thisnode (). Knob (' MaxThreads '). Value ()
Maxcache = Nuke.thisnode (). Knob (' Maxcache '). Value ()
view = Nuke.views ()
Limits = {' MaxThreads ': maxthreads, ' maxCache ': '%dm '%maxcache}

For I in Range (splitnum_2+1):
Framerange = nuke. Framerange ()
Frameranges = nuke. Frameranges ()

If firstframe_2-1 + subrange * (i+1) >= lastframe_2:
Framerange.setlast (lastframe_2)
Else
Framerange.setlast (firstframe_2-1 + subrange * (i+1))
If lastframe_2 >= firstframe_2 + subrange * I:
Framerange.setfirst (firstframe_2 + subrange * i)
Framerange.setincrement (1)
Frameranges.add (Framerange)
Time.sleep (0.1)
Print Frameranges
Nuke.executebackgroundnuke (nuke. Exe_path,[nuke.thisnode ()],frameranges,view,limits)
Else
Pass



INPUTX = Nuke.thisnode () [' Xpos '].value ()
Inputy = Nuke.thisnode () [' Ypos '].value ()
NewNode = Nuke.nodes.Read (File=nuke.thisnode (). Knob (' file '). Value (), first=firstframe_2,last=lastframe_2,)
Newnode.setxypos (int (INPUTX), int (inputy) +50) "
)


Nuke.addoncreate (renderinbackground,nodeclass = ' Write ')

wrote a renderinbackground script.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.