Нет описания
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. KNOBNAME_KEEP = "keep"
  2. KNOBNAME_DELETE = "delete"
  3. nodeTemplate = """
  4. Group {
  5. name MetaDataCleaner
  6. addUserKnob {20 properties l Properties}
  7. addUserKnob {1 delete l "Delete" t}
  8. addUserKnob {1 keep l "Keep" t}
  9. addUserKnob {26 ""}
  10. knobChanged "metaDataCleaner.userKnobChanged()"
  11. }
  12. Input {
  13. inputs 0
  14. name Input1
  15. xpos 0
  16. }
  17. ModifyMetaData {
  18. metadata {
  19. }
  20. name ModifyMetaData
  21. xpos 0
  22. ypos 150
  23. }
  24. Output {
  25. name Output1
  26. xpos 0
  27. ypos 300
  28. }
  29. end_group
  30. """
  31. metaDataLineTemplate = """{remove "%s" ""}"""
  32. def createNode():
  33. from PySide2 import QtWidgets
  34. QtWidgets.QApplication.clipboard().setText(nodeTemplate)
  35. newNode = nuke.nodePaste("%clipboard%")
  36. nuke.addKnobChanged(userKnobChanged, node=newNode)
  37. pass
  38. def userKnobChanged():
  39. if ((nuke.thisKnob().name() == KNOBNAME_DELETE) or
  40. (nuke.thisKnob().name() == KNOBNAME_KEEP)):
  41. updateModifyMetadata()
  42. def updateModifyMetadata():
  43. # set values for each frame
  44. import shlex
  45. import fnmatch
  46. keeplist = shlex.split(nuke.thisNode().knob(KNOBNAME_KEEP).value())
  47. removelist = shlex.split(nuke.thisNode().knob(KNOBNAME_DELETE).value()) # get the metadata node
  48. metaKeys = list()
  49. for key in nuke.thisNode().input(0).metadata().keys():
  50. doKeep = False;
  51. # check for remove
  52. for keep in keeplist:
  53. if (checkPattern(keep, key)):
  54. # do nothing, keep this string
  55. doKeep =True;
  56. break;
  57. if (doKeep):
  58. continue;
  59. # check for remove
  60. for remove in removelist:
  61. if (checkPattern(remove, key)):
  62. # add to remove list
  63. metaKeys.append(metaDataLineTemplate % (key))
  64. # do the stuf
  65. mmd = nuke.allNodes(group=nuke.thisGroup(), filter="ModifyMetaData")[0]
  66. mmd["metadata"].fromScript("\n".join(metaKeys));
  67. def checkPattern(fnpattern, string):
  68. import fnmatch, re
  69. regex = fnmatch.translate(fnpattern)
  70. reobj = re.compile(regex)
  71. if (reobj.match(string) is not None):
  72. #nuke.debug(" checking: %s = %s: TRUE" % (fnpattern, string))
  73. return True
  74. #nuke.debug(" checking: %s = %s: FALSE" % (fnpattern, string))
  75. return False