No Description
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.

playInRV.py 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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(node, 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. file = node.knobs()['file'].getValue()
  24. useshotenv = node.knobs()['useshotenv'].getValue()
  25. my_env = os.environ.copy()
  26. if useshotenv == 0:
  27. try:
  28. del my_env['PREFIX']
  29. del my_env['SEQ']
  30. del my_env['SHOT']
  31. except:
  32. pass
  33. try:
  34. rvpush = my_env['RV'] + 'rvpush'
  35. print(('playInRV: Info. Using RV: %s') % rvpush)
  36. except:
  37. print('playInRV: Error. No env variable RV found. Exiting.')
  38. return
  39. try:
  40. rv_gen_workgroup = my_env['RV_GEN_WORKGROUP']
  41. except:
  42. print('playInRV: Error. No env variable RV_GEN_WORKGROUP found. Exiting.')
  43. return
  44. try:
  45. root3d = my_env['PROJECT_ROOT_3D']
  46. print(('playInRV: Info. Using JOB: %s') % root3d)
  47. except:
  48. print('playInRV: Warning. No env variable job found.')
  49. my_env['JOB'] = 'GEN'
  50. try:
  51. dev = my_env['DEV']
  52. print(('playInRV: Info. Using dev: %s') % dev)
  53. except:
  54. print('playInRV: Warning. No env variable dev found. Setting pub.')
  55. my_env['DEV'] = "0"
  56. # check with default project without dev/pub structure
  57. if my_env['JOB'] == 'GEN':
  58. pass
  59. if my_env['DEV'] == "0":
  60. my_env['RV_SUPPORT_PATH'] = rv_gen_workgroup.replace('"', '').replace('\\', '/') + ';' + root3d.replace('"', '').replace('\\', '/') + '/000_env/rv/'
  61. else:
  62. my_env['RV_SUPPORT_PATH'] = rv_gen_workgroup.replace('"', '').replace('\\', '/') + ';' + root3d.replace('"', '').replace('\\', '/') + '/000_dev/rv/'
  63. print(('playInRV: Info. Using RV Workgroup: %s') % my_env['RV_SUPPORT_PATH'])
  64. if nuke.root()['colorManagement'].value().lower() != 'ocio':
  65. pass
  66. else:
  67. if nuke.root()['OCIO_config'].value() == 'custom':
  68. if nuke.root()['customOCIOConfigPath'].value() != "":
  69. my_env['OCIO'] = nuke.root()['customOCIOConfigPath'].value()
  70. else:
  71. my_env['OCIO'] = 'c:/Program Files/Nuke' + nuke.NUKE_VERSION_STRING + '/plugins/OCIOConfigs/configs/' + \
  72. nuke.root()['OCIO_config'].value() + '/config.ocio'
  73. print(('playInRV: Info. Using OCIO config %s') % my_env['OCIO'])
  74. # check modes
  75. if mode == 0:
  76. # new RV
  77. # get a random string for a random rv id
  78. rnd = random.choice('abcdefghijklmnopqrstuvwxyz')
  79. subprocess.call([rvpush, '-tag', rnd, 'set', file], env=my_env)
  80. pass
  81. elif mode == 1:
  82. # sets / replaces the source of the connected rv
  83. subprocess.call([rvpush, '-tag', 'nukeKeller', 'set', file], env=my_env)
  84. pass
  85. elif mode == 2:
  86. # appends to the connected rv
  87. subprocess.call([rvpush, '-tag', 'nukeKeller', 'merge', file], env=my_env)
  88. pass
  89. return
  90. # test in nuke
  91. #file = nuke.toNode('Write1').knob('file').getValue()
  92. #playInRV(file, 1)