Няма описание
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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. from __future__ import print_function
  2. class playInRV(KellerNukePlugin):
  3. def configurePlugin(self):
  4. menubar = nuke.menu('Nuke')
  5. self.m = menubar.addMenu('Workgroup')
  6. self.m.addCommand('Play in RV', 'playInRV.playInRV()')
  7. self.m.addCommand('Play in RV (append)', 'playInRV.playInRV(append=true)')
  8. def unconfigurePlugin(self):
  9. self.m.removeItem('Play in RV')
  10. self.m.removeItem('Play in RV (append)')
  11. def playInRV(file, mode):
  12. """
  13. loads the file specified in the write node to a new or existing RV session
  14. rvlink:// -l -play /path/to/my/movie.mov
  15. attaches a tag to the rv instance which is used to append sources to the session
  16. TODO: Linux / MacOS Support
  17. TODO: Better logging
  18. """
  19. import os
  20. import subprocess
  21. import random
  22. import nuke
  23. my_env = os.environ.copy()
  24. try:
  25. rvpush = my_env['RV'] + 'rvpush'
  26. print(('playInRV: Info. Using RV: %s') % rvpush)
  27. except:
  28. print('playInRV: Error. No env variable RV found. Exiting.')
  29. return
  30. try:
  31. job = my_env['JOB']
  32. print(('playInRV: Info. Using JOB: %s') % job)
  33. except:
  34. print('playInRV: Warning. No env variable job found.')
  35. my_env['JOB'] = 'GEN'
  36. try:
  37. dev = my_env['DEV']
  38. print(('playInRV: Info. Using dev: %s') % dev)
  39. except:
  40. print('playInRV: Warning. No env variable dev found. Setting pub.')
  41. my_env['DEV'] = "0"
  42. # TODO: check 000_dev/000_env vs dev/pub
  43. # check with default project without dev/pub structure
  44. if my_env['JOB'] == 'GEN':
  45. pass
  46. if my_env['DEV'] == "0":
  47. my_env['RV_SUPPORT_PATH'] = job.replace('"', '').replace('\\', '/') + '/000_env/rv/'
  48. else:
  49. my_env['RV_SUPPORT_PATH'] = job.replace('"', '').replace('\\', '/') + '/000_dev/rv/'
  50. print(('playInRV: Info. Using RV Workgroup: %s') % my_env['RV_SUPPORT_PATH'])
  51. if nuke.root()['colorManagement'].value().lower() != 'ocio':
  52. pass
  53. else:
  54. if nuke.root()['OCIO_config'].value() == 'custom':
  55. if nuke.root()['customOCIOConfigPath'].value() != "":
  56. my_env['OCIO'] = nuke.root()['customOCIOConfigPath'].value()
  57. else:
  58. my_env['OCIO'] = 'c:/Program Files/Nuke' + nuke.NUKE_VERSION_STRING + '/plugins/OCIOConfigs/configs/' + \
  59. nuke.root()['OCIO_config'].value() + '/config.ocio'
  60. print(('playInRV: Info. Using OCIO config %s') % my_env['OCIO'])
  61. # check modes
  62. if mode == 0:
  63. # new RV
  64. # get a random string for a random rv id
  65. rnd = random.choice('abcdefghijklmnopqrstuvwxyz')
  66. subprocess.call([rvpush, '-tag', rnd, 'set', file], env=my_env)
  67. pass
  68. elif mode == 1:
  69. # sets / replaces the source of the connected rv
  70. subprocess.call([rvpush, '-tag', 'nukeKeller', 'set', file], env=my_env)
  71. pass
  72. elif mode == 2:
  73. # appends to the connected rv
  74. subprocess.call([rvpush, '-tag', 'nukeKeller', 'merge', file], env=my_env)
  75. pass
  76. return
  77. # test in nuke
  78. #file = nuke.toNode('Write1').knob('file').getValue()
  79. #playInRV(file, 1)