Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # finding merges and sorting them in ascending manner
- def find_merges():
- node_class = "Merge2"
- merge_list = [i for i in nuke.selectedNodes() if i.Class() in node_class]
- merge_nodes = []
- for i in merge_list: # getting names of the merge nodes
- mergeName = i.name()
- merge_nodes.append(mergeName)
- merge_nodes.sort()
- return merge_nodes
- print find_merges()
- # Building crops
- def deploy_crops():
- # Getting root formats
- f = nuke.root().format()
- rootWidth = int(f.width())
- rootHeight = int(f.height())
- if len(find_merges())== 0 :
- nuke.message("No nodes selected")
- elif len(find_merges())>0 :
- p = nuke.Panel('Crops format')
- p.addSingleLineInput('Width', rootWidth)
- p.addSingleLineInput('Height', rootHeight)
- ret = p.show()
- width_input = int(p.value('Width'))
- height_input = int(p.value('Height'))
- cropCount = 0
- for n in find_merges():
- node = nuke.toNode(n)
- nuke.selectAll()
- nuke.invertSelection()
- node.setSelected(True)# selecting the node to insert the crop
- boxWidth = int(nuke.value(n+ ".bbox.w"))
- boxHeight =int(nuke.value(n+ ".bbox.h"))
- print boxWidth, boxHeight
- if boxWidth > width_input or boxHeight > height_input :
- cropNode = nuke.createNode('Crop')
- cropNode['box'].setValue((0, 0, width_input, height_input))
- cropNode.knob('reformat').setValue(True)
- cropCount = cropCount+1
- nuke.selectAll()
- nuke.invertSelection()
- else:
- pass
- nuke.message("%s crops deployed." % (cropCount))
- deploy_crops()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement