Advertisement
Guest User

Untitled

a guest
Jul 16th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. # finding merges and sorting them in ascending manner
  2.  
  3. def find_merges():
  4.  
  5.  
  6. node_class = "Merge2"
  7. merge_list = [i for i in nuke.selectedNodes() if i.Class() in node_class]
  8.  
  9. merge_nodes = []
  10.  
  11.  
  12.  
  13. for i in merge_list: # getting names of the merge nodes
  14.  
  15. mergeName = i.name()
  16. merge_nodes.append(mergeName)
  17.  
  18. merge_nodes.sort()
  19.  
  20.  
  21.  
  22.  
  23. return merge_nodes
  24.  
  25. print find_merges()
  26.  
  27. # Building crops
  28. def deploy_crops():
  29.  
  30.  
  31. # Getting root formats
  32.  
  33.  
  34. f = nuke.root().format()
  35. rootWidth = int(f.width())
  36. rootHeight = int(f.height())
  37.  
  38.  
  39. if len(find_merges())== 0 :
  40. nuke.message("No nodes selected")
  41.  
  42. elif len(find_merges())>0 :
  43.  
  44. p = nuke.Panel('Crops format')
  45. p.addSingleLineInput('Width', rootWidth)
  46. p.addSingleLineInput('Height', rootHeight)
  47.  
  48. ret = p.show()
  49.  
  50. width_input = int(p.value('Width'))
  51. height_input = int(p.value('Height'))
  52.  
  53.  
  54.  
  55.  
  56. cropCount = 0
  57.  
  58. for n in find_merges():
  59.  
  60. node = nuke.toNode(n)
  61.  
  62. nuke.selectAll()
  63. nuke.invertSelection()
  64.  
  65. node.setSelected(True)# selecting the node to insert the crop
  66.  
  67.  
  68.  
  69. boxWidth = int(nuke.value(n+ ".bbox.w"))
  70. boxHeight =int(nuke.value(n+ ".bbox.h"))
  71.  
  72. print boxWidth, boxHeight
  73.  
  74.  
  75. if boxWidth > width_input or boxHeight > height_input :
  76. cropNode = nuke.createNode('Crop')
  77. cropNode['box'].setValue((0, 0, width_input, height_input))
  78. cropNode.knob('reformat').setValue(True)
  79. cropCount = cropCount+1
  80. nuke.selectAll()
  81. nuke.invertSelection()
  82.  
  83.  
  84. else:
  85.  
  86.  
  87. pass
  88.  
  89.  
  90. nuke.message("%s crops deployed." % (cropCount))
  91.  
  92.  
  93.  
  94. deploy_crops()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement