Skip to content

Instantly share code, notes, and snippets.

View sanfx's full-sized avatar
🎯
Focusing

Sanjeev Kumar sanfx

🎯
Focusing
  • London
  • 01:23 (UTC +01:00)
View GitHub Profile
from PyQt4 import QtCore,QtGui
from tableModel import TableModel
#import tableModel.TableModel as PaletteTableModel
import sys
class PaletteListModel(QtCore.QAbstractListModel):
def __init__(self, colors = [], parent = None):
super(PaletteListModel,self).__init__(parent)
self.__colors = colors
@sanfx
sanfx / sequenceExists.py
Last active December 16, 2015 04:08
Checks if sequence exist on disk. seqPath = image sequence path example: J:/Footages/33x01_02a/33x01_02a.%04d.sgi where %04d can be any sequence like 0001-0265, 231-689 but not KFd001- KFd567 string change buildPath at line 21 to customize for compatibility frstFrame = First frame as string lastFrame = Last frame as string
import os
def sequenceExists(seqPath, firstFrame, lastFrame, sep=None):
""" Checks if sequence exist on disk.
seqPath (string): image sequence path
example: J:/Footages/33x01_02a/33x01_02a.%04d.sgi
where %04d can be any sequence like 0001-0265, 231-689 but not KFd001- KFd567 string
change buildPath at line 21 to customize for compatibility
@sanfx
sanfx / namedBackDrop.py
Last active December 18, 2015 12:59
this simple script creates backdrop for selected nodes and name it based on the read node in selection.
import nuke
sel = nuke.selectedNodes()
if sel:
# create backdrop for selection
bckDrop = nukescripts.autoBackdrop()
for eachNode in sel:
if eachNode.Class() == 'Read':
bckDrop.setName(eachNode.name(), uncollide=True)
else:
import nuke
y = [os.path.dirname(each['file'].getValue()) for each in nuke.selectedNodes() if each.Class() == 'Read' and not os.path.exists(os.path.dirname(each['file'].getValue()))]
sa = nuke.Panel("printFilePath", 600)
sa.addMultilineTextInput("Error'd Read Nodes","\n".join(y))
@sanfx
sanfx / orderListAsinDAG.py
Created July 27, 2013 03:12
Set the node order in list same as order in DAG
def orderSelectionToList():
""" Set the node order in list same as order in DAG
Returns:
selNodes(List): sorted node order in list as in DAG
"""
selNodes = nuke.selectedNodes()
lastNode = nuke.selectedNode()
if lastNode.dependencies()[0] in selNodes:
return list(reversed(selNodes))
else:
@sanfx
sanfx / moveUp.py
Created July 27, 2013 04:02
move bunch of selected node up
if orderSelectionToList()[0].dependencies()[0].Class() == 'Read':
nuke.message("Cannot Move up further to %s" % orderSelectionToList()[0].dependencies()[0].name())
else:
selection = orderSelectionToList()
lastNode = orderSelectionToList()[-1]#.dependent()[0]
lastNodeDep = orderSelectionToList()[-1].dependent()[0]
moveNode = orderSelectionToList()[0].dependencies()[0]
[each.setSelected(False) for each in orderSelectionToList()]
moveNode.setSelected(True)
nuke.extractSelected()
@sanfx
sanfx / deleteRead.py
Created July 29, 2013 11:36
delete unused read nodes in nuke
for each in nuke.allNodes('Read'):
if not len(each.dependent()):
if not each.maxOutputs() == 0:
print nuke.delete(each)
# Add Custom menu for scripts
menubar=nuke.menu("Nodes")
m=menubar.addMenu("San")
# Add Python scripts to the custom menu
m.addCommand("Move Up", "import moveupdown; \
moveupdown.moveUp()", icon="PostageStamp.png")
m.addCommand("Move Down", "import moveupdown; \
sel = nuke.selectedNode()
for i in range(0, sel.inputs()):
print "input %s of %s is connected to %s " % (i, sel.name(), sel.input(i).name())
@sanfx
sanfx / filterList.py
Created October 12, 2013 00:58
This script is for purpose to explain how logging works as well how mox testing done; see test_filterList.py
import sys
import ast
import logging
class ItemNotString(Exception):
pass
class FilterList(object):