Nenhuma descrição
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

read_from_write.py 2.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. ## read_from_write.py
  2. ##
  3. ## written by stefan ihringer (stefan@bildfehler.de)
  4. ## parts by Diogo Girondi (diogogirondi@gmail.com) http://www.creativecrash.com/nuke/downloads/scripts-plugins/c/read-from-write
  5. ##
  6. ## version 1.0 (2010-06-07)
  7. ## version 1.1 Martin Saechsinger: fixed colorspace when using OCIO.
  8. import nuke
  9. import os, re
  10. def _get_directory(rawpath):
  11. """
  12. Make a path cross-platform by replacing network shares
  13. """
  14. path = rawpath
  15. if (nuke.env["WIN32"]):
  16. path = path.replace("/Volumes/O/", "//calculon/o/")
  17. path = path.replace("/","\\")
  18. else:
  19. path = path.replace("//calculon/o/", "/Volumes/O/")
  20. return os.path.dirname(path)
  21. def _hashreplace(match):
  22. """
  23. Internally called by regular expression.
  24. Replaces #### by %04d (or any other number of hashes)
  25. """
  26. return "%%0%dd" % len(match.group())
  27. def ReadFromWrite():
  28. """
  29. Creates a read node from a selected write node.
  30. """
  31. try:
  32. the_node = nuke.selectedNode()
  33. if the_node.Class() != "Write":
  34. nuke.message("Please select a write node.")
  35. return
  36. except:
  37. nuke.message("Please select a write node.")
  38. return
  39. # get values from Write knobs
  40. filestr = the_node.knob("file").value()
  41. proxystr = the_node.knob('proxy').value()
  42. colorstr = int(the_node.knob('colorspace').getValue())
  43. #colorstr = the_node.knob('colorspace').value()
  44. premult = the_node.knob('premultiplied').value()
  45. rawdata = the_node.knob('raw').value()
  46. xpos = the_node.knob('xpos').value()
  47. ypos = the_node.knob('ypos').value()
  48. # #-Zeichen finden (falls vorhanden) und durch ein Konstrukt wie %04d ersetzen.
  49. filestr = re.sub("#+", _hashreplace, filestr)
  50. # Dateiliste holen um automatisch ersten und letzten Frame zu erkennen
  51. # (von http://www.vfxtalk.com/forum/showpost.php?p=79846&postcount=15)
  52. expaddpatt = re.compile(r"(?<=\.)\d*(?=\.)")
  53. paddpatt = re.compile(r'%+\d+d')
  54. try:
  55. padding = paddpatt.search(filestr).group()
  56. seqlist = sorted(glob.glob(paddpatt.sub("*",filestr)))
  57. start = int(padding % (int(expaddpatt.search(seqlist[0]).group())))
  58. end = int(padding % (int(expaddpatt.search(seqlist[-1]).group())))
  59. except:
  60. # wenn Sequenzlaenge nicht ermittelbar (z.B. kein Dateiname in der write-node)
  61. # wird als default die Shotlaenge verwendet:
  62. start = int(nuke.root().knob('first_frame').value())
  63. end = int(nuke.root().knob('last_frame').value())
  64. new_read = nuke.nodes.Read(file = filestr, proxy = proxystr, first = start, last = end, colorspace = colorstr, premultiplied = premult, raw = rawdata)
  65. new_read.knob('xpos').setValue(xpos + 80)
  66. new_read.knob('ypos').setValue(ypos + 80)
  67. nuke.inputs(new_read, 0)