Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import nuke
- def create_contact_sheet(start_frame, step, num_clips, columns=5):
- # Get the source node
- source = nuke.selectedNode() # Select the source node in Nuke before running the script
- # Create a list to store the TimeClip nodes
- time_clips = []
- # Create TimeClip nodes for each 10-frame segment
- for i in range(num_clips):
- time_clip = nuke.createNode("TimeClip")
- time_clip.setInput(0, source) # Connect each TimeClip node to the source node
- # Set frame mode to "start at" and set the frame knob to start_frame
- time_clip['frame_mode'].setValue("start at")
- time_clip['frame'].setValue(str(start_frame)) # Set frame to start at start_frame
- # Define the frame range for this segment
- start = start_frame + i * step
- time_clip['first'].setValue(start)
- time_clip['last'].setValue(start + step - 1)
- # Add the TimeClip node to the list
- time_clips.append(time_clip)
- # Create the ContactSheet node after all TimeClip nodes are created
- contact_sheet = nuke.createNode("ContactSheet")
- contact_sheet['columns'].setValue(columns)
- contact_sheet['rows'].setValue((num_clips + columns - 1) // columns) # Calculate rows based on the number of clips
- # Connect each TimeClip node to an input of the ContactSheet
- for index, time_clip in enumerate(time_clips):
- contact_sheet.setInput(index, time_clip)
- return contact_sheet
- # Run function with desired parameters
- # For example: starting at frame 1001, with 10-frame steps, and creating 5 segments
- create_contact_sheet(1001, 10, 5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement