Sometimes there are critical changes in a production. The resolution of the plate may change (it’s not a common thing, but it may happen). Lest say that we have been working doing some roto and cleanup for a 2K DCP plate and the, they give us a 4K DCP plate. The aim of this script is to modify the roto/rotopaint nodes to adapt them to the new resolution, without having to redo all the work.
It works straight away with proportional resolution changes. However, it is possible to adapt it to work with non-proportional resolution changes too. The only thing that we should do is add an offset to the root layer modification expressions. It has been used in a professional feature film 🙂
def resolutionChanger(): # Remind the user the steps that need to be made readyToGo = nuke.ask("In order to this script to work it needs certain steps: 1. Make a copy of the roto/rotopaint node you want to adapt 2. Connect it to the new footage 3. Select the new roto/rotopaint's root layer. Is everything ready to go?") # If everything is ready if readyToGo: # Get original width and height originalFormatX = nuke.selectedNode().knob('center').value()*2 originalFormatY = nuke.selectedNode().knob('center').value()*2 # Get new width and height newFormatX = nuke.selectedNode().width() newFormatY = nuke.selectedNode().height() # Calculate proportional difference between two formats factorX = newFormatX/originalFormatX factorY = newFormatY/originalFormatY # Modify Root layer nuke.selectedNode()['translate'].setExpression('input.width/2-center.x', 0) nuke.selectedNode()['translate'].setExpression('input.height/2-center.y', 1) nuke.selectedNode()['scale'].setExpression('input.width/(center.x*2)') # Modify Brush strokes root_layer = nuke.selectedNode()['curves'].rootLayer for i in root_layer: attr = i.getAttributes() # BS = Brush Size # STX = Source Transform X oldBS = attr.getValue(nuke.frame(), 'bs') oldSTX = attr.getValue(nuke.frame(), 'stx') oldSTY = attr.getValue(nuke.frame(), 'sty') newBS = oldBS*factorX newSTX = int('%.0f' % round(oldSTX, 1))*factorX newSTY = int('%.0f' % round(oldSTY, 1))*factorX attr.set('bs', newBS) attr.set('stx', newSTX) attr.set('sty', newSTY) # If the steps that are required have not been made else: nuke.message("Operation canceled. Please make sure that all the necessary steps have been made.")