暫無描述
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

frawExporter.py 2.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. class FrawExporter(KellerNukePlugin):
  2. def configurePlugin(self):
  3. self.menu = nuke.menu("Animation")
  4. self.menu.addCommand("Export fraw...", "frawExporter.export_fraw()")
  5. def unconfigurePlugin(self):
  6. self.menu.removeItem("Export fraw...")
  7. pass
  8. class ExportPanel(nukescripts.PythonPanel):
  9. def __init__(self):
  10. nukescripts.PythonPanel.__init__(self, 'Export fraw...')
  11. self.knob_startframe = nuke.Int_Knob("Start Frame")
  12. self.knob_startframe.setValue(nuke.Root()["first_frame"].getValue())
  13. self.addKnob(self.knob_startframe)
  14. self.knob_endframe = nuke.Int_Knob("End Frame")
  15. self.knob_endframe.setValue(nuke.Root()["last_frame"].getValue())
  16. self.addKnob(self.knob_endframe)
  17. self.knob_file = nuke.File_Knob("File")
  18. self.addKnob(self.knob_file)
  19. def _writeFile(contents, file):
  20. s = "%s 2" % str(len(contents))
  21. for cont in contents:
  22. s = s + "\n%.5f %.5f 0.00000 0.00000" % (cont[0], cont[1])
  23. #print s
  24. f = open(file, "w")
  25. f.write(s)
  26. f.close()
  27. def export_fraw():
  28. knob = nuke.thisKnob()
  29. p = ExportPanel()
  30. ret = p.showModalDialog()
  31. start = p.knob_startframe.getValue()
  32. end = p.knob_endframe.getValue()
  33. fps = float(nuke.Root()["fps"].getValue())
  34. filename = p.knob_file.getValue()
  35. if isinstance(knob, nuke.Array_Knob):
  36. for comp in range(knob.width()):
  37. contents = list()
  38. for i in range(start, end+1):
  39. time = float(i)/fps
  40. chval = knob.valueAt(int(i))[comp]
  41. contents.append( (time,chval) )
  42. _writeFile(contents, os.path.join( os.path.dirname(filename),str(comp)+ "_" + os.path.basename(filename)))
  43. else:
  44. contents = list()
  45. for i in range(start, end+1):
  46. time = float(i)/fps
  47. chval = knob.valueAt(int(i))
  48. contents.append((time,chval))
  49. _writeFile(contents, filename)
  50. #file = p.knob_file.getValue()
  51. #f = open(file, "w")
  52. #f.write(s)
  53. #f.close()