Keine Beschreibung
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

convertGizmosToGroups.py 2.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #https://github.com/dekekincaid/nuke.env/blob/master/python/convertGizmosToGroups.py
  2. import nuke
  3. import nukescripts
  4. def convertGizmosToGroups():
  5. ###Node Selections
  6. nodeSelection = nuke.selectedNodes()
  7. noGizmoSelection = []
  8. gizmoSelection = []
  9. for n in nodeSelection:
  10. if 'gizmo_file' in n.knobs():
  11. gizmoSelection.append(n)
  12. else:
  13. noGizmoSelection.append(n)
  14. groupSelection = []
  15. for n in gizmoSelection:
  16. bypassGroup = False
  17. ###Current Status Variables
  18. nodeName = n.knob('name').value()
  19. nodeXPosition = n['xpos'].value()
  20. nodeYPosition = n['ypos'].value()
  21. nodeHideInput = n.knob('hide_input').value()
  22. nodeCached = n.knob('cached').value()
  23. nodePostageStamp = n.knob('postage_stamp').value()
  24. nodeDisable = n.knob('disable').value()
  25. nodeDopeSheet = n.knob('dope_sheet').value()
  26. nodeDependencies = n.dependencies()
  27. nodeMaxInputs = n.maxInputs()
  28. inputsList = []
  29. ###Current Node Isolate Selection
  30. for i in nodeSelection:
  31. i.knob('selected').setValue(False)
  32. n.knob('selected').setValue(True)
  33. nuke.tcl('copy_gizmo_to_group [selected_node]')
  34. ###Refresh selections
  35. groupSelection.append(nuke.selectedNode())
  36. newGroup = nuke.selectedNode()
  37. ###Paste Attributes
  38. newGroup.knob('xpos').setValue(nodeXPosition)
  39. newGroup.knob('ypos').setValue(nodeYPosition)
  40. newGroup.knob('hide_input').setValue(nodeHideInput)
  41. newGroup.knob('cached').setValue(nodeCached)
  42. newGroup.knob('postage_stamp').setValue(nodePostageStamp)
  43. newGroup.knob('disable').setValue(nodeDisable)
  44. newGroup.knob('dope_sheet').setValue(nodeDopeSheet)
  45. ###Connect Inputs
  46. for f in range(0, nodeMaxInputs):
  47. inputsList.append(n.input(f))
  48. for num, r in enumerate(inputsList):
  49. newGroup.setInput(num, None)
  50. for num, s in enumerate(inputsList):
  51. newGroup.setInput(num, s)
  52. n.knob('name').setValue('temp__'+nodeName+'__temp')
  53. newGroup.knob('name').setValue(nodeName)
  54. newGroup.knob('selected').setValue(False)
  55. ###Cleanup (remove gizmos, leave groups)
  56. for y in gizmoSelection:
  57. y.knob('selected').setValue(True)
  58. nukescripts.node_delete(popupOnError=False)
  59. for z in groupSelection:
  60. z.knob('selected').setValue(True)
  61. for w in noGizmoSelection:
  62. w.knob('selected').setValue(True)