Monday, June 20, 2016

scale up and down cornerpin node

global scale up and down cornerpin

This script help you to global scale up or down the selected cornerpin. Recently i had situation to scale up the cornerpin globally. But there is no way either to place the pins individually. So here is the solution. Bugs and future improvement requests are welcome.

Raw script:

'''
Created on 10th june 2016
@author: satheesh
mail - satheesrev@gmail.com

#### nuke.menu( 'Viewer' ).addCommand( 'scaleCornerpin/scaleUpCornerpin', "scaleCornerpin.scaleUpCornerpin()", "ctrl++")
#### nuke.menu( 'Viewer' ).addCommand( 'scaleCornerpin/scaleDownCornerpin', "scaleCornerpin.scaleDownCornerpin()", "ctrl+-")

'''

import nuke

def scaleUpCornerpin():

    selNode = None
    try:
      selNode = nuke.selectedNode()
    except ValueError:  # no node selected
      pass

    if selNode is not None:
        selClass = selNode.Class()
        if selClass == 'CornerPin2D':
            to1x = selNode['to1'].getValue(0)
            selNode['to1'].setValue(to1x-10.0, 0)

            to1y = selNode['to1'].getValue(1)
            selNode['to1'].setValue(to1y-10.0, 1)

            to2x = selNode['to2'].getValue(0)
            selNode['to2'].setValue(to2x+10.0, 0)

            to2y = selNode['to2'].getValue(1)
            selNode['to2'].setValue(to2y-10.0, 1)


            to3x = selNode['to3'].getValue(0)
            selNode['to3'].setValue(to3x+10.0, 0)

            to3y = selNode['to3'].getValue(1)
            selNode['to3'].setValue(to3y+10.0, 1)

            to4x = selNode['to4'].getValue(0)
            selNode['to4'].setValue(to4x-10.0, 0)

            to4y = selNode['to4'].getValue(1)
            selNode['to4'].setValue(to4y+10.0, 1)
        else:
            return

def scaleDownCornerpin():

    selNode = None
    try:
      selNode = nuke.selectedNode()
    except ValueError:  # no node selected
      pass

    if selNode is not None:
        selClass = selNode.Class()
        if selClass == 'CornerPin2D':
            to1x = selNode['to1'].getValue(0)
            selNode['to1'].setValue(to1x+10.0, 0)

            to1y = selNode['to1'].getValue(1)
            selNode['to1'].setValue(to1y+10.0, 1)

            to2x = selNode['to2'].getValue(0)
            selNode['to2'].setValue(to2x-10.0, 0)

            to2y = selNode['to2'].getValue(1)
            selNode['to2'].setValue(to2y+10.0, 1)


            to3x = selNode['to3'].getValue(0)
            selNode['to3'].setValue(to3x-10.0, 0)

            to3y = selNode['to3'].getValue(1)
            selNode['to3'].setValue(to3y-10.0, 1)

            to4x = selNode['to4'].getValue(0)
            selNode['to4'].setValue(to4x+10.0, 0)

            to4y = selNode['to4'].getValue(1)
            selNode['to4'].setValue(to4y-10.0, 1)
        else:
            return

Saturday, April 2, 2016

roto shape life time settings

roto shape life time based on keyframes

This is long time request. I haven't got time to look into this after joined in MPC. Got some time yesterday. Thought to update my blog with new tool. Here is the simple tool but much needed one ( i hope).

One of my friend requested to automate roto shapes lifetime based on the key frame. We use multiple way to set roto shapes lifetime. Some artists uses lifetime tab in roto node, Some simply move the roto shape out of the working resolution. Some guys are using 'multiply' node to achieve this. Some artists animating 'visible' knob in roto node. The way of doing this will differ from artist to artist. How to make this organised ?.

Here is the idea: lifetimeRoto.py

Most of us using nuke roto node lifetime tab set the lifetime based on the frame range.



Some artists using mouse click option in curve window in roto node.


In both way we need to feed the frame range either we need to choose to-end or to start. Doing this is not time consuming task for compers. But for roto & clean-up artist ?

lifetimeRoto.py automatically sets the selected rotoshapes lifetime based on the shapes key frame's. This code get the selected shapes keyframe value ( example: 10, 20, 30) and apply min and max to lifetime start and end respectively.  After i run this code my roto shape lifetime set to 10 - 30 automatically by single click or short-key.

I have assigned 'shift+L' as short-cut. Select your roto shape and make sure you have selected the roto node. Run this shortcut, Boooommmm. Your roto shape lifetime sets based on the keyframe.

I hope this will helpful. Feature request and bug reports are welcome.

Download: lifetimeroto.py

menu.py lines:

import lifetimeRoto

menuBar = nuke.menu("Nuke")
menuBar.addCommand('Edit/Node/lifetimeRoto', 'lifetimeRoto.setRotoLifeTime()', 'shift+l')

Full code:

'''
Created on 07-april-2016
@author: satheesh-R
mail - satheesrev@gmail.com
'''
### to set selected roto shapes lifetime based on the min max keyframes value.

import nuke

def setRotoLifeTime():

### get selected node
    selNode = None
    try:
        selNode = nuke.selectedNode()
    except ValueError: # no node selected
        pass
    if selNode == None:
        nuke.message('make sure your roto node selected')
        return
    ### find selected roto shapes keyframes
    if selNode.Class() == 'Roto':
        for selShape in selNode['curves'].getSelected():
            keyFrame = selShape[0].center.getControlPointKeyTimes()
            keyFrames = [int(i) for i in keyFrame]
            low = (min(keyFrames))
            high = (max(keyFrames))
            ### applying min max keyframe to per shape lifetime
            selNode['lifetime_type'].setValue(4)
            selNode['lifetime_start'].setValue(low)
            selNode['lifetime_end'].setValue(high)


Friday, May 22, 2015

lockNode for nuke

lockNode.py

Locking the nodes knobs (sliders) inside nuke very long waited future. It is requested many time with foundry but i don't think they going to add this unique future. So i have decided to create a python code for this function. Her is the solution.

This code allow user to lock the nodes knob. Once you lock the knobs, then you cant modify any sliders until you un-lock the knobs. This will save you from any accident changes. Hope this will help you guys.

Latest version support to write the info to your nuke script. So it will always locked if you close your nuke script and re-open it. I have used some cheat method to keep the node locked while user save their nuke script. I have tested many times and haven't faced any issues. Let me know if you faced any issues.


steps:

right mouse click on node property panel. You will get options 'lock_knobs' and 'unlock_knobs'.



Select 'lock_knobs'. This code will lock will the knobs and put Node_Locked text into node label. So user can easily identify the locked knob in UI.



If user selects 'unlock_knob'. This code will return knobs to active and remove the Node_Locked text from label.

Save your nuke script with nodes locked. Close nuke and re-open the script. You can find the locked node still locked.

mail to satheesrev@gmail.com for any bugs & reports.


copy paste below lines into your menu.py.

import lockNode

nuke.menu("Properties").addCommand('lock_knobs', "lockNode.lock_knobs()")
nuke.menu("Properties").addCommand('unlock_knobs', "lockNode.unLock_knobs()")

def oc():
nodes = nuke.allNodes()
for selNode in nodes:
selNode.setSelected(True)
allknobs=selNode.allKnobs()
label = selNode['label'].getValue()
labCheck = label.rsplit(None, 1)
if labCheck:
labCheck = labCheck[-1]
if labCheck == 'Node_Locked':
for knob in allknobs:
  knob.setEnabled(False)
nuke.addOnScriptLoad(oc)


Here is the python code:

download lockNode.py

Saturday, October 11, 2014

rippleEditOnOff

rippleEditOnOff.py

Hi nukers i have created this little code for my friend request. I'm decided to share this code with you. Hope this will help you friends.

This code toggle on - off ripple edit mode in nuke. Select your roto shape and run the hot-key. This will really help full while edit rotoshape inside nuke. Here im using alt+q as keyboard shortcut. But you can use your combination of key's.

rippleEditOnOff.py work with nukes roto and rotopaint node. Tested several time and working fine. If you have any bugs or reports mail to satheesrev@gmail.com



Original Code:

### created by satheesh-r, Oct 2014.
### To toggle on & off nuke roto, rotopaint nodes ripple edit function.
### for bugs & reports: satheesrev@gmail.com

import nuke

def rippleEditOnOff():
    selNode = None
    try:
      selNode = nuke.selectedNode()
    except ValueError:  # no node selected
      pass
    getValue = selNode['toolbar_ripple'].value()
    if getValue == False:
        selNode['toolbar_ripple'].setValue(True)
    if getValue == True:
        selNode['toolbar_ripple'].setValue(False)
    else:
        return


menu.py:

import rippleEditOnOff
nuke.menu( 'Viewer' ).addCommand( 'rippleEdit/OnOff', 'rippleEditOnOff.rippleEditOnOff()', "alt+q")