A supervisor wants to write Node has the function of multi thread rendering , and nuke Medium render in background This function can be used to perform multiple rendering tasks at the same time , So I thought about using this method to achieve .

transfer During the test, I found that renderinbackground The management of memory is worrying , So I added a parameter to control the memory consumption of multithreaded rendering . This feature is written very quickly , After writing, I still We have to think about it artist Usage habits , It's not a wise move to make this function a separate node in the toolbar ,artist It'll be troublesome , So I decided to integrate this function into write Node .
This is the final result of implementation :
write One more page in the node ,artist It's easy to use , But this function is limited by the computing and memory capacity of the computer , After all, it's single machine multithreading , Resources are tight , The project is simple , This feature has great advantages , It's several times faster ; The project is complicated , Memory is tight , This function is just like chicken ribs .
Talk is 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("Please make 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 More related articles on the script of

  1. I wrote one myself tomcat Release the script

    Be free and at leisure , Just write one by yourself shell Script , It's convenient for you to deploy on the server in the future tomcat Next item . I use it locally maven pack , Then you have to manually switch a bunch of directories every time , It's a bit tedious. , So I wrote the following shell Script . #! /bi ...

  2. Based on seven cattle Python SDK Write a batch download script

    Preface The last one is based on seven cows Python SDK Write a synchronization script, the script only supports upload , File download is not supported . Although the demand is not very strong , But there could be someone ( In backup . When moving ) need , And does the government provide corresponding tools , So I put this function into practice ...

  3. Write login and logout functions separately to a public .py Script , Other use cases test1,test2 Call public login , Exit function

    Public login / Exit function module (login_exit.py): #coding:utf-8import timedef login(driver, username, password):# Here driver ...

  4. python3 Write a pressure test script ( To be developed )

    import requests import queue import threading import time status_code_list = [] exec_time = 0 class ...

  5. python+imageMagick Write a compressed picture script

    !/usr/bin/python import os import cPickle as p import re import Image def imageCompre(imagedir = '.' ...

  6. Write a general generation merge Small script for

    Now use the database to write stored procedures , The parameters will be used xml , Of course , The advantages are obvious , The parameters are relatively fixed , And flexible , If you want to modify or something , The middle interface layer doesn't need to change either , You just need to modify the encapsulated stored procedure and program parameters ok 了 . along with ...

  7. Preliminary learning nodejs, Amateur use node Write a small script to create directories and files automatically , I hope it can help people in need

    Preliminary learning nodejs, Amateur use node Write a small script to create directories and files automatically , I hope it can help people in need , If there is bug Or better optimization , Please also criticize and correct , thank you , The code is as follows : var fs = require('f ...

  8. Hand to hand Monkey Write a pressure test script

    Copyright notice : The official account is published in the public address , Ink shadow bearing fragrance (cxmyDev), All rights reserved . Conditional reprint is allowed , Please attach the QR code at the bottom for reprint . One . Why a test script is needed ? Yesterday I explained Android Monkey life ...

  9. Wrote a hiero Add custom Token Script for

    Hiero Bring their own Token It's often not enough ,shotname It will be very troublesome to upgrade the version when the version number is included in the , such as Shot_0001_v001 Such a sequence name , To upgrade to Shot_0001_v002 You have to put _v001 Previous ...

Random recommendation

  1. JAVA Work in the fourth week

    import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.FileOutputStream; ...

  2. Testing - Quality assurance and quality control

    QA QC QM Concept Quality Assurance ( QA ) Quality Control ( The quality control ) Quality Manage ( Quality management ) Definition Operation technology adopted to meet quality requirements ...

  3. angularjs kindEditor in content Can't get value

    angularjs kindEditor in content Can't get value It needs to be revised angular-kindeditor.js angular-kindeditor.js if (KindEditor) ...

  4. MYSQL group_concat() function

    Look at the data in the table select * from t; The next step is to look at group_concat Function usage select ID,group_concat(Name) from t group by ID ...

  5. goodbye acm

    2013 year 11 month 17 My last regional match in the Changsha regional match . Busy for three years acm To stop , I can't accept it for a while . Such a result is a bit helpless . Thanks to the team , Three years, three teams, five teammates , Thank you for your .( When I write here, I can't help it ...

  6. 【1414 Soft assistant 】 Team work 7——Alpha After the sprint Scoreboard

    subject Team work 7--Alpha After the sprint Past results Personal work 1: Four computing console Pairing projects 1:GUI Personal work 2: case analysis Pairing projects 2: unit testing Team work 1: Team show Team work 2: Demand analysis & ...

  7. Centos build Docker Environmental Science

    install Docker install Docker Docker The package is already included in the default CentOS-Extras Software source . So you want to install docker, Just run the following yum command : yum install d ...

  8. 【jQuery】 JQ and AJAX

    AJAX AJAX Asynchronous JavaScript and XML(Asynchronous JavaScript and XML), It is a means of data interaction between the front end of the web page and the background of the website . About AJAX The details of are in ...

  9. springmvc Simple integration shiro

    Preface : One day I chatted with my colleagues , Talking about rights management , He said he had a colleague with shiro It's very smooth . Now there's a management platform project , There is a need for access control , So I want to take this opportunity to study . In this paper, I will briefly explain how to shiro Some knowledge of , ...

  10. Program bug It's a huge loss , Do you want to shoot the ape ?[ZZ]

    From maopu : Program bug It's a huge loss , Do you want to shoot the ape ? 0 introduction Annual meeting Review What is the source code ? A court of law Review code It's really exciting ..... 2015 year 9 month 3 Japan , With the Tokyo Supreme Court rejecting Mizuho Securities ...