Advertisement
jedypod

fcpxml_to_nuke

Jun 13th, 2012
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 21.49 KB | None | 0 0
  1. '''
  2. FCP XML to Nuke
  3. v1.3 -
  4.     Made support for Premiere FCPXML format more robust. Premiere FCP XML stores all sequences in the project, whereas
  5. Final Cut Pro's XML format stores only a single sequence. I added a box that lets you choose what sequence
  6. of the Premiere XML file to process, and it should work more reliably now.
  7.     Added support for transfer of linear TimeRemaps, Translates, Scales, and Rotates into Nuke.
  8.     Also transfers framerate for each clip, and many other improvements.
  9. v1.0 - Initial release.
  10.  
  11. This script takes a Final Cut XML file with a single flattened video track, and builds Nuke scripts for each clip in the timeline.
  12. It is intended as a simple way to automate workflows between FCP/Premiere and Nuke.
  13. It creates a Nuke script with global first and last frame set, a frameRange node with the proper framerange, and a Write node
  14. set to the output path.
  15. There is an option for creating subdirectories for every Nuke script created. Handles are also an option.
  16. It can parse reel number and clip number from Red and Alexa footage, or can use the clip filename as the base naming for the output files.
  17.  
  18. This script was somewhat inspired by compflows.blogspot.com, but has been written from scratch and is a bit more flexible (although it only goes from XML->NukeScripts and not from renders back to an XML at the moment).
  19. This has only been tested on OSX, but in theory should be cross-platform compatible. Comments and suggestions are welcome!
  20.  
  21. # The menu.py example entry below adds this script in a folder called "Scripts" in your toolbar.
  22. import fcpxml_to_nuke
  23. nuke.toolbar('Nodes').addMenu('Scripts').addCommand('FCP XML to Nuke', 'fcpxml_to_nuke.process_xml()')
  24. '''
  25.  
  26. import nuke, os
  27. from xml.dom.minidom import parse
  28.  
  29. def process_xml():
  30.     '''
  31.     Imports an FCP XML file, locates each clip in the timeline on Track 1,
  32.     and for each clip, builds a nuke script for that file and puts it in the output directory specified
  33.  
  34.     New Features that would be nice to have:
  35.     Customized naming patterns based on reel/clip number.
  36.     Handle FCP XML from Premiere or FCP / FCPX ( Are there differences in the XML structure for these? )
  37.     Choose additional output naming and directory formatting patterns
  38.     '''
  39.  
  40.     # Build the Nuke Panel where locations and stuff is specified.
  41.     p = nuke.Panel("FCP XML Import")
  42.     xml_file = 'FCP XML To Import'
  43.     output_dir = 'Directory to Output Nuke Scripts'
  44.     subdirectories = 'Create subdirectories for each script?'
  45.     render_dir = 'Render Directory for All Write Nodes'
  46.     handle_length = "0 5 10 15 20 30 35 40"
  47.     clip_name_format = "Bypass RED Alexa"
  48.  
  49.     p.addFilenameSearch("FCP XML File", xml_file)
  50.     p.addBooleanCheckBox("Create subdirectories for each script", subdirectories)
  51.     p.addFilenameSearch("Output Directory", output_dir)
  52.     p.addFilenameSearch("Render Directory", render_dir)
  53.     p.addEnumerationPulldown("Handle Length", handle_length)
  54.     p.addEnumerationPulldown("Clip Name Format", clip_name_format)
  55.     p.setWidth(600)
  56.     if not p.show():
  57.         return
  58.  
  59.     # Assign vars from Nuke Panel user-entered data
  60.     xml_file    = p.value("FCP XML File")
  61.     output_dir  = p.value("Output Directory")
  62.     subdirectories = p.value("Create subdirectories for each script")
  63.     render_dir  = p.value("Render Directory")
  64.     handle_length = int( p.value("Handle Length") )
  65.     clip_name_format = p.value("Clip Name Format")
  66.  
  67.     # Create paths for render directory if it does not exist
  68.     if not os.path.isdir(render_dir):
  69.         os.mkdir(render_dir)
  70.     if not os.path.isdir(output_dir):
  71.         os.mkdir(output_dir)
  72.  
  73.  
  74.     ############################
  75.     # Begin Parsing XML File
  76.     ############################
  77.     dom = parse( xml_file )
  78.  
  79.     # Prompt user to choose which sequence to process, because Premiere's XML export includes all sequences.
  80.     # Much of this complexity is to handle sequences with spaces in their names, because the nuke.panel
  81.     # addEnumerationPulldown is space-demarcated. The logic below handles spaces in sequence names and allows the user
  82.     # to choose which sequence to process, and stores the sequence to process as a variable to access
  83.  
  84.     sequences = []
  85.     i = 0
  86.     # Makes a list of all sequence names
  87.     for seq in dom.getElementsByTagName('sequence'):
  88.         seqname = seq.getElementsByTagName('name')[0].firstChild.data
  89.         sequences.append( [seqname] )
  90.         # If a sequence name has space characters, replace them with underscores for the Nuke enumeration pulldown panel
  91.         if seqname.find(' ') != -1:
  92.             sequences[i].append( seqname.replace(' ', '_') )
  93.         i += 1
  94.     print "Sequences are: ", sequences
  95.     # ??? Do all of the below messy work to prepare for deciding between multiple sequences, including dealing with spaces in sequence names
  96.     # but only if there is more than one sequence in the XML file. If not, we'll just set the 'row' var to 0, and roll with that.
  97.     if len(sequences) > 1:
  98.         # Makes a " " demarcated string with all sequence names for the nuke enumeration pulldown panel
  99.         seq_enum = ''
  100.         i = 0
  101.         for seq in sequences:
  102.             if len(sequences[i]) == 1:
  103.                 seq_enum += sequences[i][0] + ' '
  104.             else:
  105.                 seq_enum += sequences[i][1] + ' '
  106.             i += 1
  107.  
  108.         # Create a Nuke panel for the user to choose which sequence to process
  109.         seq_panel = nuke.Panel("Choose Sequence To Process")
  110.         seq_panel.addEnumerationPulldown("Choose Sequence", seq_enum)
  111.         seq_panel.setWidth(400)
  112.         if not seq_panel.show():
  113.             return
  114.         chosen_sequence = seq_panel.value("Choose Sequence")
  115.  
  116.         # Gets the index of the chosen sequence in the list of sequences, stores the sequence XML object as a variable
  117.         for row, i in enumerate(sequences):
  118.                 try:
  119.                     column = i.index( chosen_sequence )
  120.                 except ValueError:
  121.                     continue
  122.                 break
  123.     else:
  124.         row = 0
  125.     chosen_seqobj = dom.getElementsByTagName('sequence')[row]
  126.     print "Chosen sequence is: ", chosen_seqobj.getElementsByTagName('name')[0].firstChild.data
  127.  
  128.     seq_res_x = int( chosen_seqobj.getElementsByTagName('format')[0].getElementsByTagName('width')[0].firstChild.data )
  129.     seq_res_y = int( chosen_seqobj.getElementsByTagName('format')[0].getElementsByTagName('height')[0].firstChild.data )
  130.     print "Sequence resolution is ", seq_res_x,"x",seq_res_y
  131.  
  132.     # Set optional effect parameters to False
  133.     timeremap_value = False
  134.     scale_value = False
  135.     x_move = False
  136.     y_move = False
  137.     rotation_value = False
  138.     fps = 97
  139.  
  140.     seq_clip_number = 1
  141.     track = chosen_seqobj.getElementsByTagName('track')[0]
  142.     for clip in track.getElementsByTagName('clipitem'):
  143.         # This loop performs the following for each clip on the first Track of the chosen Sequence.
  144.         masterclipid    = clip.getElementsByTagName('masterclipid')[0].firstChild.data
  145.         clip_name       = clip.getElementsByTagName("name")[0].firstChild.data
  146.         in_point        = int( clip.getElementsByTagName('in')[0].firstChild.data )
  147.         out_point       = int( clip.getElementsByTagName('out')[0].firstChild.data )
  148.         clip_duration   = int( clip.getElementsByTagName("duration")[0].firstChild.data )
  149.        
  150.         # Fetch the pathurl of the clip by cycling through all <pathurl> nodes and comparing the filename of the clip to the clip_name
  151.         # This is necessary because in Premiere XMLs, the pathurl for a clip is not always stored in the clipitem node, but rather in a seperate node in the master-clip
  152.        
  153.         #??? Instead: Check for pathurl node in current clip node. If it doesn't exist, cycle through all
  154.         # clipitem nodes to find another that matches the name node with the current clip_name.
  155.         # If it finds a matching named clipitem, search for a pathurl in that node.
  156.         try:
  157.             file_path = clip.getElementsByTagName('pathurl')[0].firstChild.data.split("file://localhost")[1].replace("%20", " ")
  158.             fps = float(clip.getElementsByTagName('timebase')[0].firstChild.data)
  159.         except:
  160.             print 'Failed to get pathurl in current clipitem. Searching other clipitems for matching name.'
  161.             for pathurl_clip in dom.getElementsByTagName('clipitem'):
  162.                 if pathurl_clip.getElementsByTagName('name')[0].firstChild.data == clip_name:
  163.                     try:
  164.                         file_path = pathurl_clip.getElementsByTagName('pathurl')[0].firstChild.data.split("file://localhost")[1].replace("%20", " ")
  165.                         fps = float(pathurl_clip.getElementsByTagName('timebase')[0].firstChild.data)
  166.                         break
  167.                     except:
  168.                         continue
  169.         print clip_name, in_point, out_point, clip_duration, file_path, fps
  170.  
  171.         # Get resolution of this clip in the clipitem node,
  172.         # Else, look for a masterclip with the same name and try to get the resolution from there, Else: fail?
  173.         try:
  174.             clip_width = int( clip.getElementsByTagName('width')[0].firstChild.data )
  175.             clip_height = int( clip.getElementsByTagName('height')[0].firstChild.data )
  176.             print "Clip resolution is: ", clip_width, "x", clip_height
  177.         except:
  178.             for masterclip in dom.getElementsByTagName('clipitem'):
  179.                 if masterclip.getElementsByTagName('name')[0].firstChild.data == clip_name:
  180.                     #!!! This is triggered if a clip is used more than once in the sequence.
  181.                     try:
  182.                         #print "found master clip: ", masterclip.getElementsByTagName('name')[0].firstChild.data, " and "
  183.                         clip_width = int( masterclip.getElementsByTagName('width')[0].firstChild.data )
  184.                         clip_height = int( masterclip.getElementsByTagName('height')[0].firstChild.data )
  185.                         break
  186.                     except:
  187.                         continue
  188.         # Get all effects applied to this clip
  189.         for effect in clip.getElementsByTagName('effect'):
  190.             effect_name = effect.childNodes[1].firstChild.data
  191.             if effect_name == 'Time Remap':
  192.                 # Loop through all parameters of the effect
  193.                 for param in effect.getElementsByTagName('parameter'):
  194.                     param_id = param.childNodes[1].firstChild.data
  195.                     if param_id == 'speed':
  196.                         timeremap_value = float( param.getElementsByTagName('value')[0].firstChild.data )
  197.                         print effect_name, param_id, timeremap_value
  198.  
  199.             if effect_name == 'Basic Motion':
  200.                 for param in effect.getElementsByTagName('parameter'):
  201.                     param_id = param.childNodes[1].firstChild.data
  202.                     if param_id == 'scale':
  203.                         scale_value = float( param.getElementsByTagName('value')[0].firstChild.data )
  204.                         print effect_name, param_id, scale_value
  205.                     if param_id == 'rotation':
  206.                         rotation_value = float( param.getElementsByTagName('value')[0].firstChild.data )
  207.                         print effect_name, param_id, rotation_value
  208.                     if param_id == 'center':
  209.                         x_move = float( param.getElementsByTagName('value')[0].childNodes[1].firstChild.data )
  210.                         y_move = float( param.getElementsByTagName('value')[0].childNodes[3].firstChild.data )
  211.                         print effect_name, param_id, x_move, y_move
  212.                         '''
  213.                         So.... Figuring out how Premiere handles position values:
  214.                         Prem 0-0 clip is centered upper left: value = .5,.5
  215.                         prem 1920-1080, clip is centered lower right: value = .5 .5??
  216.                         prem 1060-640, value: 0.052083 0.092593
  217.                         prem center bottom: 960-1080, value: 0.0 0.5
  218.                         prem center top: 960 0, value: 0.0 -0.5
  219.                         prem UR 1919 0, value: 0.499479 -0.5
  220.                        
  221.                         location    x, y
  222.                         center      0, 0
  223.                         UL          -0.5, -0.5
  224.                         UR          0.5, -0.5
  225.                         LR          0.5, 0.5
  226.                         LL          0, 0.5
  227.                         y-up is negative
  228.                         x-right is positive
  229.                         The range from edge to edge of sequence space is 1.
  230.                         -.5 is left, .5 is right.
  231.                         -.5 is up, .5 is down.
  232.                         .125, 0 would be 1200x540 = (seq_res_x * x_move) = how many pixels to move from center) = 1920*.125 + 1920/2 = 1200
  233.                         for x: seq_res_x * x_move
  234.                         for y: seq_res_y * -y_move
  235.                         '''
  236.        
  237.         # Gets the shot name, which is the formatted clip_name with clip# and reel#, with the sequence clipnumber.
  238.         # uses camera type (Red, Alexa, etc), and the clip_name string (the filename of the clip used in FCP)
  239.         # Also takes the seq_clip_number for returning the correct shot_name (the name that will be used to name the nuke script)
  240.         if clip_name_format == 'RED':
  241.             # This works for Red footage of format: A###_C###_RANDOMDATA
  242.             reel_number = clip_name.split('_')[0][1:]
  243.             clip_number = clip_name.split('_')[1][1:]
  244.  
  245.         if clip_name_format == 'Alexa':
  246.             # Alexa footage is A###C###_######_R####
  247.             reel_number = int(clip_name.split('C')[0][1:])
  248.             clip_number = int( clip_name.split('C')[1].split('_')[0] )
  249.  
  250.         if clip_name_format == 'Bypass':
  251.             shot_name = "%02d0_%s" %(seq_clip_number, os.path.splitext(clip_name)[0])
  252.         else:
  253.             # shot_name is the string that defines the name that the nuke script is saved to. seq_clip_number+0_A{reelnumber}_C{clipnumber}
  254.             shot_name = "%02d0_A%sC%s" %(seq_clip_number, reel_number, clip_number)
  255.  
  256.  
  257.         ############################
  258.         # Build Nuke Script
  259.         ############################
  260.        
  261.         # if the subdirectories checkbox is checked, set the output_shotdir to be a subdirectory named with the shot_name
  262.         if subdirectories:
  263.             output_shotdir = output_dir
  264.             output_shotdir = os.path.join(output_dir, shot_name)
  265.         else:
  266.             output_shotdir = output_dir
  267.         # If the output_shotdir does not exist, create it (auto-creates subdirectories)
  268.         if not os.path.isdir(output_shotdir):
  269.                 os.mkdir(output_shotdir)
  270.  
  271.        
  272.         ###########################
  273.         # Compute values to plug into the Nuke Script
  274.  
  275.         # Compute Handles and set first_frame and last_frame
  276.         first_frame = in_point - handle_length
  277.         last_frame = out_point-1 + handle_length
  278.  
  279.         if timeremap_value:
  280.             '''
  281.             The XML gives us the duration of the original clip, and the in and out points of the retimed clip
  282.             originalIn = newIn * retime
  283.             originalOut = newOut * retime
  284.             new duration = lastFrame - first_frame
  285.             '''
  286.             timeremap_value     = timeremap_value/100
  287.             new_clip_duration   = last_frame - first_frame
  288.             clip_duration       = clip_duration * timeremap_value
  289.             first_frame         = first_frame * timeremap_value
  290.             last_frame          = first_frame + new_clip_duration
  291.            
  292.            
  293.         # Set Format
  294.         if seq_res_x == 1920 and seq_res_y == 1080:
  295.             fcp_xml_resolution = 'HD'
  296.         else:
  297.             fcp_xml_resolution = 'from_xml'
  298.  
  299.  
  300.         #!!! This creates a nuke script by appending text to the .nk file instead of using nuke.nodeCopy(), which is slow and messy, and so that root node settings can be added.
  301.         # The strings that are written are triple-quoted. newlines are created with '\n'. {} chars in the string have to be doubled so as not to throw a KeyError
  302.         nuke_file = os.path.join(output_shotdir, "%s_v001.nk"%(shot_name))
  303.         nuke_script = open(nuke_file, 'a+')
  304.         # Create Root node
  305.         nuke_script.write('''Root {{\n inputs 0\n name \"{0}\"\n project_directory \"\[python \{{nuke.script_directory()\}}]\"\n first_frame {1}\n last_frame {2}\n fps {6}\n format \"{3} {4} 0 0 {3} {4} 1 {5}\"\n proxy_type scale\n}}\n'''.format(nuke_file, first_frame, last_frame, seq_res_x, seq_res_y, fcp_xml_resolution, fps))
  306.         # Create Read node
  307.         nuke_script.write('''Read {{\n inputs 0\n file \"{0}\"\n first 0\n last {1}\n frame_mode offset\n frame 1\n origlast {1}\n origset true\n name Read1\n selected true\n xpos -425\n ypos -40\n}}\n'''.format(file_path, clip_duration))
  308.         # Create TimeRemap if there is retiming on the clip
  309.         if timeremap_value:
  310.             nuke_script.write('''
  311. Text {
  312. message "\[frame]"
  313. font /Library/Fonts/Arial.ttf
  314. yjustify center
  315. box {480 270 1440 810}
  316. translate {1314 -498}
  317. center {960 540}
  318. name FrameNumber
  319. selected true
  320. xpos -425
  321. ypos 42
  322. }
  323. ''')
  324.             nuke_script.write('''Group {{
  325. name RetimeFromFrame
  326. selected true
  327. addUserKnob {{20 Retime t "Retime From Frame Parameters"}}
  328. addUserKnob {{41 StartFrame l "SourceStart Frame" t "The source frame from which retiming starts. For example, if you have a clip that you are using a range from frames 200-300 in, and you want to retime that clip to be 50\% speed, you would set this to be 200. \\n\\nThis gizmo references the root.first_frame value to determine the \\\"in-point\\\" of the clip." T RetimeControls.StartFrame}}
  329. addUserKnob {{41 PlaybackSpeed l "Playback Speed" t "Retime speed as a fraction of one. That is, 0.5 = 50\% speed, 2 = 200\% speed." T RetimeControls.PlaybackSpeed}}
  330. }}
  331. Input {{
  332.  inputs 0
  333.  name Input1
  334.  xpos 0
  335. }}
  336. TimeOffset {{
  337.  time_offset {{{{-RetimeControls.StartFrame/RetimeScreen.timingSpeed}}}}
  338.  name Retime_TimeOffset
  339.  tile_color 0xff0000ff
  340.  xpos 0
  341.  ypos 132
  342. }}
  343. OFXuk.co.thefoundry.time.oflow_v100 {{
  344.  method Motion
  345.  timing Speed
  346.  timingFrame 1
  347.  timingSpeed {{{{RetimeControls.PlaybackSpeed}}}}
  348.  filtering Normal
  349.  warpMode Normal
  350.  correctLuminance false
  351.  automaticShutterTime false
  352.  shutterTime 0
  353.  shutterSamples 1
  354.  vectorDetail 0.2
  355.  smoothness 0.5
  356.  blockSize 6
  357.  Tolerances 0
  358.  weightRed 0.3
  359.  weightGreen 0.6
  360.  weightBlue 0.1
  361.  showVectors false
  362.  cacheBreaker false
  363.  name RetimeScreen
  364.  tile_color 0xff0000ff
  365.  selected true
  366.  xpos 0
  367.  ypos 156
  368. }}
  369. TimeOffset {{
  370.  time_offset {{{{root.first_frame}}}}
  371.  name GlobalStart_Offset
  372.  tile_color 0xff0000ff
  373.  xpos 0
  374.  ypos 180
  375. }}
  376. Output {{
  377.  name Output1
  378.  xpos 0
  379.  ypos 393
  380. }}
  381. NoOp {{
  382.  inputs 0
  383.  name RetimeControls
  384.  xpos -174
  385.  ypos 126
  386.  addUserKnob {{20 User}}
  387.  addUserKnob {{7 PlaybackSpeed l "Playback Speed" R 0 100}}
  388.  PlaybackSpeed {0}
  389.  addUserKnob {{3 StartFrame l "Start Frame" t "Offset video start frame"}}
  390.  StartFrame {1}
  391. }}
  392. end_group\n'''.format( timeremap_value, first_frame ))
  393.        
  394.         # Create FrameRange node
  395.         nuke_script.write('''FrameRange {{\n first_frame {0}\n last_frame {1}\n name FrameRange1\n label "\\[knob first_frame]-\\[knob last_frame]"\n selected true\n}}\n'''.format(first_frame, last_frame))
  396.        
  397.         # Create a Transform node with pans and scales, if they exist
  398.         if  scale_value or x_move or y_move or rotation_value:
  399.             if not scale_value:
  400.                 scale_value = 100
  401.             if not x_move:
  402.                 x_move = 0
  403.             if not y_move:
  404.                 y_move = 0
  405.             if not rotation_value:
  406.                 rotation_value = 0
  407.             # Create a reformat node if there are pans or scales
  408.             nuke_script.write('''Reformat {{
  409. resize none
  410. black_outside true
  411. name Reformat1
  412. selected true
  413. }}
  414. '''.format())
  415.             nuke_script.write( '''Transform {{
  416. translate {{{0} {1}}}
  417. rotate {2}
  418. scale {3}
  419. center {{{4} {5}}}
  420. name Transform1
  421. selected true
  422. }}
  423. '''.format( (seq_res_x * x_move), (seq_res_y * -y_move), -rotation_value, scale_value/100, seq_res_x/2, seq_res_y/2 ) )
  424.  
  425.         # Create Write node
  426.         nuke_script.write('''Write {{\n file \"{0}\"\n file_type mov\n codec apch\n fps 23.976\n checkHashOnRead false\n name Write1\n selected true\n}}\n'''.format('{0}_v001.mov'.format(os.path.join(render_dir, shot_name)) ) )
  427.         # Create Viewer node
  428.         nuke_script.write('''Viewer {\n name Viewer1\n selected true\n}\n''')
  429.         # Create Backdrop node
  430.         nuke_script.write('''BackdropNode {{\n inputs 0\n name BackdropNode1\n tile_color 0x26434dff\n label \"<img src=\\\"Read.png\\\"> Read Plate <br/><font size=1> {0} <br/> {1}-{2}<br/>{3} frame handles\"\n note_font_size 30\n selected true\n xpos -500\n ypos -150\n bdwidth 234\n bdheight 254\n}}\n'''.format(shot_name, in_point, out_point, handle_length))
  431.  
  432.         seq_clip_number += 1
  433.         # Reset option effect parameters to false for next clip iteration
  434.         timeremap_value = False
  435.         scale_value = False
  436.         x_move = False
  437.         y_move = False
  438.         rotation_value = False
  439.         ### End of for loop which processes each clip in timeline.
  440.  
  441.  
  442.     nuke.message('All clips processed successfully!')
  443.     return
  444.  
  445.  
  446.  
  447. '''
  448.         ### ??? ALTERNATIVE METHOD FOR CREATING THE SCRIPT FILES
  449.         ### This approach uses the script that import_xml is executed from as a base for creating nodes, and then using nuke.nodeCopy() to 'paste' the data into each script file.
  450.         ### The approach I ended up using instead just uses python to format .nk scripts as text, inputting the variables where relevant. It is much faster and more efficient.
  451.         for node in nuke.allNodes():
  452.             node.setSelected(True)
  453.         nuke.nodeDelete()
  454.  
  455.         # Create Read node
  456.         read = nuke.createNode("Read")
  457.         read.knob("file").setValue(file_path)
  458.         read.knob("frame_mode").setValue('offset')
  459.         read.knob("frame").setValue('1')
  460.         read.knob("first").setValue(0)
  461.         read.knob("last").setValue(clip_duration)
  462.  
  463.         # Create a NoOp node to hold shot info
  464.         #!!! This is not needed
  465.         #shotInfo = nuke.createNode('NoOp')
  466.         #shotInfo.knob('name').setValue(shot_name+"_info")
  467.         #shotInfo.addKnob( nuke.String_Knob("The original name of the clip", "clip_name", clip_name) )
  468.         #shotInfo.addKnob( nuke.String_Knob("Base name of the nuke script", "shot_name", shot_name) )
  469.  
  470.         # Create FrameRange node
  471.         frame_range = nuke.createNode("FrameRange")
  472.         frame_range.knob('label').setValue('[knob first_frame]-[knob last_frame]')
  473.         frame_range.knob('first_frame').setValue( in_point - handle_length )
  474.         frame_range.knob('last_frame').setValue( out_point-1 + handle_length )
  475.        
  476.         # Create Write node
  477.         write = nuke.createNode("Write")
  478.         write.knob('file').setValue('{0}{1}_v001.mov'.format(render_dir, shot_name))
  479.         #write.knob("file_type").setValue("mov")
  480.         #write.knob("mov.codec").setValue("apch")
  481.         #write.knob("mov.fps").setValue("23.976")
  482.  
  483.         # Create Viewer Node
  484.         nuke.createNode('Viewer')
  485.  
  486.         # Informational Backdrop Node
  487.         bd_node = nuke.createNode("BackdropNode")
  488.         bd_node.knob("tile_color").setValue(0x26434dff)
  489.         bd_node.knob("note_font_size").setValue(30)
  490.         bd_node.knob("bdwidth").setValue(234)
  491.         bd_node.knob("bdheight").setValue(254)
  492.         bd_node.knob("label").setValue('<img src=\"Read.png\"> Read Plate <br/><font size=1> %s <br/> %s-%s'%(shot_name,int(in_point),int(out_point)))
  493.  
  494.         # Set root script values
  495.         #nuke.toNode('root').knob('project_directory').setValue('[python {nuke.script_directory()}]')
  496.         #nuke.toNode('root').knob('first_frame').setValue( in_point-handle_length)
  497.         #nuke.toNode('root').knob('first_frame').setValue( (out_point-1) + handle_length)
  498.         #nuke.toNode('root').knob('format').setValue('HD')
  499.  
  500.         # Select all created nodes and copy them into a new script
  501.         for node in nuke.allNodes():
  502.             node.setSelected(True)
  503.         nuke.nodeCopy(nuke_file)
  504.         '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement