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

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