Advertisement
thureinfree

nuke clip

Nov 8th, 2024 (edited)
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.62 KB | None | 0 0
  1. import nuke
  2.  
  3. def create_contact_sheet(start_frame, step, num_clips, columns=5):
  4.     # Get the source node
  5.     source = nuke.selectedNode()  # Select the source node in Nuke before running the script
  6.  
  7.     # Create a list to store the TimeClip nodes
  8.     time_clips = []
  9.  
  10.     # Create TimeClip nodes for each 10-frame segment
  11.     for i in range(num_clips):
  12.         time_clip = nuke.createNode("TimeClip")
  13.         time_clip.setInput(0, source)  # Connect each TimeClip node to the source node
  14.  
  15.         # Set frame mode to "start at" and set the frame knob to start_frame
  16.         time_clip['frame_mode'].setValue("start at")
  17.         time_clip['frame'].setValue(str(start_frame))  # Set frame to start at start_frame
  18.  
  19.         # Define the frame range for this segment
  20.         start = start_frame + i * step
  21.         time_clip['first'].setValue(start)
  22.         time_clip['last'].setValue(start + step - 1)
  23.  
  24.         # Add the TimeClip node to the list
  25.         time_clips.append(time_clip)
  26.  
  27.     # Create the ContactSheet node after all TimeClip nodes are created
  28.     contact_sheet = nuke.createNode("ContactSheet")
  29.     contact_sheet['columns'].setValue(columns)
  30.     contact_sheet['rows'].setValue((num_clips + columns - 1) // columns)  # Calculate rows based on the number of clips
  31.  
  32.     # Connect each TimeClip node to an input of the ContactSheet
  33.     for index, time_clip in enumerate(time_clips):
  34.         contact_sheet.setInput(index, time_clip)
  35.  
  36.     return contact_sheet
  37.  
  38. # Run function with desired parameters
  39. # For example: starting at frame 1001, with 10-frame steps, and creating 5 segments
  40. create_contact_sheet(1001, 10, 5)
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement