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")

Tuesday, September 30, 2014

extract selected roto shapes

extractSelectedShapes.py

This script extract selected roto shapes from selected roto, rotopaint node in nuke. Usually we use to do, copy the desired roto shapes and then create a new roto node and paste the shapes. If roto node contain baked tracker info, then we copy paste the entire roto node and then delete unwanted shape's from pasted roto node.

I have created extractSelectedShapes script to make this process automatically. Tested several times and working with nuke 6, 7, 8 versions. This code also work with roto shapes imported from silhouette and mocha.

How to use:

Select the roto shapes need to extract make sure your roto node selected.


Run the script. This script will prompt you to choose the output method. User can extract the selected shapes into one roto node or each shape into separate node.



If user choose single this code copy paste selected shapes into single roto node.


Master roto node remain same.


 
If user choose each, this code create multiple roto node and copy paste selected shapes into newly created roto nodes.


extractSelectedShapes also link the track info if master roto have roto information on root layer. So no need to worry about linking track info.

Sample video:



Hope this code help you friends. enjoy :)

For bugs and future request send mail to satheesrev@gmail.com.

Download: http://www.nukepedia.com/python/misc/extractselectedshape

Original code:

### created by satheesh-r July 2014
### to extract selected roto shapes from selected roto node. Tested with nuke 6,7,8.
### for bugs and reports: satheesrev@gmail.com

import nuke, nukescripts

def extractSelectedShapes():
    panel = nuke.Panel("extractSelectedShapes", 200)
    panel.addEnumerationPulldown('shapes goes to:\nroto node', 'single each')
    panel.addButton("cancel")
    panel.addButton("ok")
    showPanel = panel.show()
    userChoice = panel.value('shapes goes to:\nroto node')
    if showPanel == 0:
        return
    if showPanel == 1:
        selNode = None
        try:
            selNode = nuke.selectedNode()
            selXpos = selNode.xpos()
            selYpos = selNode.ypos()
        except ValueError: # no node selected
            pass

        if selNode:
            if userChoice == 'single':
                newRotoNode = nuke.nodes.Roto()
                newRotoNode['xpos'].setValue(selXpos+200)
                newRotoNode['ypos'].setValue(selYpos)
                newRotoNode['curves'].rootLayer.setTransform(selNode['curves'].rootLayer.getTransform())
                for selShape in selNode['curves'].getSelected():
                    shapeName = selShape.name
                    newRotoNode.setName(shapeName)
                    newRotoNode['curves'].rootLayer.append(selShape.clone())
            if userChoice == 'each':
                for selShape in selNode['curves'].getSelected():
                    selXpos = selXpos + 200
                    shapeName = selShape.name
                    newRotoNode = nuke.nodes.Roto()
                    newRotoNode['curves'].rootLayer.setTransform(selNode['curves'].rootLayer.getTransform())
                    newRotoNode['xpos'].setValue(selXpos)
                    newRotoNode['ypos'].setValue(selYpos)
                    newRotoNode.setName(shapeName)
                    newRotoNode['curves'].rootLayer.append(selShape.clone())

        else:
            nuke.message('
make sure you have selected your roto node\n
then try again :)')






 

Sunday, April 27, 2014

Inbetweener for silhouette

Inbetweener


Silhouette don't have the very use-full keyboard short-cut for jump half-way between frames like other software's have (nuke). In nuke you can jump half way through between key frames and frames by hitting 'alt+arrow' keys. But this future is missing inside silhouette.

One of my friend requested me to write script for jumping half way through between frames inside silhouette. Also he mentioned this will going to be more use-full for roto artists. So I have created this scripts months ago and like to share with public. Hoping this will help you friends.

This is what this script will do....


Keyboard short-cuts:

alt+x for forward.
alt+z for backward.


Tested several months. Working fine with Silhouette v5 plus, v4 plus not tested in previous versions.

For bugs and reports - satheesrev@gmail.com.

download scripts:

inbetweener


Installation:
download the scripts and Copy paste it into....

Linux:  /opt/SilhouetteFX/silhouette v5.1/resources/scripts/
you have to change permission to copied file. Run this command in shell...  chmod 777 -R rename_shapes.py

Windows: /opt/SilhouetteFX/silhouette v5.1/resources/scripts/
restart silhouette.

Wednesday, March 26, 2014

extractAlpha.py

extractAlpha.py

Usually we use "Shuffle" node to extract alpha from ID mattes. Some of us use "Expression" node to do the same thing. Some time we need to use basic maths function in "Expression" node to get exact matte. This code create 'Expression' node and feed the value from the window. It also clamp the value. So no need to worry about the clamp issue.

Example maths function: r, (r+b)-g, (r+g+b), (r-g)

This code will pop-up small window like below image.,



User can select maths function from the list of drop-down menu. Most of the maths function's are pre-defined and stored on the UserChoice menu. This code allow user to feed their custom maths function. If user feed anything on custom math field this code will take the code and feed the info into the expression node.

Below video will explain how the function works:




Hope this will help you friends.,

Download:  https://drive.google.com/file/d/0BzfeLEFhrh44WFRjU1lYLU1fODQ/edit?usp=sharing

nukepedia: extractalpha.py


Raw code:

'''
Created on 26-March-2014
@author: satheesh-R
mail - satheesrev@gmail.com
'''

import nuke

def extractAlpha():
    ea = nuke.Panel("extractAlpha.... by satheesh-R", 350)
    ea.addEnumerationPulldown('UserChoice:\n(pre-defined math)', 'none r g b a r+g+b r+g+b+a r+g r+b g+b r-g r-b g-b (r+g)-b (r+b)-g (g+b)-r')
    math = ea.addSingleLineInput('custom Math:', '')
    ea.addButton("cancel")
    ea.addButton("ok")
    show = ea.show()
    outChannel = ea.value('UserChoice:\n(pre-defined math)')
    customMath = ea.value('custom Math:')
    print outChannel
    if show == 0:
        return
    if customMath:
        exp = nuke.createNode('Expression')
        exp['expr3'].setValue('clamp('+customMath+')')
        exp['label'].setValue(customMath+'  to  alpha')
    else:
        if outChannel == 'none':
            return
        else:
            exp = nuke.createNode('Expression')
            exp['expr3'].setValue('clamp('+outChannel+')')
            exp['label'].setValue(outChannel+'  to  alpha')

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 ...